Subscriptions.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <?php
  2. namespace Srmklive\PayPal\Tests\Mocks\Requests;
  3. use GuzzleHttp\Utils;
  4. trait Subscriptions
  5. {
  6. /**
  7. * @return array
  8. */
  9. private function mockCreateSubscriptionParams(): array
  10. {
  11. return Utils::jsonDecode('{
  12. "plan_id": "P-5ML4271244454362WXNWU5NQ",
  13. "start_time": "2018-11-01T00:00:00Z",
  14. "quantity": "20",
  15. "shipping_amount": {
  16. "currency_code": "USD",
  17. "value": "10.00"
  18. },
  19. "subscriber": {
  20. "name": {
  21. "given_name": "John",
  22. "surname": "Doe"
  23. },
  24. "email_address": "customer@example.com",
  25. "shipping_address": {
  26. "name": {
  27. "full_name": "John Doe"
  28. },
  29. "address": {
  30. "address_line_1": "2211 N First Street",
  31. "address_line_2": "Building 17",
  32. "admin_area_2": "San Jose",
  33. "admin_area_1": "CA",
  34. "postal_code": "95131",
  35. "country_code": "US"
  36. }
  37. }
  38. },
  39. "application_context": {
  40. "brand_name": "walmart",
  41. "locale": "en-US",
  42. "shipping_preference": "SET_PROVIDED_ADDRESS",
  43. "user_action": "SUBSCRIBE_NOW",
  44. "payment_method": {
  45. "payer_selected": "PAYPAL",
  46. "payee_preferred": "IMMEDIATE_PAYMENT_REQUIRED"
  47. },
  48. "return_url": "https://example.com/returnUrl",
  49. "cancel_url": "https://example.com/cancelUrl"
  50. }
  51. }', true);
  52. }
  53. /**
  54. * @return array
  55. */
  56. private function mockUpdateSubscriptionParams(): array
  57. {
  58. return Utils::jsonDecode('[
  59. {
  60. "op": "replace",
  61. "path": "/billing_info/outstanding_balance",
  62. "value": {
  63. "currency_code": "USD",
  64. "value": "50.00"
  65. }
  66. }
  67. ]', true);
  68. }
  69. /**
  70. * @return array
  71. */
  72. private function mockActivateSubscriptionParams()
  73. {
  74. return Utils::jsonDecode('{
  75. "reason": "Reactivating the subscription"
  76. }', true);
  77. }
  78. /**
  79. * @return array
  80. */
  81. private function mockCancelSubscriptionParams()
  82. {
  83. return Utils::jsonDecode('{
  84. "reason": "Not satisfied with the service"
  85. }', true);
  86. }
  87. /**
  88. * @return array
  89. */
  90. private function mockSuspendSubscriptionParams()
  91. {
  92. return Utils::jsonDecode('{
  93. "reason": "Item out of stock"
  94. }', true);
  95. }
  96. /**
  97. * @return array
  98. */
  99. private function mockCaptureSubscriptionPaymentParams()
  100. {
  101. return Utils::jsonDecode('{
  102. "note": "Charging as the balance reached the limit",
  103. "capture_type": "OUTSTANDING_BALANCE",
  104. "amount": {
  105. "currency_code": "USD",
  106. "value": "100"
  107. }
  108. }', true);
  109. }
  110. /**
  111. * @return array
  112. */
  113. private function mockUpdateSubscriptionItemsParams()
  114. {
  115. return Utils::jsonDecode('{
  116. "plan_id": "P-5ML4271244454362WXNWU5NQ",
  117. "shipping_amount": {
  118. "currency_code": "USD",
  119. "value": "10.00"
  120. },
  121. "shipping_address": {
  122. "name": {
  123. "full_name": "John Doe"
  124. },
  125. "address": {
  126. "address_line_1": "2211 N First Street",
  127. "address_line_2": "Building 17",
  128. "admin_area_2": "San Jose",
  129. "admin_area_1": "CA",
  130. "postal_code": "95131",
  131. "country_code": "US"
  132. }
  133. },
  134. "application_context": {
  135. "brand_name": "walmart",
  136. "locale": "en-US",
  137. "shipping_preference": "SET_PROVIDED_ADDRESS",
  138. "payment_method": {
  139. "payer_selected": "PAYPAL",
  140. "payee_preferred": "IMMEDIATE_PAYMENT_REQUIRED"
  141. },
  142. "return_url": "https://example.com/returnUrl",
  143. "cancel_url": "https://example.com/cancelUrl"
  144. }
  145. }', true);
  146. }
  147. }