| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534 |
- <?php
- namespace Srmklive\PayPal\Tests\Mocks\Responses;
- use GuzzleHttp\Utils;
- trait WebHooks
- {
- /**
- * @return array
- */
- private function mockCreateWebHookResponse(): array
- {
- return Utils::jsonDecode('{
- "id": "0EH40505U7160970P",
- "url": "https://example.com/example_webhook",
- "event_types": [
- {
- "name": "PAYMENT.AUTHORIZATION.CREATED",
- "description": "A payment authorization was created."
- },
- {
- "name": "PAYMENT.AUTHORIZATION.VOIDED",
- "description": "A payment authorization was voided."
- }
- ],
- "links": [
- {
- "href": "https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P",
- "rel": "self",
- "method": "GET"
- },
- {
- "href": "https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P",
- "rel": "update",
- "method": "PATCH"
- },
- {
- "href": "https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P",
- "rel": "delete",
- "method": "DELETE"
- }
- ]
- }', true);
- }
- /**
- * @return array
- */
- private function mockListWebHookResponse(): array
- {
- return Utils::jsonDecode('{
- "webhooks": [
- {
- "id": "40Y916089Y8324740",
- "url": "https://example.com/example_webhook",
- "event_types": [
- {
- "name": "PAYMENT.AUTHORIZATION.CREATED",
- "description": "A payment authorization was created."
- },
- {
- "name": "PAYMENT.AUTHORIZATION.VOIDED",
- "description": "A payment authorization was voided."
- }
- ],
- "links": [
- {
- "href": "https://api.paypal.com/v1/notifications/webhooks/40Y916089Y8324740",
- "rel": "self",
- "method": "GET"
- },
- {
- "href": "https://api.paypal.com/v1/notifications/webhooks/40Y916089Y8324740",
- "rel": "update",
- "method": "PATCH"
- },
- {
- "href": "https://api.paypal.com/v1/notifications/webhooks/40Y916089Y8324740",
- "rel": "delete",
- "method": "DELETE"
- }
- ]
- },
- {
- "id": "0EH40505U7160970P",
- "url": "https://example.com/another_example_webhook",
- "event_types": [
- {
- "name": "PAYMENT.AUTHORIZATION.CREATED",
- "description": "A payment authorization was created."
- },
- {
- "name": "PAYMENT.AUTHORIZATION.VOIDED",
- "description": "A payment authorization was voided."
- }
- ],
- "links": [
- {
- "href": "https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P",
- "rel": "self",
- "method": "GET"
- },
- {
- "href": "https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P",
- "rel": "update",
- "method": "PATCH"
- },
- {
- "href": "https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P",
- "rel": "delete",
- "method": "DELETE"
- }
- ]
- }
- ]
- }', true);
- }
- /**
- * @return array
- */
- private function mockUpdateWebHookResponse(): array
- {
- return Utils::jsonDecode('{
- "id": "0EH40505U7160970P",
- "url": "https://example.com/example_webhook_2",
- "event_types": [
- {
- "name": "PAYMENT.SALE.REFUNDED",
- "description": "A sale payment was refunded."
- }
- ],
- "links": [
- {
- "href": "https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P",
- "rel": "self",
- "method": "GET"
- },
- {
- "href": "https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P",
- "rel": "update",
- "method": "PATCH"
- },
- {
- "href": "https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P",
- "rel": "delete",
- "method": "DELETE"
- }
- ]
- }', true);
- }
- /**
- * @return array
- */
- private function mockGetWebHookResponse(): array
- {
- return Utils::jsonDecode('{
- "id": "0EH40505U7160970P",
- "url": "https://example.com/example_webhook",
- "event_types": [
- {
- "name": "PAYMENT.AUTHORIZATION.CREATED",
- "description": "A payment authorization was created.",
- "status": "ENABLED"
- },
- {
- "name": "PAYMENT.AUTHORIZATION.VOIDED",
- "description": "A payment authorization was voided.",
- "status": "ENABLED"
- }
- ],
- "links": [
- {
- "href": "https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P",
- "rel": "self",
- "method": "GET"
- },
- {
- "href": "https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P",
- "rel": "update",
- "method": "PATCH"
- },
- {
- "href": "https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P",
- "rel": "delete",
- "method": "DELETE"
- }
- ]
- }', true);
- }
- /**
- * @return array
- */
- private function mockListWebHookEventsResponse(): array
- {
- return Utils::jsonDecode('{
- "event_types": [
- {
- "name": "PAYMENT.AUTHORIZATION.CREATED",
- "description": "A payment authorization was created.",
- "status": "ENABLED"
- },
- {
- "name": "PAYMENT.AUTHORIZATION.VOIDED",
- "description": "A payment authorization was voided.",
- "status": "ENABLED"
- },
- {
- "name": "RISK.DISPUTE.CREATED",
- "description": "A dispute was filed against a transaction.",
- "status": "DEPRECATED"
- }
- ]
- }', true);
- }
- /**
- * @return array
- */
- private function mockListWebHookEventsTypesResponse(): array
- {
- return Utils::jsonDecode('{
- "event_types": [
- {
- "name": "PAYMENT.AUTHORIZATION.CREATED",
- "description": "A payment authorization was created.",
- "status": "ENABLED",
- "service": "amqpaymentwebhookd",
- "owner": "Webhooks",
- "contact": "livesupport@example.com"
- },
- {
- "name": "PAYMENT.AUTHORIZATION.VOIDED",
- "description": "A payment authorization was voided.",
- "status": "ENABLED",
- "service": "amqpaymentwebhookd",
- "owner": "Webhooks",
- "contact": "livesupport@example.com"
- },
- {
- "name": "PAYMENT.CAPTURE.COMPLETED",
- "description": "A capture payment was completed.",
- "status": "ENABLED",
- "service": "amqpaymentwebhookd",
- "owner": "Webhooks",
- "contact": "livesupport@example.com"
- }
- ]
- }', true);
- }
- /**
- * @return array
- */
- private function mockWebHookEventsListResponse(): array
- {
- return Utils::jsonDecode('{
- "events": [
- {
- "id": "8PT597110X687430LKGECATA",
- "create_time": "2013-06-25T21:41:28Z",
- "resource_type": "authorization",
- "event_version": "1.0",
- "event_type": "PAYMENT.AUTHORIZATION.CREATED",
- "summary": "A payment authorization was created",
- "resource_version": "1.0",
- "resource": {
- "id": "2DC87612EK520411B",
- "create_time": "2013-06-25T21:39:15Z",
- "update_time": "2013-06-25T21:39:17Z",
- "state": "authorized",
- "amount": {
- "total": "7.47",
- "currency": "USD",
- "details": {
- "subtotal": "7.47"
- }
- },
- "parent_payment": "PAY-36246664YD343335CKHFA4AY",
- "valid_until": "2013-07-24T21:39:15Z",
- "links": [
- {
- "href": "https://api.paypal.com/v1/payments/authorization/2DC87612EK520411B",
- "rel": "self",
- "method": "GET"
- },
- {
- "href": "https://api.paypal.com/v1/payments/authorization/2DC87612EK520411B/capture",
- "rel": "capture",
- "method": "POST"
- },
- {
- "href": "https://api.paypal.com/v1/payments/authorization/2DC87612EK520411B/void",
- "rel": "void",
- "method": "POST"
- },
- {
- "href": "https://api.paypal.com/v1/payments/payment/PAY-36246664YD343335CKHFA4AY",
- "rel": "parent_payment",
- "method": "GET"
- }
- ]
- },
- "links": [
- {
- "href": "https://api.paypal.com/v1/notfications/webhooks-events/8PT597110X687430LKGECATA",
- "rel": "self",
- "method": "GET"
- },
- {
- "href": "https://api.paypal.com/v1/notfications/webhooks-events/8PT597110X687430LKGECATA/resend",
- "rel": "resend",
- "method": "POST"
- }
- ]
- },
- {
- "id": "HTSPGS710X687430LKGECATA",
- "create_time": "2013-06-25T21:41:28Z",
- "resource_type": "authorization",
- "event_version": "1.0",
- "event_type": "PAYMENT.AUTHORIZATION.CREATED",
- "summary": "A payment authorization was created",
- "resource_version": "1.0",
- "resource": {
- "id": "HATH7S72EK520411B",
- "create_time": "2013-06-25T21:39:15Z",
- "update_time": "2013-06-25T21:39:17Z",
- "state": "authorized",
- "amount": {
- "total": "7.47",
- "currency": "USD",
- "details": {
- "subtotal": "7.47"
- }
- },
- "parent_payment": "PAY-ALDSFJ64YD343335CKHFA4AY",
- "valid_until": "2013-07-24T21:39:15Z",
- "links": [
- {
- "href": "https://api.paypal.com/v1/payments/authorization/HATH7S72EK520411B",
- "rel": "self",
- "method": "GET"
- },
- {
- "href": "https://api.paypal.com/v1/payments/authorization/HATH7S72EK520411B/capture",
- "rel": "capture",
- "method": "POST"
- },
- {
- "href": "https://api.paypal.com/v1/payments/authorization/HATH7S72EK520411B/void",
- "rel": "void",
- "method": "POST"
- },
- {
- "href": "https://api.paypal.com/v1/payments/payment/PAY-HATH7S72EK520411B",
- "rel": "parent_payment",
- "method": "GET"
- }
- ]
- },
- "links": [
- {
- "href": "https://api.paypal.com/v1/notfications/webhooks-events/HTSPGS710X687430LKGECATA",
- "rel": "self",
- "method": "GET"
- },
- {
- "href": "https://api.paypal.com/v1/notfications/webhooks-events/HTSPGS710X687430LKGECATA/resend",
- "rel": "resend",
- "method": "POST"
- }
- ]
- }
- ],
- "count": 2,
- "links": [
- {
- "href": "https://api.paypal.com/v1/notifications/webhooks-events/?start_time=2014-08-04T12:46:47-07:00&end_time=2014-09-18T12:46:47-07:00&page_size=2&move_to=next&index_time=2014-09-17T23:07:35Z&index_id=3",
- "rel": "next",
- "method": "GET"
- },
- {
- "href": "https://api.paypal.com/v1/notifications/webhooks-events/?start_time=2014-08-04T12:46:47-07:00&end_time=2014-09-18T12:46:47-07:00&page_size=2&move_to=previous&index_time=2014-09-17T23:07:35Z&index_id=0",
- "rel": "previous",
- "method": "GET"
- }
- ]
- }', true);
- }
- /**
- * @return array
- */
- private function mockGetWebHookEventResponse(): array
- {
- return Utils::jsonDecode('{
- "id": "8PT597110X687430LKGECATA",
- "create_time": "2013-06-25T21:41:28Z",
- "resource_type": "authorization",
- "event_version": "1.0",
- "event_type": "PAYMENT.AUTHORIZATION.CREATED",
- "summary": "A payment authorization was created",
- "resource_version": "1.0",
- "resource": {
- "id": "2DC87612EK520411B",
- "create_time": "2013-06-25T21:39:15Z",
- "update_time": "2013-06-25T21:39:17Z",
- "state": "authorized",
- "amount": {
- "total": "7.47",
- "currency": "USD",
- "details": {
- "subtotal": "7.47"
- }
- },
- "parent_payment": "PAY-36246664YD343335CKHFA4AY",
- "valid_until": "2013-07-24T21:39:15Z",
- "links": [
- {
- "href": "https://api.paypal.com/v1/payments/authorization/2DC87612EK520411B",
- "rel": "self",
- "method": "GET"
- },
- {
- "href": "https://api.paypal.com/v1/payments/authorization/2DC87612EK520411B/capture",
- "rel": "capture",
- "method": "POST"
- },
- {
- "href": "https://api.paypal.com/v1/payments/authorization/2DC87612EK520411B/void",
- "rel": "void",
- "method": "POST"
- },
- {
- "href": "https://api.paypal.com/v1/payments/payment/PAY-36246664YD343335CKHFA4AY",
- "rel": "parent_payment",
- "method": "GET"
- }
- ]
- },
- "links": [
- {
- "href": "https://api.paypal.com/v1/notfications/webhooks-events/8PT597110X687430LKGECATA",
- "rel": "self",
- "method": "GET"
- },
- {
- "href": "https://api.paypal.com/v1/notfications/webhooks-events/8PT597110X687430LKGECATA/resend",
- "rel": "resend",
- "method": "POST"
- }
- ]
- }', true);
- }
- /**
- * @return array
- */
- private function mockResendWebHookEventNotificationResponse(): array
- {
- return Utils::jsonDecode('{
- "id": "8PT597110X687430LKGECATA",
- "create_time": "2013-06-25T21:41:28Z",
- "resource_type": "authorization",
- "event_version": "1.0",
- "event_type": "PAYMENT.AUTHORIZATION.CREATED",
- "summary": "A payment authorization was created",
- "resource_version": "1.0",
- "resource": {
- "id": "2DC87612EK520411B",
- "create_time": "2013-06-25T21:39:15Z",
- "update_time": "2013-06-25T21:39:17Z",
- "state": "authorized",
- "amount": {
- "total": "7.47",
- "currency": "USD",
- "details": {
- "subtotal": "7.47"
- }
- },
- "parent_payment": "PAY-36246664YD343335CKHFA4AY",
- "valid_until": "2013-07-24T21:39:15Z",
- "links": [
- {
- "href": "https://api.paypal.com/v1/payments/authorization/2DC87612EK520411B",
- "rel": "self",
- "method": "GET"
- },
- {
- "href": "https://api.paypal.com/v1/payments/authorization/2DC87612EK520411B/capture",
- "rel": "capture",
- "method": "POST"
- },
- {
- "href": "https://api.paypal.com/v1/payments/authorization/2DC87612EK520411B/void",
- "rel": "void",
- "method": "POST"
- },
- {
- "href": "https://api.paypal.com/v1/payments/payment/PAY-36246664YD343335CKHFA4AY",
- "rel": "parent_payment",
- "method": "GET"
- }
- ]
- },
- "links": [
- {
- "href": "https://api.paypal.com/v1/notfications/webhooks-events/8PT597110X687430LKGECATA",
- "rel": "self",
- "method": "GET"
- },
- {
- "href": "https://api.paypal.com/v1/notfications/webhooks-events/8PT597110X687430LKGECATA/resend",
- "rel": "resend",
- "method": "POST"
- }
- ]
- }', true);
- }
- /**
- * @return array
- */
- private function mockVerifyWebHookSignatureResponse(): array
- {
- return Utils::jsonDecode('{
- "verification_status": "SUCCESS"
- }', true);
- }
- }
|