Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
676 lars 1
<?php
2
 
3
namespace Srmklive\PayPal\Tests\Mocks\Responses;
4
 
5
use GuzzleHttp\Utils;
6
 
7
trait WebHooks
8
{
9
    /**
10
     * @return array
11
     */
12
    private function mockCreateWebHookResponse(): array
13
    {
14
        return Utils::jsonDecode('{
15
  "id": "0EH40505U7160970P",
16
  "url": "https://example.com/example_webhook",
17
  "event_types": [
18
    {
19
      "name": "PAYMENT.AUTHORIZATION.CREATED",
20
      "description": "A payment authorization was created."
21
    },
22
    {
23
      "name": "PAYMENT.AUTHORIZATION.VOIDED",
24
      "description": "A payment authorization was voided."
25
    }
26
  ],
27
  "links": [
28
    {
29
      "href": "https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P",
30
      "rel": "self",
31
      "method": "GET"
32
    },
33
    {
34
      "href": "https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P",
35
      "rel": "update",
36
      "method": "PATCH"
37
    },
38
    {
39
      "href": "https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P",
40
      "rel": "delete",
41
      "method": "DELETE"
42
    }
43
  ]
44
}', true);
45
    }
46
 
47
    /**
48
     * @return array
49
     */
50
    private function mockListWebHookResponse(): array
51
    {
52
        return Utils::jsonDecode('{
53
  "webhooks": [
54
    {
55
      "id": "40Y916089Y8324740",
56
      "url": "https://example.com/example_webhook",
57
      "event_types": [
58
        {
59
          "name": "PAYMENT.AUTHORIZATION.CREATED",
60
          "description": "A payment authorization was created."
61
        },
62
        {
63
          "name": "PAYMENT.AUTHORIZATION.VOIDED",
64
          "description": "A payment authorization was voided."
65
        }
66
      ],
67
      "links": [
68
        {
69
          "href": "https://api.paypal.com/v1/notifications/webhooks/40Y916089Y8324740",
70
          "rel": "self",
71
          "method": "GET"
72
        },
73
        {
74
          "href": "https://api.paypal.com/v1/notifications/webhooks/40Y916089Y8324740",
75
          "rel": "update",
76
          "method": "PATCH"
77
        },
78
        {
79
          "href": "https://api.paypal.com/v1/notifications/webhooks/40Y916089Y8324740",
80
          "rel": "delete",
81
          "method": "DELETE"
82
        }
83
      ]
84
    },
85
    {
86
      "id": "0EH40505U7160970P",
87
      "url": "https://example.com/another_example_webhook",
88
      "event_types": [
89
        {
90
          "name": "PAYMENT.AUTHORIZATION.CREATED",
91
          "description": "A payment authorization was created."
92
        },
93
        {
94
          "name": "PAYMENT.AUTHORIZATION.VOIDED",
95
          "description": "A payment authorization was voided."
96
        }
97
      ],
98
      "links": [
99
        {
100
          "href": "https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P",
101
          "rel": "self",
102
          "method": "GET"
103
        },
104
        {
105
          "href": "https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P",
106
          "rel": "update",
107
          "method": "PATCH"
108
        },
109
        {
110
          "href": "https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P",
111
          "rel": "delete",
112
          "method": "DELETE"
113
        }
114
      ]
115
    }
116
  ]
117
}', true);
118
    }
119
 
120
    /**
121
     * @return array
122
     */
123
    private function mockUpdateWebHookResponse(): array
124
    {
125
        return Utils::jsonDecode('{
126
  "id": "0EH40505U7160970P",
127
  "url": "https://example.com/example_webhook_2",
128
  "event_types": [
129
    {
130
      "name": "PAYMENT.SALE.REFUNDED",
131
      "description": "A sale payment was refunded."
132
    }
133
  ],
134
  "links": [
135
    {
136
      "href": "https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P",
137
      "rel": "self",
138
      "method": "GET"
139
    },
140
    {
141
      "href": "https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P",
142
      "rel": "update",
143
      "method": "PATCH"
144
    },
145
    {
146
      "href": "https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P",
147
      "rel": "delete",
148
      "method": "DELETE"
149
    }
150
  ]
151
}', true);
152
    }
153
 
154
    /**
155
     * @return array
156
     */
157
    private function mockGetWebHookResponse(): array
158
    {
159
        return Utils::jsonDecode('{
160
  "id": "0EH40505U7160970P",
161
  "url": "https://example.com/example_webhook",
162
  "event_types": [
163
    {
164
      "name": "PAYMENT.AUTHORIZATION.CREATED",
165
      "description": "A payment authorization was created.",
166
      "status": "ENABLED"
167
    },
168
    {
169
      "name": "PAYMENT.AUTHORIZATION.VOIDED",
170
      "description": "A payment authorization was voided.",
171
      "status": "ENABLED"
172
    }
173
  ],
174
  "links": [
175
    {
176
      "href": "https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P",
177
      "rel": "self",
178
      "method": "GET"
179
    },
180
    {
181
      "href": "https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P",
182
      "rel": "update",
183
      "method": "PATCH"
184
    },
185
    {
186
      "href": "https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P",
187
      "rel": "delete",
188
      "method": "DELETE"
189
    }
190
  ]
191
}', true);
192
    }
193
 
194
    /**
195
     * @return array
196
     */
197
    private function mockListWebHookEventsResponse(): array
198
    {
199
        return Utils::jsonDecode('{
200
  "event_types": [
201
    {
202
      "name": "PAYMENT.AUTHORIZATION.CREATED",
203
      "description": "A payment authorization was created.",
204
      "status": "ENABLED"
205
    },
206
    {
207
      "name": "PAYMENT.AUTHORIZATION.VOIDED",
208
      "description": "A payment authorization was voided.",
209
      "status": "ENABLED"
210
    },
211
    {
212
      "name": "RISK.DISPUTE.CREATED",
213
      "description": "A dispute was filed against a transaction.",
214
      "status": "DEPRECATED"
215
    }
216
  ]
217
}', true);
218
    }
219
 
220
    /**
221
     * @return array
222
     */
223
    private function mockListWebHookEventsTypesResponse(): array
224
    {
225
        return Utils::jsonDecode('{
226
  "event_types": [
227
    {
228
      "name": "PAYMENT.AUTHORIZATION.CREATED",
229
      "description": "A payment authorization was created.",
230
      "status": "ENABLED",
231
      "service": "amqpaymentwebhookd",
232
      "owner": "Webhooks",
233
      "contact": "livesupport@example.com"
234
    },
235
    {
236
      "name": "PAYMENT.AUTHORIZATION.VOIDED",
237
      "description": "A payment authorization was voided.",
238
      "status": "ENABLED",
239
      "service": "amqpaymentwebhookd",
240
      "owner": "Webhooks",
241
      "contact": "livesupport@example.com"
242
    },
243
    {
244
      "name": "PAYMENT.CAPTURE.COMPLETED",
245
      "description": "A capture payment was completed.",
246
      "status": "ENABLED",
247
      "service": "amqpaymentwebhookd",
248
      "owner": "Webhooks",
249
      "contact": "livesupport@example.com"
250
    }
251
  ]
252
}', true);
253
    }
254
 
255
    /**
256
     * @return array
257
     */
258
    private function mockWebHookEventsListResponse(): array
259
    {
260
        return Utils::jsonDecode('{
261
  "events": [
262
    {
263
      "id": "8PT597110X687430LKGECATA",
264
      "create_time": "2013-06-25T21:41:28Z",
265
      "resource_type": "authorization",
266
      "event_version": "1.0",
267
      "event_type": "PAYMENT.AUTHORIZATION.CREATED",
268
      "summary": "A payment authorization was created",
269
      "resource_version": "1.0",
270
      "resource": {
271
        "id": "2DC87612EK520411B",
272
        "create_time": "2013-06-25T21:39:15Z",
273
        "update_time": "2013-06-25T21:39:17Z",
274
        "state": "authorized",
275
        "amount": {
276
          "total": "7.47",
277
          "currency": "USD",
278
          "details": {
279
            "subtotal": "7.47"
280
          }
281
        },
282
        "parent_payment": "PAY-36246664YD343335CKHFA4AY",
283
        "valid_until": "2013-07-24T21:39:15Z",
284
        "links": [
285
          {
286
            "href": "https://api.paypal.com/v1/payments/authorization/2DC87612EK520411B",
287
            "rel": "self",
288
            "method": "GET"
289
          },
290
          {
291
            "href": "https://api.paypal.com/v1/payments/authorization/2DC87612EK520411B/capture",
292
            "rel": "capture",
293
            "method": "POST"
294
          },
295
          {
296
            "href": "https://api.paypal.com/v1/payments/authorization/2DC87612EK520411B/void",
297
            "rel": "void",
298
            "method": "POST"
299
          },
300
          {
301
            "href": "https://api.paypal.com/v1/payments/payment/PAY-36246664YD343335CKHFA4AY",
302
            "rel": "parent_payment",
303
            "method": "GET"
304
          }
305
        ]
306
      },
307
      "links": [
308
        {
309
          "href": "https://api.paypal.com/v1/notfications/webhooks-events/8PT597110X687430LKGECATA",
310
          "rel": "self",
311
          "method": "GET"
312
        },
313
        {
314
          "href": "https://api.paypal.com/v1/notfications/webhooks-events/8PT597110X687430LKGECATA/resend",
315
          "rel": "resend",
316
          "method": "POST"
317
        }
318
      ]
319
    },
320
    {
321
      "id": "HTSPGS710X687430LKGECATA",
322
      "create_time": "2013-06-25T21:41:28Z",
323
      "resource_type": "authorization",
324
      "event_version": "1.0",
325
      "event_type": "PAYMENT.AUTHORIZATION.CREATED",
326
      "summary": "A payment authorization was created",
327
      "resource_version": "1.0",
328
      "resource": {
329
        "id": "HATH7S72EK520411B",
330
        "create_time": "2013-06-25T21:39:15Z",
331
        "update_time": "2013-06-25T21:39:17Z",
332
        "state": "authorized",
333
        "amount": {
334
          "total": "7.47",
335
          "currency": "USD",
336
          "details": {
337
            "subtotal": "7.47"
338
          }
339
        },
340
        "parent_payment": "PAY-ALDSFJ64YD343335CKHFA4AY",
341
        "valid_until": "2013-07-24T21:39:15Z",
342
        "links": [
343
          {
344
            "href": "https://api.paypal.com/v1/payments/authorization/HATH7S72EK520411B",
345
            "rel": "self",
346
            "method": "GET"
347
          },
348
          {
349
            "href": "https://api.paypal.com/v1/payments/authorization/HATH7S72EK520411B/capture",
350
            "rel": "capture",
351
            "method": "POST"
352
          },
353
          {
354
            "href": "https://api.paypal.com/v1/payments/authorization/HATH7S72EK520411B/void",
355
            "rel": "void",
356
            "method": "POST"
357
          },
358
          {
359
            "href": "https://api.paypal.com/v1/payments/payment/PAY-HATH7S72EK520411B",
360
            "rel": "parent_payment",
361
            "method": "GET"
362
          }
363
        ]
364
      },
365
      "links": [
366
        {
367
          "href": "https://api.paypal.com/v1/notfications/webhooks-events/HTSPGS710X687430LKGECATA",
368
          "rel": "self",
369
          "method": "GET"
370
        },
371
        {
372
          "href": "https://api.paypal.com/v1/notfications/webhooks-events/HTSPGS710X687430LKGECATA/resend",
373
          "rel": "resend",
374
          "method": "POST"
375
        }
376
      ]
377
    }
378
  ],
379
  "count": 2,
380
  "links": [
381
    {
382
      "href": "https://api.paypal.com/v1/notifications/webhooks-events/?start_time=2014-08-04T12:46:47-07:00&amp;end_time=2014-09-18T12:46:47-07:00&amp;page_size=2&amp;move_to=next&amp;index_time=2014-09-17T23:07:35Z&amp;index_id=3",
383
      "rel": "next",
384
      "method": "GET"
385
    },
386
    {
387
      "href": "https://api.paypal.com/v1/notifications/webhooks-events/?start_time=2014-08-04T12:46:47-07:00&amp;end_time=2014-09-18T12:46:47-07:00&amp;page_size=2&amp;move_to=previous&amp;index_time=2014-09-17T23:07:35Z&amp;index_id=0",
388
      "rel": "previous",
389
      "method": "GET"
390
    }
391
  ]
392
}', true);
393
    }
394
 
395
    /**
396
     * @return array
397
     */
398
    private function mockGetWebHookEventResponse(): array
399
    {
400
        return Utils::jsonDecode('{
401
  "id": "8PT597110X687430LKGECATA",
402
  "create_time": "2013-06-25T21:41:28Z",
403
  "resource_type": "authorization",
404
  "event_version": "1.0",
405
  "event_type": "PAYMENT.AUTHORIZATION.CREATED",
406
  "summary": "A payment authorization was created",
407
  "resource_version": "1.0",
408
  "resource": {
409
    "id": "2DC87612EK520411B",
410
    "create_time": "2013-06-25T21:39:15Z",
411
    "update_time": "2013-06-25T21:39:17Z",
412
    "state": "authorized",
413
    "amount": {
414
      "total": "7.47",
415
      "currency": "USD",
416
      "details": {
417
        "subtotal": "7.47"
418
      }
419
    },
420
    "parent_payment": "PAY-36246664YD343335CKHFA4AY",
421
    "valid_until": "2013-07-24T21:39:15Z",
422
    "links": [
423
      {
424
        "href": "https://api.paypal.com/v1/payments/authorization/2DC87612EK520411B",
425
        "rel": "self",
426
        "method": "GET"
427
      },
428
      {
429
        "href": "https://api.paypal.com/v1/payments/authorization/2DC87612EK520411B/capture",
430
        "rel": "capture",
431
        "method": "POST"
432
      },
433
      {
434
        "href": "https://api.paypal.com/v1/payments/authorization/2DC87612EK520411B/void",
435
        "rel": "void",
436
        "method": "POST"
437
      },
438
      {
439
        "href": "https://api.paypal.com/v1/payments/payment/PAY-36246664YD343335CKHFA4AY",
440
        "rel": "parent_payment",
441
        "method": "GET"
442
      }
443
    ]
444
  },
445
  "links": [
446
    {
447
      "href": "https://api.paypal.com/v1/notfications/webhooks-events/8PT597110X687430LKGECATA",
448
      "rel": "self",
449
      "method": "GET"
450
    },
451
    {
452
      "href": "https://api.paypal.com/v1/notfications/webhooks-events/8PT597110X687430LKGECATA/resend",
453
      "rel": "resend",
454
      "method": "POST"
455
    }
456
  ]
457
}', true);
458
    }
459
 
460
    /**
461
     * @return array
462
     */
463
    private function mockResendWebHookEventNotificationResponse(): array
464
    {
465
        return Utils::jsonDecode('{
466
  "id": "8PT597110X687430LKGECATA",
467
  "create_time": "2013-06-25T21:41:28Z",
468
  "resource_type": "authorization",
469
  "event_version": "1.0",
470
  "event_type": "PAYMENT.AUTHORIZATION.CREATED",
471
  "summary": "A payment authorization was created",
472
  "resource_version": "1.0",
473
  "resource": {
474
    "id": "2DC87612EK520411B",
475
    "create_time": "2013-06-25T21:39:15Z",
476
    "update_time": "2013-06-25T21:39:17Z",
477
    "state": "authorized",
478
    "amount": {
479
      "total": "7.47",
480
      "currency": "USD",
481
      "details": {
482
        "subtotal": "7.47"
483
      }
484
    },
485
    "parent_payment": "PAY-36246664YD343335CKHFA4AY",
486
    "valid_until": "2013-07-24T21:39:15Z",
487
    "links": [
488
      {
489
        "href": "https://api.paypal.com/v1/payments/authorization/2DC87612EK520411B",
490
        "rel": "self",
491
        "method": "GET"
492
      },
493
      {
494
        "href": "https://api.paypal.com/v1/payments/authorization/2DC87612EK520411B/capture",
495
        "rel": "capture",
496
        "method": "POST"
497
      },
498
      {
499
        "href": "https://api.paypal.com/v1/payments/authorization/2DC87612EK520411B/void",
500
        "rel": "void",
501
        "method": "POST"
502
      },
503
      {
504
        "href": "https://api.paypal.com/v1/payments/payment/PAY-36246664YD343335CKHFA4AY",
505
        "rel": "parent_payment",
506
        "method": "GET"
507
      }
508
    ]
509
  },
510
  "links": [
511
    {
512
      "href": "https://api.paypal.com/v1/notfications/webhooks-events/8PT597110X687430LKGECATA",
513
      "rel": "self",
514
      "method": "GET"
515
    },
516
    {
517
      "href": "https://api.paypal.com/v1/notfications/webhooks-events/8PT597110X687430LKGECATA/resend",
518
      "rel": "resend",
519
      "method": "POST"
520
    }
521
  ]
522
}', true);
523
    }
524
 
525
    /**
526
     * @return array
527
     */
528
    private function mockVerifyWebHookSignatureResponse(): array
529
    {
530
        return Utils::jsonDecode('{
531
  "verification_status": "SUCCESS"
532
}', true);
533
    }
534
}