1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Srmklive\PayPal\Traits\PayPalAPI; |
4
|
|
|
|
5
|
|
|
trait Identity |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* Get user profile information. |
9
|
|
|
* |
10
|
|
|
* @throws \Throwable |
11
|
|
|
* |
12
|
|
|
* @return array|\Psr\Http\Message\StreamInterface|string |
13
|
|
|
* |
14
|
|
|
* @see https://developer.paypal.com/docs/api/identity/v1/#userinfo_get |
15
|
|
|
*/ |
16
|
|
|
public function showProfileInfo() |
17
|
|
|
{ |
18
|
|
|
$this->apiEndPoint = "v1/identity/oauth2/userinfo?schema=paypalv1.1"; |
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 merchant application. |
28
|
|
|
* |
29
|
|
|
* @param string $client_name |
30
|
|
|
* @param array $redirect_uris |
31
|
|
|
* @param array $contacts |
32
|
|
|
* @param string $payer_id |
33
|
|
|
* @param string $migrated_app |
34
|
|
|
* @param string $application_type |
35
|
|
|
* @param string $logo_url |
36
|
|
|
* |
37
|
|
|
* @throws \Throwable |
38
|
|
|
* |
39
|
|
|
* @return array|\Psr\Http\Message\StreamInterface|string |
40
|
|
|
* |
41
|
|
|
* @see https://developer.paypal.com/docs/api/identity/v1/#applications_post |
42
|
|
|
*/ |
43
|
|
|
public function createMerchantApplication(string $client_name, array $redirect_uris, array $contacts, string $payer_id, string $migrated_app, string $application_type = 'web', string $logo_url = '') |
44
|
|
|
{ |
45
|
|
|
$this->apiEndPoint = 'v1/identity/applications'; |
46
|
|
|
$this->apiUrl = collect([$this->config['api_url'], $this->apiEndPoint])->implode('/'); |
47
|
|
|
|
48
|
|
|
$this->options['json'] = [ |
49
|
|
|
'application_type' => $application_type, |
50
|
|
|
'redirect_uris' => $redirect_uris, |
51
|
|
|
'client_name' => $client_name, |
52
|
|
|
'contacts' => $contacts, |
53
|
|
|
'payer_id' => $payer_id, |
54
|
|
|
'migrated_app' => $migrated_app |
55
|
|
|
]; |
56
|
|
|
|
57
|
|
|
$this->verb = 'post'; |
58
|
|
|
|
59
|
|
|
return $this->doPayPalRequest(); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Create a merchant application. |
64
|
|
|
* |
65
|
|
|
* @param array $features |
66
|
|
|
* @param string $account_property |
67
|
|
|
* |
68
|
|
|
* @throws \Throwable |
69
|
|
|
* |
70
|
|
|
* @return array|\Psr\Http\Message\StreamInterface|string |
71
|
|
|
* |
72
|
|
|
* @see https://developer.paypal.com/docs/api/identity/v1/#account-settings_post |
73
|
|
|
*/ |
74
|
|
|
public function setAccountProperties(array $features, string $account_property = 'BRAINTREE_MERCHANT') |
75
|
|
|
{ |
76
|
|
|
$this->apiEndPoint = 'v1/identity/account-settings'; |
77
|
|
|
$this->apiUrl = collect([$this->config['api_url'], $this->apiEndPoint])->implode('/'); |
78
|
|
|
|
79
|
|
|
$this->options['json'] = [ |
80
|
|
|
'account_property' => $account_property, |
81
|
|
|
'features' => $features, |
82
|
|
|
]; |
83
|
|
|
|
84
|
|
|
$this->verb = 'post'; |
85
|
|
|
|
86
|
|
|
return $this->doPayPalRequest(); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Create a merchant application. |
91
|
|
|
* |
92
|
|
|
* @param string $account_property |
93
|
|
|
* |
94
|
|
|
* @throws \Throwable |
95
|
|
|
* |
96
|
|
|
* @return array|\Psr\Http\Message\StreamInterface|string |
97
|
|
|
* |
98
|
|
|
* @see https://developer.paypal.com/docs/api/identity/v1/#account-settings_deactivate |
99
|
|
|
*/ |
100
|
|
|
public function disableAccountProperties(string $account_property = 'BRAINTREE_MERCHANT') |
101
|
|
|
{ |
102
|
|
|
$this->apiEndPoint = 'v1/identity/account-settings/deactivate'; |
103
|
|
|
$this->apiUrl = collect([$this->config['api_url'], $this->apiEndPoint])->implode('/'); |
104
|
|
|
|
105
|
|
|
$this->options['json'] = [ |
106
|
|
|
'account_property' => $account_property, |
107
|
|
|
]; |
108
|
|
|
|
109
|
|
|
$this->verb = 'post'; |
110
|
|
|
|
111
|
|
|
return $this->doPayPalRequest(); |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
|