1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Srmklive\PayPal\Traits\PayPalAPI; |
4
|
|
|
|
5
|
|
|
trait PaymentExperienceWebProfiles |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* List Web Experience Profiles. |
9
|
|
|
* |
10
|
|
|
* @throws \Throwable |
11
|
|
|
* |
12
|
|
|
* @return array|\Psr\Http\Message\StreamInterface|string |
13
|
|
|
* |
14
|
|
|
* @see https://developer.paypal.com/docs/api/payment-experience/v1/#web-profiles_get-list |
15
|
|
|
*/ |
16
|
|
|
public function listWebExperienceProfiles() |
17
|
|
|
{ |
18
|
|
|
$this->apiEndPoint = "v1/payment-experience/web-profiles"; |
19
|
|
|
$this->apiUrl = collect([$this->config['api_url'], $this->apiEndPoint])->implode('/'); |
20
|
|
|
|
21
|
|
|
$this->verb = 'get'; |
22
|
|
|
|
23
|
|
|
return $this->doPayPalRequest(); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Create a Web Experience Profile. |
28
|
|
|
* |
29
|
|
|
* @param array $data |
30
|
|
|
* @param string $request_id |
31
|
|
|
* |
32
|
|
|
* @throws \Throwable |
33
|
|
|
* |
34
|
|
|
* @return array|\Psr\Http\Message\StreamInterface|string |
35
|
|
|
* |
36
|
|
|
* @see https://developer.paypal.com/docs/api/payment-experience/v1/#web-profiles_get-list |
37
|
|
|
*/ |
38
|
|
|
public function createWebExperienceProfile(array $data, string $request_id) |
39
|
|
|
{ |
40
|
|
|
$this->apiEndPoint = "v1/payment-experience/web-profiles"; |
41
|
|
|
$this->apiUrl = collect([$this->config['api_url'], $this->apiEndPoint])->implode('/'); |
42
|
|
|
|
43
|
|
|
$this->options['headers']['PayPal-Request-Id'] = $request_id; |
44
|
|
|
$this->options['json'] = $data; |
45
|
|
|
|
46
|
|
|
$this->verb = 'post'; |
47
|
|
|
|
48
|
|
|
return $this->doPayPalRequest(); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Delete a Web Experience Profile. |
53
|
|
|
* |
54
|
|
|
* @param string $profile_id |
55
|
|
|
* |
56
|
|
|
* @throws \Throwable |
57
|
|
|
* |
58
|
|
|
* @return array|\Psr\Http\Message\StreamInterface|string |
59
|
|
|
* |
60
|
|
|
* @see https://developer.paypal.com/docs/api/payment-experience/v1/#web-profiles_get-list |
61
|
|
|
*/ |
62
|
|
|
public function deleteWebExperienceProfile(string $profile_id) |
63
|
|
|
{ |
64
|
|
|
$this->apiEndPoint = "v1/payment-experience/web-profiles/{$profile_id}"; |
65
|
|
|
$this->apiUrl = collect([$this->config['api_url'], $this->apiEndPoint])->implode('/'); |
66
|
|
|
|
67
|
|
|
$this->verb = 'delete'; |
68
|
|
|
|
69
|
|
|
return $this->doPayPalRequest(); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Partially update a Web Experience Profile. |
74
|
|
|
* |
75
|
|
|
* @param string $profile_id |
76
|
|
|
* @param array $data |
77
|
|
|
* |
78
|
|
|
* @throws \Throwable |
79
|
|
|
* |
80
|
|
|
* @return array|\Psr\Http\Message\StreamInterface|string |
81
|
|
|
* |
82
|
|
|
* @see https://developer.paypal.com/docs/api/payment-experience/v1/#web-profiles_get-list |
83
|
|
|
*/ |
84
|
|
|
public function patchWebExperienceProfile(string $profile_id, array $data) |
85
|
|
|
{ |
86
|
|
|
$this->apiEndPoint = "v1/payment-experience/web-profiles/{$profile_id}"; |
87
|
|
|
$this->apiUrl = collect([$this->config['api_url'], $this->apiEndPoint])->implode('/'); |
88
|
|
|
|
89
|
|
|
$this->options['json'] = $data; |
90
|
|
|
|
91
|
|
|
$this->verb = 'patch'; |
92
|
|
|
|
93
|
|
|
return $this->doPayPalRequest(); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Partially update a Web Experience Profile. |
98
|
|
|
* |
99
|
|
|
* @param string $profile_id |
100
|
|
|
* @param array $data |
101
|
|
|
* |
102
|
|
|
* @throws \Throwable |
103
|
|
|
* |
104
|
|
|
* @return array|\Psr\Http\Message\StreamInterface|string |
105
|
|
|
* |
106
|
|
|
* @see https://developer.paypal.com/docs/api/payment-experience/v1/#web-profiles_get-list |
107
|
|
|
*/ |
108
|
|
|
public function updateWebExperienceProfile(string $profile_id, array $data) |
109
|
|
|
{ |
110
|
|
|
$this->apiEndPoint = "v1/payment-experience/web-profiles/{$profile_id}"; |
111
|
|
|
$this->apiUrl = collect([$this->config['api_url'], $this->apiEndPoint])->implode('/'); |
112
|
|
|
|
113
|
|
|
$this->options['json'] = $data; |
114
|
|
|
|
115
|
|
|
$this->verb = 'put'; |
116
|
|
|
|
117
|
|
|
return $this->doPayPalRequest(); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* Delete a Web Experience Profile. |
122
|
|
|
* |
123
|
|
|
* @param string $profile_id |
124
|
|
|
* |
125
|
|
|
* @throws \Throwable |
126
|
|
|
* |
127
|
|
|
* @return array|\Psr\Http\Message\StreamInterface|string |
128
|
|
|
* |
129
|
|
|
* @see https://developer.paypal.com/docs/api/payment-experience/v1/#web-profiles_get-list |
130
|
|
|
*/ |
131
|
|
|
public function showWebExperienceProfileDetails(string $profile_id) |
132
|
|
|
{ |
133
|
|
|
$this->apiEndPoint = "v1/payment-experience/web-profiles/{$profile_id}"; |
134
|
|
|
$this->apiUrl = collect([$this->config['api_url'], $this->apiEndPoint])->implode('/'); |
135
|
|
|
|
136
|
|
|
$this->verb = 'get'; |
137
|
|
|
|
138
|
|
|
return $this->doPayPalRequest(); |
139
|
|
|
} |
140
|
|
|
} |
141
|
|
|
|