PaymentMethodsTokens.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. <?php
  2. namespace Srmklive\PayPal\Tests\Mocks\Responses;
  3. use GuzzleHttp\Utils;
  4. trait PaymentMethodsTokens
  5. {
  6. /**
  7. * @return array
  8. */
  9. private function mockCreatePaymentMethodsTokenResponse(): array
  10. {
  11. return Utils::jsonDecode('{
  12. "id": "8kk8451t",
  13. "customer": {
  14. "id": "customer_4029352050"
  15. },
  16. "payment_source": {
  17. "card": {
  18. "brand": "VISA",
  19. "last_digits": "1111",
  20. "expiry": "2027-02",
  21. "name": "John Doe",
  22. "billing_address": {
  23. "address_line_1": "2211 N First Street",
  24. "address_line_2": "17.3.160",
  25. "admin_area_2": "San Jose",
  26. "admin_area_1": "CA",
  27. "postal_code": "95131",
  28. "country_code": "US"
  29. }
  30. }
  31. },
  32. "links": [
  33. {
  34. "rel": "self",
  35. "href": "https://api-m.paypal.com/v3/vault/payment-tokens/8kk8451t",
  36. "method": "GET",
  37. "encType": "application/json"
  38. },
  39. {
  40. "rel": "delete",
  41. "href": "https://api-m.paypal.com/v3/vault/payment-tokens/8kk8451t",
  42. "method": "DELETE",
  43. "encType": "application/json"
  44. }
  45. ]
  46. }', true);
  47. }
  48. /**
  49. * @return array
  50. */
  51. private function mockListPaymentMethodsTokensResponse(): array
  52. {
  53. return Utils::jsonDecode('{
  54. "customer": {
  55. "id": "customer_4029352050"
  56. },
  57. "payment_tokens": [
  58. {
  59. "id": "8kk8451t",
  60. "customer": {
  61. "id": "customer_4029352050"
  62. },
  63. "payment_source": {
  64. "card": {
  65. "name": "John Doe",
  66. "brand": "VISA",
  67. "last_digits": "1111",
  68. "expiry": "2027-02",
  69. "billing_address": {
  70. "id": "kk",
  71. "address_line_1": "2211 N First Street",
  72. "address_line_2": "17.3.160",
  73. "admin_area_2": "San Jose",
  74. "admin_area_1": "CA",
  75. "postal_code": "95131",
  76. "country_code": "US"
  77. }
  78. }
  79. },
  80. "links": [
  81. {
  82. "rel": "self",
  83. "href": "https://api-m.paypal.com/v3/vault/payment-tokens/8kk8451t",
  84. "method": "GET",
  85. "encType": "application/json"
  86. },
  87. {
  88. "rel": "delete",
  89. "href": "https://api-m.paypal.com/v3/vault/payment-tokens/8kk8451t",
  90. "method": "DELETE",
  91. "encType": "application/json"
  92. }
  93. ]
  94. },
  95. {
  96. "id": "fgh6561t",
  97. "customer": {
  98. "id": "customer_4029352050"
  99. },
  100. "payment_source": {
  101. "paypal": {
  102. "description": "Description for PayPal to be shown to PayPal payer",
  103. "email_address": "john.doe@example.com",
  104. "account_id": "VYYFH3WJ4JPJQ",
  105. "shipping": {
  106. "name": {
  107. "full_name": "John Doe"
  108. },
  109. "address": {
  110. "address_line_1": "2211 N First Street",
  111. "address_line_2": "17.3.160",
  112. "admin_area_2": "San Jose",
  113. "admin_area_1": "CA",
  114. "postal_code": "95131",
  115. "country_code": "US"
  116. }
  117. },
  118. "usage_pattern": "IMMEDIATE",
  119. "usage_type": "MERCHANT",
  120. "customer_type": "CONSUMER",
  121. "name": {
  122. "given_name": "John",
  123. "surname": "Doe"
  124. },
  125. "address": {
  126. "address_line_1": "2211 N First Street",
  127. "address_line_2": "17.3.160",
  128. "admin_area_2": "San Jose",
  129. "admin_area_1": "CA",
  130. "postal_code": "95131",
  131. "country_code": "US"
  132. }
  133. }
  134. },
  135. "links": [
  136. {
  137. "rel": "self",
  138. "href": "https://api-m.paypal.com/v3/vault/payment-tokens/fgh6561t",
  139. "method": "GET",
  140. "encType": "application/json"
  141. },
  142. {
  143. "rel": "delete",
  144. "href": "https://api-m.paypal.com/v3/vault/payment-tokens/fgh6561t",
  145. "method": "DELETE",
  146. "encType": "application/json"
  147. }
  148. ]
  149. },
  150. {
  151. "id": "hg654s1t",
  152. "customer": {
  153. "id": "customer_4029352050"
  154. },
  155. "payment_source": {
  156. "venmo": {
  157. "description": "Description for Venmo to be shown to Venmo payer",
  158. "shipping": {
  159. "name": {
  160. "full_name": "John Doe"
  161. },
  162. "address": {
  163. "address_line_1": "2211 N First Street",
  164. "address_line_2": "17.3.160",
  165. "admin_area_2": "San Jose",
  166. "admin_area_1": "CA",
  167. "postal_code": "95131",
  168. "country_code": "US"
  169. }
  170. },
  171. "usage_pattern": "IMMEDIATE",
  172. "usage_type": "MERCHANT",
  173. "customer_type": "CONSUMER",
  174. "email_address": "john.doe@example.com",
  175. "user_name": "johndoe",
  176. "name": {
  177. "given_name": "John",
  178. "surname": "Doe"
  179. },
  180. "account_id": "VYYFH3WJ4JPJQ",
  181. "address": {
  182. "address_line_1": "PayPal",
  183. "address_line_2": "2211 North 1st Street",
  184. "admin_area_1": "CA",
  185. "admin_area_2": "San Jose",
  186. "postal_code": "96112",
  187. "country_code": "US"
  188. }
  189. }
  190. },
  191. "links": [
  192. {
  193. "rel": "self",
  194. "href": "https://api-m.paypal.com/v3/vault/payment-tokens/hg654s1t",
  195. "method": "GET",
  196. "encType": "application/json"
  197. },
  198. {
  199. "rel": "delete",
  200. "href": "https://api-m.paypal.com/v3/vault/payment-tokens/hg654s1t",
  201. "method": "DELETE",
  202. "encType": "application/json"
  203. }
  204. ]
  205. },
  206. {
  207. "id": "8kk8457",
  208. "payment_source": {
  209. "apple_pay": {
  210. "card": {
  211. "name": "John Doe",
  212. "last_digits": "1111",
  213. "type": "CREDIT",
  214. "brand": "VISA",
  215. "billing_address": {
  216. "address_line_1": "2211 N First Street",
  217. "address_line_2": "17.3.160",
  218. "admin_area_1": "CA",
  219. "admin_area_2": "San Jose",
  220. "postal_code": "95131",
  221. "country_code": "US"
  222. }
  223. }
  224. }
  225. },
  226. "links": [
  227. {
  228. "rel": "self",
  229. "href": "https://api-m.paypal.com/v3/vault/payment-tokens/8kk845",
  230. "method": "GET"
  231. },
  232. {
  233. "rel": "delete",
  234. "href": "https://api-m.paypal.com/v3/vault/payment-tokens/8kk845",
  235. "method": "DELETE"
  236. }
  237. ]
  238. },
  239. {
  240. "id": "8kk8458",
  241. "payment_source": {
  242. "bank": {
  243. "ach_debit": {
  244. "last_digits": "9999",
  245. "routing_number": "307075259",
  246. "account_type": "CHECKING",
  247. "ownership_type": "PERSONAL",
  248. "account_holder_name": "John Doe",
  249. "verification_status": "VERIFIED"
  250. }
  251. }
  252. },
  253. "links": [
  254. {
  255. "rel": "self",
  256. "href": "https://api-m.paypal.com/v3/vault/payment-tokens/8kk8458",
  257. "method": "GET",
  258. "encType": "application/json"
  259. },
  260. {
  261. "rel": "delete",
  262. "href": "https://api-m.paypal.com/v3/vault/payment-tokens/hg654s1t",
  263. "method": "DELETE",
  264. "encType": "application/json"
  265. }
  266. ]
  267. }
  268. ],
  269. "links": [
  270. {
  271. "rel": "self",
  272. "href": "https://api-m.paypal.com/v3/vault/payment-tokens?customer_id=customer_4029352050&page=1&page_size=5&total_required=false",
  273. "method": "GET",
  274. "encType": "application/json"
  275. },
  276. {
  277. "rel": "first",
  278. "href": "https://api-m.paypal.com/v3/vault/payment-tokens?customer_id=customer_4029352050&page=1&page_size=5&total_required=false",
  279. "method": "GET",
  280. "encType": "application/json"
  281. },
  282. {
  283. "rel": "last",
  284. "href": "https://api-m.paypal.com/v3/vault/payment-tokens?customer_id=customer_4029352050&page=1&page_size=5&total_required=false",
  285. "method": "GET",
  286. "encType": "application/json"
  287. }
  288. ]
  289. }', true);
  290. }
  291. /**
  292. * @return array
  293. */
  294. private function mockCreatePaymentSetupTokenResponse(): array
  295. {
  296. return Utils::jsonDecode('{
  297. "payment_source": {
  298. "card": {
  299. "number": "4111111111111111",
  300. "expiry": "2027-02",
  301. "name": "John Doe",
  302. "billing_address": {
  303. "address_line_1": "2211 N First Street",
  304. "address_line_2": "17.3.160",
  305. "admin_area_1": "CA",
  306. "admin_area_2": "San Jose",
  307. "postal_code": "95131",
  308. "country_code": "US"
  309. },
  310. "experience_context": {
  311. "brand_name": "YourBrandName",
  312. "locale": "en-US",
  313. "return_url": "https://example.com/returnUrl",
  314. "cancel_url": "https://example.com/cancelUrl"
  315. }
  316. }
  317. }
  318. }', true);
  319. }
  320. /**
  321. * @return array
  322. */
  323. private function mockListPaymentSetupTokenResponse(): array
  324. {
  325. return Utils::jsonDecode('{
  326. "id": "5C991763VB2781612",
  327. "customer": {
  328. "id": "customer_4029352050"
  329. },
  330. "status": "APPROVED",
  331. "payment_source": {
  332. "card": {
  333. "last_digits": "1111",
  334. "expiry": "2027-02",
  335. "name": "John Doe",
  336. "billing_address": {
  337. "address_line_1": "2211 N First Street",
  338. "address_line_2": "17.3.160",
  339. "admin_area_2": "San Jose",
  340. "admin_area_1": "CA",
  341. "postal_code": "95131",
  342. "country_code": "US"
  343. }
  344. }
  345. },
  346. "links": [
  347. {
  348. "rel": "self",
  349. "href": "https://api-m.paypal.com/v3/vault/setup-tokens/5C991763VB2781612",
  350. "method": "GET",
  351. "encType": "application/json"
  352. },
  353. {
  354. "rel": "confirm",
  355. "href": "https://api-m.paypal.com/v3/vault/payment-token",
  356. "method": "POST",
  357. "encType": "application/json"
  358. }
  359. ]
  360. }', true);
  361. }
  362. }