| 676 |
lars |
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 |
|
|
|
20 |
$this->verb = 'get';
|
|
|
21 |
|
|
|
22 |
return $this->doPayPalRequest();
|
|
|
23 |
}
|
|
|
24 |
|
|
|
25 |
/**
|
|
|
26 |
* Create a merchant application.
|
|
|
27 |
*
|
|
|
28 |
* @param string $client_name
|
|
|
29 |
* @param array $redirect_uris
|
|
|
30 |
* @param array $contacts
|
|
|
31 |
* @param string $payer_id
|
|
|
32 |
* @param string $migrated_app
|
|
|
33 |
* @param string $application_type
|
|
|
34 |
* @param string $logo_url
|
|
|
35 |
*
|
|
|
36 |
* @throws \Throwable
|
|
|
37 |
*
|
|
|
38 |
* @return array|\Psr\Http\Message\StreamInterface|string
|
|
|
39 |
*
|
|
|
40 |
* @see https://developer.paypal.com/docs/api/identity/v1/#applications_post
|
|
|
41 |
*/
|
|
|
42 |
public function createMerchantApplication(string $client_name, array $redirect_uris, array $contacts, string $payer_id, string $migrated_app, string $application_type = 'web', string $logo_url = '')
|
|
|
43 |
{
|
|
|
44 |
$this->apiEndPoint = 'v1/identity/applications';
|
|
|
45 |
|
|
|
46 |
$this->options['json'] = array_filter([
|
|
|
47 |
'application_type' => $application_type,
|
|
|
48 |
'redirect_uris' => $redirect_uris,
|
|
|
49 |
'client_name' => $client_name,
|
|
|
50 |
'contacts' => $contacts,
|
|
|
51 |
'payer_id' => $payer_id,
|
|
|
52 |
'migrated_app' => $migrated_app,
|
|
|
53 |
'logo_uri' => $logo_url,
|
|
|
54 |
]);
|
|
|
55 |
|
|
|
56 |
$this->verb = 'post';
|
|
|
57 |
|
|
|
58 |
return $this->doPayPalRequest();
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
/**
|
|
|
62 |
* Create a merchant application.
|
|
|
63 |
*
|
|
|
64 |
* @param array $features
|
|
|
65 |
* @param string $account_property
|
|
|
66 |
*
|
|
|
67 |
* @throws \Throwable
|
|
|
68 |
*
|
|
|
69 |
* @return array|\Psr\Http\Message\StreamInterface|string
|
|
|
70 |
*
|
|
|
71 |
* @see https://developer.paypal.com/docs/api/identity/v1/#account-settings_post
|
|
|
72 |
*/
|
|
|
73 |
public function setAccountProperties(array $features, string $account_property = 'BRAINTREE_MERCHANT')
|
|
|
74 |
{
|
|
|
75 |
$this->apiEndPoint = 'v1/identity/account-settings';
|
|
|
76 |
|
|
|
77 |
$this->options['json'] = [
|
|
|
78 |
'account_property' => $account_property,
|
|
|
79 |
'features' => $features,
|
|
|
80 |
];
|
|
|
81 |
|
|
|
82 |
$this->verb = 'post';
|
|
|
83 |
|
|
|
84 |
return $this->doPayPalRequest();
|
|
|
85 |
}
|
|
|
86 |
|
|
|
87 |
/**
|
|
|
88 |
* Create a merchant application.
|
|
|
89 |
*
|
|
|
90 |
* @param string $account_property
|
|
|
91 |
*
|
|
|
92 |
* @throws \Throwable
|
|
|
93 |
*
|
|
|
94 |
* @return array|\Psr\Http\Message\StreamInterface|string
|
|
|
95 |
*
|
|
|
96 |
* @see https://developer.paypal.com/docs/api/identity/v1/#account-settings_deactivate
|
|
|
97 |
*/
|
|
|
98 |
public function disableAccountProperties(string $account_property = 'BRAINTREE_MERCHANT')
|
|
|
99 |
{
|
|
|
100 |
$this->apiEndPoint = 'v1/identity/account-settings/deactivate';
|
|
|
101 |
|
|
|
102 |
$this->options['json'] = [
|
|
|
103 |
'account_property' => $account_property,
|
|
|
104 |
];
|
|
|
105 |
|
|
|
106 |
$this->verb = 'post';
|
|
|
107 |
|
|
|
108 |
return $this->doPayPalRequest();
|
|
|
109 |
}
|
|
|
110 |
|
|
|
111 |
/**
|
|
|
112 |
* Get a client token.
|
|
|
113 |
*
|
|
|
114 |
* @throws \Throwable
|
|
|
115 |
*
|
|
|
116 |
* @return array|\Psr\Http\Message\StreamInterface|string
|
|
|
117 |
*
|
|
|
118 |
* @see https://developer.paypal.com/docs/multiparty/checkout/advanced/integrate/#link-sampleclienttokenrequest
|
|
|
119 |
*/
|
|
|
120 |
public function getClientToken()
|
|
|
121 |
{
|
|
|
122 |
$this->apiEndPoint = 'v1/identity/generate-token';
|
|
|
123 |
|
|
|
124 |
$this->verb = 'post';
|
|
|
125 |
|
|
|
126 |
return $this->doPayPalRequest();
|
|
|
127 |
}
|
|
|
128 |
}
|