Subscriptions.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <?php
  2. namespace Srmklive\PayPal\Tests\Mocks\Responses;
  3. use GuzzleHttp\Utils;
  4. trait Subscriptions
  5. {
  6. /**
  7. * @return array
  8. */
  9. private function mockCreateSubscriptionResponse(): array
  10. {
  11. return Utils::jsonDecode('{
  12. "id": "I-BW452GLLEP1G",
  13. "status": "APPROVAL_PENDING",
  14. "status_update_time": "2018-12-10T21:20:49Z",
  15. "plan_id": "P-5ML4271244454362WXNWU5NQ",
  16. "start_time": "2018-11-01T00:00:00Z",
  17. "quantity": "20",
  18. "shipping_amount": {
  19. "currency_code": "USD",
  20. "value": "10.00"
  21. },
  22. "subscriber": {
  23. "name": {
  24. "given_name": "John",
  25. "surname": "Doe"
  26. },
  27. "email_address": "customer@example.com",
  28. "payer_id": "2J6QB8YJQSJRJ",
  29. "shipping_address": {
  30. "name": {
  31. "full_name": "John Doe"
  32. },
  33. "address": {
  34. "address_line_1": "2211 N First Street",
  35. "address_line_2": "Building 17",
  36. "admin_area_2": "San Jose",
  37. "admin_area_1": "CA",
  38. "postal_code": "95131",
  39. "country_code": "US"
  40. }
  41. }
  42. },
  43. "create_time": "2018-12-10T21:20:49Z",
  44. "links": [
  45. {
  46. "href": "https://www.paypal.com/webapps/billing/subscriptions?ba_token=BA-2M539689T3856352J",
  47. "rel": "approve",
  48. "method": "GET"
  49. },
  50. {
  51. "href": "https://api.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G",
  52. "rel": "edit",
  53. "method": "PATCH"
  54. },
  55. {
  56. "href": "https://api.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G",
  57. "rel": "self",
  58. "method": "GET"
  59. }
  60. ]
  61. }', true);
  62. }
  63. /**
  64. * @return array
  65. */
  66. private function mockGetSubscriptionDetailsResponse(): array
  67. {
  68. return Utils::jsonDecode('{
  69. "id": "I-BW452GLLEP1G",
  70. "plan_id": "P-5ML4271244454362WXNWU5NQ",
  71. "start_time": "2019-04-10T07:00:00Z",
  72. "quantity": "20",
  73. "shipping_amount": {
  74. "currency_code": "USD",
  75. "value": "10.0"
  76. },
  77. "subscriber": {
  78. "shipping_address": {
  79. "name": {
  80. "full_name": "John Doe"
  81. },
  82. "address": {
  83. "address_line_1": "2211 N First Street",
  84. "address_line_2": "Building 17",
  85. "admin_area_2": "San Jose",
  86. "admin_area_1": "CA",
  87. "postal_code": "95131",
  88. "country_code": "US"
  89. }
  90. },
  91. "name": {
  92. "given_name": "John",
  93. "surname": "Doe"
  94. },
  95. "email_address": "customer@example.com",
  96. "payer_id": "2J6QB8YJQSJRJ"
  97. },
  98. "billing_info": {
  99. "outstanding_balance": {
  100. "currency_code": "USD",
  101. "value": "1.0"
  102. },
  103. "cycle_executions": [
  104. {
  105. "tenure_type": "TRIAL",
  106. "sequence": 1,
  107. "cycles_completed": 0,
  108. "cycles_remaining": 2,
  109. "total_cycles": 2
  110. },
  111. {
  112. "tenure_type": "TRIAL",
  113. "sequence": 2,
  114. "cycles_completed": 0,
  115. "cycles_remaining": 3,
  116. "total_cycles": 3
  117. },
  118. {
  119. "tenure_type": "REGULAR",
  120. "sequence": 3,
  121. "cycles_completed": 0,
  122. "cycles_remaining": 12,
  123. "total_cycles": 12
  124. }
  125. ],
  126. "last_payment": {
  127. "amount": {
  128. "currency_code": "USD",
  129. "value": "1.15"
  130. },
  131. "time": "2019-04-09T10:27:20Z"
  132. },
  133. "next_billing_time": "2019-04-10T10:00:00Z",
  134. "failed_payments_count": 0
  135. },
  136. "create_time": "2019-04-09T10:26:04Z",
  137. "update_time": "2019-04-09T10:27:27Z",
  138. "links": [
  139. {
  140. "href": "https://api.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G/cancel",
  141. "rel": "cancel",
  142. "method": "POST"
  143. },
  144. {
  145. "href": "https://api.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G",
  146. "rel": "edit",
  147. "method": "PATCH"
  148. },
  149. {
  150. "href": "https://api.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G",
  151. "rel": "self",
  152. "method": "GET"
  153. },
  154. {
  155. "href": "https://api.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G/suspend",
  156. "rel": "suspend",
  157. "method": "POST"
  158. },
  159. {
  160. "href": "https://api.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G/capture",
  161. "rel": "capture",
  162. "method": "POST"
  163. }
  164. ],
  165. "status": "ACTIVE",
  166. "status_update_time": "2019-04-09T10:27:27Z"
  167. }', true);
  168. }
  169. /**
  170. * @return array
  171. */
  172. private function mockUpdateSubscriptionItemsResponse(): array
  173. {
  174. return Utils::jsonDecode('{
  175. "plan_id": "P-5ML4271244454362WXNWU5NQ",
  176. "effective_time": "2018-11-01T00:00:00Z",
  177. "shipping_amount": {
  178. "currency_code": "USD",
  179. "value": "10.00"
  180. },
  181. "shipping_address": {
  182. "name": {
  183. "full_name": "John Doe"
  184. },
  185. "address": {
  186. "address_line_1": "2211 N First Street",
  187. "address_line_2": "Building 17",
  188. "admin_area_2": "San Jose",
  189. "admin_area_1": "CA",
  190. "postal_code": "95131",
  191. "country_code": "US"
  192. }
  193. },
  194. "links": [
  195. {
  196. "href": "https://www.paypal.com/webapps/billing/subscriptions/update?ba_token=BA-2M539689T3856352J",
  197. "rel": "approve",
  198. "method": "GET"
  199. }
  200. ]
  201. }', true);
  202. }
  203. /**
  204. * @return array
  205. */
  206. private function mockListSubscriptionTransactionsResponse(): array
  207. {
  208. return Utils::jsonDecode('{
  209. "transactions": [
  210. {
  211. "id": "TRFGHNJKOIIOJKL",
  212. "status": "COMPLETED",
  213. "payer_email": "customer@example.com",
  214. "payer_name": {
  215. "given_name": "John",
  216. "surname": "Doe"
  217. },
  218. "amount_with_breakdown": {
  219. "gross_amount": {
  220. "currency_code": "USD",
  221. "value": "10.00"
  222. },
  223. "fee_amount": {
  224. "currency_code": "USD",
  225. "value": "1.00"
  226. },
  227. "net_amount": {
  228. "currency_code": "USD",
  229. "value": "9.00"
  230. }
  231. },
  232. "time": "2018-03-16T07:40:20.940Z"
  233. },
  234. {
  235. "id": "VDFG45345FFGS",
  236. "status": "COMPLETED",
  237. "payer_email": "customer2@example.com",
  238. "payer_name": {
  239. "given_name": "Jhonny",
  240. "surname": "Cat"
  241. },
  242. "amount_with_breakdown": {
  243. "gross_amount": {
  244. "currency_code": "USD",
  245. "value": "15.00"
  246. },
  247. "fee_amount": {
  248. "currency_code": "USD",
  249. "value": "1.00"
  250. },
  251. "net_amount": {
  252. "currency_code": "USD",
  253. "value": "14.00"
  254. }
  255. },
  256. "time": "2018-08-21T07:50:20.940Z"
  257. }
  258. ],
  259. "links": [
  260. {
  261. "href": "https://api.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G/transactions?start_time=2018-01-21T07:50:20.940Z&end_time=2018-08-21T07:50:20.940Z",
  262. "rel": "self",
  263. "method": "GET"
  264. }
  265. ]
  266. }', true);
  267. }
  268. }