PaymentAuthorizations.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. namespace Srmklive\PayPal\Tests\Mocks\Responses;
  3. use GuzzleHttp\Utils;
  4. trait PaymentAuthorizations
  5. {
  6. /**
  7. * @return array
  8. */
  9. private function mockGetAuthorizedPaymentDetailsResponse(): array
  10. {
  11. return Utils::jsonDecode('{
  12. "id": "0VF52814937998046",
  13. "status": "AUTHORIZED",
  14. "amount": {
  15. "total": "10.99",
  16. "currency": "USD"
  17. },
  18. "invoice_id": "INVOICE-123",
  19. "seller_protection": {
  20. "status": "ELIGIBLE",
  21. "dispute_categories": [
  22. "ITEM_NOT_RECEIVED",
  23. "UNAUTHORIZED_TRANSACTION"
  24. ]
  25. },
  26. "expiration_time": "2017-10-10T23:23:45Z",
  27. "create_time": "2017-09-11T23:23:45Z",
  28. "update_time": "2017-09-11T23:23:45Z",
  29. "links": [
  30. {
  31. "rel": "self",
  32. "method": "GET",
  33. "href": "https://api.paypal.com/v2/payments/authorizations/0VF52814937998046"
  34. },
  35. {
  36. "rel": "capture",
  37. "method": "POST",
  38. "href": "https://api.paypal.com/v2/payments/authorizations/0VF52814937998046/capture"
  39. },
  40. {
  41. "rel": "void",
  42. "method": "POST",
  43. "href": "https://api.paypal.com/v2/payments/authorizations/0VF52814937998046/void"
  44. },
  45. {
  46. "rel": "reauthorize",
  47. "method": "POST",
  48. "href": "https://api.paypal.com/v2/payments/authorizations/0VF52814937998046/reauthorize"
  49. }
  50. ]
  51. }', true);
  52. }
  53. /**
  54. * @return array
  55. */
  56. private function mockCaptureAuthorizedPaymentResponse(): array
  57. {
  58. return Utils::jsonDecode('{
  59. "id": "2GG279541U471931P",
  60. "status": "COMPLETED",
  61. "links": [
  62. {
  63. "rel": "self",
  64. "method": "GET",
  65. "href": "https://api.paypal.com/v2/payments/captures/2GG279541U471931P"
  66. },
  67. {
  68. "rel": "refund",
  69. "method": "POST",
  70. "href": "https://api.paypal.com/v2/payments/captures/2GG279541U471931P/refund"
  71. },
  72. {
  73. "rel": "up",
  74. "method": "GET",
  75. "href": "https://api.paypal.com/v2/payments/authorizations/0VF52814937998046"
  76. }
  77. ]
  78. }', true);
  79. }
  80. /**
  81. * @return array
  82. */
  83. private function mockReAuthorizeAuthorizedPaymentResponse(): array
  84. {
  85. return Utils::jsonDecode('{
  86. "id": "8AA831015G517922L",
  87. "status": "CREATED",
  88. "links": [
  89. {
  90. "rel": "self",
  91. "method": "GET",
  92. "href": "https://api.paypal.com/v2/payments/authorizations/8AA831015G517922L"
  93. },
  94. {
  95. "rel": "capture",
  96. "method": "POST",
  97. "href": "https://api.paypal.com/v2/payments/authorizations/8AA831015G517922L/capture"
  98. },
  99. {
  100. "rel": "void",
  101. "method": "POST",
  102. "href": "https://api.paypal.com/v2/payments/authorizations/8AA831015G517922L/void"
  103. },
  104. {
  105. "rel": "reauthorize",
  106. "method": "POST",
  107. "href": "https://api.paypal.com/v2/payments/authorizations/8AA831015G517922L/reauthorize"
  108. }
  109. ]
  110. }', true);
  111. }
  112. }