Orders.php 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <?php
  2. namespace Srmklive\PayPal\Tests\Mocks\Responses;
  3. use GuzzleHttp\Utils;
  4. trait Orders
  5. {
  6. /**
  7. * @return array
  8. */
  9. public function mockCreateOrdersResponse(): array
  10. {
  11. return Utils::jsonDecode('{
  12. "id": "5O190127TN364715T",
  13. "status": "CREATED",
  14. "links": [
  15. {
  16. "href": "https://api-m.paypal.com/v2/checkout/orders/5O190127TN364715T",
  17. "rel": "self",
  18. "method": "GET"
  19. },
  20. {
  21. "href": "https://www.paypal.com/checkoutnow?token=5O190127TN364715T",
  22. "rel": "approve",
  23. "method": "GET"
  24. },
  25. {
  26. "href": "https://api-m.paypal.com/v2/checkout/orders/5O190127TN364715T",
  27. "rel": "update",
  28. "method": "PATCH"
  29. },
  30. {
  31. "href": "https://api-m.paypal.com/v2/checkout/orders/5O190127TN364715T/capture",
  32. "rel": "capture",
  33. "method": "POST"
  34. }
  35. ]
  36. }', true);
  37. }
  38. /**
  39. * @return empty
  40. */
  41. public function mockUpdateOrdersResponse()
  42. {
  43. return '';
  44. }
  45. /**
  46. * @return array
  47. */
  48. public function mockOrderDetailsResponse(): array
  49. {
  50. return Utils::jsonDecode('{
  51. "id": "5O190127TN364715T",
  52. "status": "PAYER_ACTION_REQUIRED",
  53. "intent": "CAPTURE",
  54. "payment_source": {
  55. "alipay": {
  56. "name": "John Doe",
  57. "country_code": "C2"
  58. }
  59. },
  60. "purchase_units": [
  61. {
  62. "reference_id": "d9f80740-38f0-11e8-b467-0ed5f89f718b",
  63. "amount": {
  64. "currency_code": "USD",
  65. "value": "100.00"
  66. },
  67. "payee": {
  68. "email_address": "payee@example.com"
  69. }
  70. }
  71. ],
  72. "create_time": "2018-04-01T21:18:49Z",
  73. "links": [
  74. {
  75. "href": "https://www.paypal.com/payment/alipay?token=5O190127TN364715T",
  76. "rel": "payer-action",
  77. "method": "GET"
  78. },
  79. {
  80. "href": "https://api-m.paypal.com/v2/checkout/orders/5O190127TN364715T",
  81. "rel": "self",
  82. "method": "GET"
  83. }
  84. ]
  85. }', true);
  86. }
  87. /**
  88. * @return array
  89. */
  90. public function mockOrderPaymentAuthorizedResponse(): array
  91. {
  92. return Utils::jsonDecode('{
  93. "id": "5O190127TN364715T",
  94. "status": "COMPLETED",
  95. "payer": {
  96. "name": {
  97. "given_name": "John",
  98. "surname": "Doe"
  99. },
  100. "email_address": "customer@example.com",
  101. "payer_id": "QYR5Z8XDVJNXQ"
  102. },
  103. "purchase_units": [
  104. {
  105. "reference_id": "d9f80740-38f0-11e8-b467-0ed5f89f718b",
  106. "shipping": {
  107. "address": {
  108. "address_line_1": "2211 N First Street",
  109. "address_line_2": "Building 17",
  110. "admin_area_2": "San Jose",
  111. "admin_area_1": "CA",
  112. "postal_code": "95131",
  113. "country_code": "US"
  114. }
  115. },
  116. "payments": {
  117. "authorizations": [
  118. {
  119. "id": "0AW2184448108334S",
  120. "status": "CREATED",
  121. "amount": {
  122. "currency_code": "USD",
  123. "value": "100.00"
  124. },
  125. "seller_protection": {
  126. "status": "ELIGIBLE",
  127. "dispute_categories": [
  128. "ITEM_NOT_RECEIVED",
  129. "UNAUTHORIZED_TRANSACTION"
  130. ]
  131. },
  132. "expiration_time": "2018-05-01T21:20:49Z",
  133. "create_time": "2018-04-01T21:20:49Z",
  134. "update_time": "2018-04-01T21:20:49Z",
  135. "links": [
  136. {
  137. "href": "https://api-m.paypal.com/v2/payments/authorizations/0AW2184448108334S",
  138. "rel": "self",
  139. "method": "GET"
  140. },
  141. {
  142. "href": "https://api-m.paypal.com/v2/payments/authorizations/0AW2184448108334S/capture",
  143. "rel": "capture",
  144. "method": "POST"
  145. },
  146. {
  147. "href": "https://api-m.paypal.com/v2/payments/authorizations/0AW2184448108334S/void",
  148. "rel": "void",
  149. "method": "POST"
  150. },
  151. {
  152. "href": "https://api-m.paypal.com/v2/payments/authorizations/0AW2184448108334S/reauthorize",
  153. "rel": "reauthorize",
  154. "method": "POST"
  155. }
  156. ]
  157. }
  158. ]
  159. }
  160. }
  161. ],
  162. "links": [
  163. {
  164. "href": "https://api-m.paypal.com/v2/checkout/orders/5O190127TN364715T",
  165. "rel": "self",
  166. "method": "GET"
  167. }
  168. ]
  169. }', true);
  170. }
  171. /**
  172. * @return array
  173. */
  174. public function mockOrderPaymentCapturedResponse(): array
  175. {
  176. return Utils::jsonDecode('{
  177. "id": "5O190127TN364715T",
  178. "status": "COMPLETED",
  179. "payer": {
  180. "name": {
  181. "given_name": "John",
  182. "surname": "Doe"
  183. },
  184. "email_address": "customer@example.com",
  185. "payer_id": "QYR5Z8XDVJNXQ"
  186. },
  187. "purchase_units": [
  188. {
  189. "reference_id": "d9f80740-38f0-11e8-b467-0ed5f89f718b",
  190. "shipping": {
  191. "address": {
  192. "address_line_1": "2211 N First Street",
  193. "address_line_2": "Building 17",
  194. "admin_area_2": "San Jose",
  195. "admin_area_1": "CA",
  196. "postal_code": "95131",
  197. "country_code": "US"
  198. }
  199. },
  200. "payments": {
  201. "captures": [
  202. {
  203. "id": "3C679366HH908993F",
  204. "status": "COMPLETED",
  205. "amount": {
  206. "currency_code": "USD",
  207. "value": "100.00"
  208. },
  209. "seller_protection": {
  210. "status": "ELIGIBLE",
  211. "dispute_categories": [
  212. "ITEM_NOT_RECEIVED",
  213. "UNAUTHORIZED_TRANSACTION"
  214. ]
  215. },
  216. "final_capture": true,
  217. "disbursement_mode": "INSTANT",
  218. "seller_receivable_breakdown": {
  219. "gross_amount": {
  220. "currency_code": "USD",
  221. "value": "100.00"
  222. },
  223. "paypal_fee": {
  224. "currency_code": "USD",
  225. "value": "3.00"
  226. },
  227. "net_amount": {
  228. "currency_code": "USD",
  229. "value": "97.00"
  230. }
  231. },
  232. "create_time": "2018-04-01T21:20:49Z",
  233. "update_time": "2018-04-01T21:20:49Z",
  234. "links": [
  235. {
  236. "href": "https://api-m.paypal.com/v2/payments/captures/3C679366HH908993F",
  237. "rel": "self",
  238. "method": "GET"
  239. },
  240. {
  241. "href": "https://api-m.paypal.com/v2/payments/captures/3C679366HH908993F/refund",
  242. "rel": "refund",
  243. "method": "POST"
  244. }
  245. ]
  246. }
  247. ]
  248. }
  249. }
  250. ],
  251. "links": [
  252. {
  253. "href": "https://api-m.paypal.com/v2/checkout/orders/5O190127TN364715T",
  254. "rel": "self",
  255. "method": "GET"
  256. }
  257. ]
  258. }', true);
  259. }
  260. private function mockConfirmOrderResponse()
  261. {
  262. return Utils::jsonDecode('{
  263. "id": "5O190127TN364715T",
  264. "status": "PAYER_ACTION_REQUIRED",
  265. "payment_source": {
  266. "paypal": {
  267. "name": {
  268. "given_name": "John",
  269. "surname": "Doe"
  270. },
  271. "email_address": "customer@example.com"
  272. }
  273. },
  274. "payer": {
  275. "name": {
  276. "given_name": "John",
  277. "surname": "Doe"
  278. },
  279. "email_address": "customer@example.com"
  280. },
  281. "links": [
  282. {
  283. "href": "https://api.paypal.com/v2/checkout/orders/5O190127TN364715T",
  284. "rel": "self",
  285. "method": "GET"
  286. },
  287. {
  288. "href": "https://www.paypal.com/checkoutnow?token=5O190127TN364715T",
  289. "rel": "payer-action",
  290. "method": "GET"
  291. }
  292. ]
  293. }', true);
  294. }
  295. }