BillingPlans.php 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. <?php
  2. namespace Srmklive\PayPal\Tests\Mocks\Responses;
  3. use GuzzleHttp\Utils;
  4. trait BillingPlans
  5. {
  6. /**
  7. * @return array
  8. */
  9. private function mockCreatePlansResponse(): array
  10. {
  11. return Utils::jsonDecode('{
  12. "id": "P-5ML4271244454362WXNWU5NQ",
  13. "product_id": "PROD-XXCD1234QWER65782",
  14. "name": "Video Streaming Service Plan",
  15. "description": "Video Streaming Service basic plan",
  16. "status": "ACTIVE",
  17. "billing_cycles": [
  18. {
  19. "frequency": {
  20. "interval_unit": "MONTH",
  21. "interval_count": 1
  22. },
  23. "tenure_type": "TRIAL",
  24. "sequence": 1,
  25. "total_cycles": 2,
  26. "pricing_scheme": {
  27. "fixed_price": {
  28. "value": "3",
  29. "currency_code": "USD"
  30. },
  31. "version": 1,
  32. "create_time": "2020-05-27T12:13:51Z",
  33. "update_time": "2020-05-27T12:13:51Z"
  34. }
  35. },
  36. {
  37. "frequency": {
  38. "interval_unit": "MONTH",
  39. "interval_count": 1
  40. },
  41. "tenure_type": "TRIAL",
  42. "sequence": 2,
  43. "total_cycles": 3,
  44. "pricing_scheme": {
  45. "fixed_price": {
  46. "currency_code": "USD",
  47. "value": "6"
  48. },
  49. "version": 1,
  50. "create_time": "2020-05-27T12:13:51Z",
  51. "update_time": "2020-05-27T12:13:51Z"
  52. }
  53. },
  54. {
  55. "frequency": {
  56. "interval_unit": "MONTH",
  57. "interval_count": 1
  58. },
  59. "tenure_type": "REGULAR",
  60. "sequence": 3,
  61. "total_cycles": 12,
  62. "pricing_scheme": {
  63. "fixed_price": {
  64. "currency_code": "USD",
  65. "value": "10"
  66. },
  67. "version": 1,
  68. "create_time": "2020-05-27T12:13:51Z",
  69. "update_time": "2020-05-27T12:13:51Z"
  70. }
  71. }
  72. ],
  73. "payment_preferences": {
  74. "auto_bill_outstanding": true,
  75. "setup_fee": {
  76. "value": "10",
  77. "currency_code": "USD"
  78. },
  79. "setup_fee_failure_action": "CONTINUE",
  80. "payment_failure_threshold": 3
  81. },
  82. "taxes": {
  83. "percentage": "10",
  84. "inclusive": false
  85. },
  86. "create_time": "2020-05-27T12:13:51Z",
  87. "update_time": "2020-05-27T12:13:51Z",
  88. "links": [
  89. {
  90. "href": "https://api.paypal.com/v1/billing/plans/P-5ML4271244454362WXNWU5NQ",
  91. "rel": "self",
  92. "method": "GET"
  93. },
  94. {
  95. "href": "https://api.paypal.com/v1/billing/plans/P-5ML4271244454362WXNWU5NQ",
  96. "rel": "edit",
  97. "method": "PATCH"
  98. },
  99. {
  100. "href": "https://api.paypal.com/v1/billing/plans/P-5ML4271244454362WXNWU5NQ/deactivate",
  101. "rel": "deactivate",
  102. "method": "POST"
  103. },
  104. {
  105. "href": "https://api.paypal.com/v1/billing/plans/P-5ML4271244454362WXNWU5NQ/update-pricing-schemes",
  106. "rel": "edit",
  107. "method": "POST"
  108. }
  109. ]
  110. }', true);
  111. }
  112. /**
  113. * @return array
  114. */
  115. private function mockListPlansResponse(): array
  116. {
  117. return Utils::jsonDecode('{
  118. "total_items": 12,
  119. "total_pages": 6,
  120. "plans": [
  121. {
  122. "id": "P-5ML4271244454362WXNWU5NQ",
  123. "product_id": "PROD-XXCD1234QWER65782",
  124. "status": "ACTIVE",
  125. "name": "Zoho Marketing Campaign Plan",
  126. "description": "Zoho Marketing Campaign Plan",
  127. "create_time": "2018-12-10T21:20:49Z",
  128. "links": [
  129. {
  130. "href": "https://api.paypal.com/v1/billing/plans/P-5ML4271244454362WXNWU5NQ",
  131. "rel": "self",
  132. "method": "GET"
  133. }
  134. ]
  135. },
  136. {
  137. "id": "P-6LL4271454454362WXNWU5NQ",
  138. "product_id": "PROD-XXCD1234QWER65782",
  139. "status": "ACTIVE",
  140. "name": "Zoho Marketing Campaign Basic Plan",
  141. "description": "Zoho Marketing Campaign Plan",
  142. "create_time": "2019-01-10T21:20:49Z",
  143. "links": [
  144. {
  145. "href": "https://api.paypal.com/v1/billing/plans/P-6LL4271454454362WXNWU5NQ",
  146. "rel": "self",
  147. "method": "GET"
  148. }
  149. ]
  150. }
  151. ],
  152. "links": [
  153. {
  154. "href": "https://api.paypal.com/v1/billing/plans?product_id=PROD-XXCD1234QWER65782&page_size=2&page=1",
  155. "rel": "self",
  156. "method": "GET"
  157. },
  158. {
  159. "href": "https://api.paypal.com/v1/billing/plans?product_id=PROD-XXCD1234QWER65782&page_size=2&page=1",
  160. "rel": "first",
  161. "method": "GET"
  162. },
  163. {
  164. "href": "https://api.paypal.com/v1/billing/plans?product_id=PROD-XXCD1234QWER65782&page_size=2&page=2",
  165. "rel": "next",
  166. "method": "GET"
  167. },
  168. {
  169. "href": "https://api.paypal.com/v1/billing/plans?product_id=PROD-XXCD1234QWER65782&page_size=2&page=6",
  170. "rel": "last",
  171. "method": "GET"
  172. }
  173. ]
  174. }', true);
  175. }
  176. /**
  177. * @return array
  178. */
  179. private function mockGetPlansResponse(): array
  180. {
  181. return Utils::jsonDecode('{
  182. "id": "P-5ML4271244454362WXNWU5NQ",
  183. "product_id": "PROD-XXCD1234QWER65782",
  184. "name": "Basic Plan",
  185. "description": "Basic Plan",
  186. "status": "ACTIVE",
  187. "billing_cycles": [
  188. {
  189. "frequency": {
  190. "interval_unit": "MONTH",
  191. "interval_count": 1
  192. },
  193. "tenure_type": "TRIAL",
  194. "sequence": 1,
  195. "total_cycles": 2,
  196. "pricing_scheme": {
  197. "fixed_price": {
  198. "currency_code": "USD",
  199. "value": "3"
  200. },
  201. "version": 1,
  202. "create_time": "2020-05-27T12:13:51Z",
  203. "update_time": "2020-05-27T12:13:51Z"
  204. }
  205. },
  206. {
  207. "frequency": {
  208. "interval_unit": "MONTH",
  209. "interval_count": 1
  210. },
  211. "tenure_type": "TRIAL",
  212. "sequence": 2,
  213. "total_cycles": 3,
  214. "pricing_scheme": {
  215. "fixed_price": {
  216. "currency_code": "USD",
  217. "value": "6"
  218. },
  219. "version": 1,
  220. "create_time": "2020-05-27T12:13:51Z",
  221. "update_time": "2020-05-27T12:13:51Z"
  222. }
  223. },
  224. {
  225. "frequency": {
  226. "interval_unit": "MONTH",
  227. "interval_count": 1
  228. },
  229. "tenure_type": "REGULAR",
  230. "sequence": 3,
  231. "total_cycles": 12,
  232. "pricing_scheme": {
  233. "fixed_price": {
  234. "value": "10",
  235. "currency_code": "USD"
  236. },
  237. "status": "ACTIVE",
  238. "version": 1,
  239. "create_time": "2020-05-27T12:13:51Z",
  240. "update_time": "2020-05-27T12:13:51Z"
  241. }
  242. }
  243. ],
  244. "taxes": {
  245. "percentage": "10",
  246. "inclusive": false
  247. },
  248. "create_time": "2020-05-27T12:13:51Z",
  249. "update_time": "2020-05-27T12:13:51Z",
  250. "links": [
  251. {
  252. "href": "https://api.paypal.com/v1/billing/plans/P-5ML4271244454362WXNWU5NQ",
  253. "rel": "self",
  254. "method": "GET"
  255. },
  256. {
  257. "href": "https://api.paypal.com/v1/billing/plans/P-5ML4271244454362WXNWU5NQ",
  258. "rel": "edit",
  259. "method": "PATCH"
  260. },
  261. {
  262. "href": "https://api.paypal.com/v1/billing/plans/P-5ML4271244454362WXNWU5NQ/deactivate",
  263. "rel": "deactivate",
  264. "method": "POST"
  265. },
  266. {
  267. "href": "https://api.paypal.com/v1/billing/plans/P-5ML4271244454362WXNWU5NQ/update-pricing-schemes",
  268. "rel": "edit",
  269. "method": "POST"
  270. }
  271. ]
  272. }', true);
  273. }
  274. /**
  275. * @return array
  276. */
  277. private function mockCreatePlansErrorResponse(): array
  278. {
  279. return Utils::jsonDecode('{
  280. "error": {
  281. "name" : "UNPROCESSABLE_ENTITY",
  282. "message" : "The requested action could not be performed, semantically incorrect, or failed business validation.",
  283. "debug_id" : "7a944631e76bf",
  284. "details" : [
  285. {
  286. "issue" : "CURRENCY_NOT_SUPPORTED_FOR_RECEIVER",
  287. "description" : "This currency cannot be accepted for this recipient\'s account."
  288. }
  289. ],
  290. "links" : [
  291. {
  292. "href" : "https://developer.paypal.com/docs/api/v1/billing/subscriptions#UNPROCESSABLE_ENTITY",
  293. "rel" : "information_link",
  294. "method" : "GET"
  295. }
  296. ]
  297. }
  298. }', true);
  299. }
  300. }