WebHooks.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. namespace Srmklive\PayPal\Tests\Mocks\Requests;
  3. use GuzzleHttp\Utils;
  4. trait WebHooks
  5. {
  6. /**
  7. * @return array
  8. */
  9. private function mockCreateWebHookParams(): array
  10. {
  11. return Utils::jsonDecode('{
  12. "url": "https://example.com/example_webhook",
  13. "event_types": [
  14. {
  15. "name": "PAYMENT.AUTHORIZATION.CREATED"
  16. },
  17. {
  18. "name": "PAYMENT.AUTHORIZATION.VOIDED"
  19. }
  20. ]
  21. }', true);
  22. }
  23. /**
  24. * @return array
  25. */
  26. private function mockUpdateWebHookParams(): array
  27. {
  28. return Utils::jsonDecode('[
  29. {
  30. "op": "replace",
  31. "path": "/url",
  32. "value": "https://example.com/example_webhook_2"
  33. },
  34. {
  35. "op": "replace",
  36. "path": "/event_types",
  37. "value": [
  38. {
  39. "name": "PAYMENT.SALE.REFUNDED"
  40. }
  41. ]
  42. }
  43. ]', true);
  44. }
  45. /**
  46. * @return array
  47. */
  48. private function mockResendWebHookEventNotificationParams(): array
  49. {
  50. return Utils::jsonDecode('{
  51. "webhook_ids": [
  52. "12334456"
  53. ]
  54. }', true);
  55. }
  56. /**
  57. * @return array
  58. */
  59. private function mockVerifyWebHookSignatureParams(): array
  60. {
  61. return Utils::jsonDecode('{
  62. "transmission_id": "69cd13f0-d67a-11e5-baa3-778b53f4ae55",
  63. "transmission_time": "2016-02-18T20:01:35Z",
  64. "cert_url": "cert_url",
  65. "auth_algo": "SHA256withRSA",
  66. "transmission_sig": "lmI95Jx3Y9nhR5SJWlHVIWpg4AgFk7n9bCHSRxbrd8A9zrhdu2rMyFrmz+Zjh3s3boXB07VXCXUZy/UFzUlnGJn0wDugt7FlSvdKeIJenLRemUxYCPVoEZzg9VFNqOa48gMkvF+XTpxBeUx/kWy6B5cp7GkT2+pOowfRK7OaynuxUoKW3JcMWw272VKjLTtTAShncla7tGF+55rxyt2KNZIIqxNMJ48RDZheGU5w1npu9dZHnPgTXB9iomeVRoD8O/jhRpnKsGrDschyNdkeh81BJJMH4Ctc6lnCCquoP/GzCzz33MMsNdid7vL/NIWaCsekQpW26FpWPi/tfj8nLA==",
  67. "webhook_id": "1JE4291016473214C",
  68. "webhook_event": {
  69. "id": "8PT597110X687430LKGECATA",
  70. "create_time": "2013-06-25T21:41:28Z",
  71. "resource_type": "authorization",
  72. "event_type": "PAYMENT.AUTHORIZATION.CREATED",
  73. "summary": "A payment authorization was created",
  74. "resource": {
  75. "id": "2DC87612EK520411B",
  76. "create_time": "2013-06-25T21:39:15Z",
  77. "update_time": "2013-06-25T21:39:17Z",
  78. "state": "authorized",
  79. "amount": {
  80. "total": "7.47",
  81. "currency": "USD",
  82. "details": {
  83. "subtotal": "7.47"
  84. }
  85. },
  86. "parent_payment": "PAY-36246664YD343335CKHFA4AY",
  87. "valid_until": "2013-07-24T21:39:15Z",
  88. "links": [
  89. {
  90. "href": "https://api.paypal.com/v1/payments/authorization/2DC87612EK520411B",
  91. "rel": "self",
  92. "method": "GET"
  93. },
  94. {
  95. "href": "https://api.paypal.com/v1/payments/authorization/2DC87612EK520411B/capture",
  96. "rel": "capture",
  97. "method": "POST"
  98. },
  99. {
  100. "href": "https://api.paypal.com/v1/payments/authorization/2DC87612EK520411B/void",
  101. "rel": "void",
  102. "method": "POST"
  103. },
  104. {
  105. "href": "https://api.paypal.com/v1/payments/payment/PAY-36246664YD343335CKHFA4AY",
  106. "rel": "parent_payment",
  107. "method": "GET"
  108. }
  109. ]
  110. }
  111. }
  112. }', true);
  113. }
  114. }