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 Orders
8
{
9
    /**
10
     * @return array
11
     */
12
    public function mockCreateOrdersResponse(): array
13
    {
14
        return Utils::jsonDecode('{
15
        "id": "5O190127TN364715T",
16
        "status": "CREATED",
17
        "links": [
18
          {
19
            "href": "https://api-m.paypal.com/v2/checkout/orders/5O190127TN364715T",
20
            "rel": "self",
21
            "method": "GET"
22
          },
23
          {
24
            "href": "https://www.paypal.com/checkoutnow?token=5O190127TN364715T",
25
            "rel": "approve",
26
            "method": "GET"
27
          },
28
          {
29
            "href": "https://api-m.paypal.com/v2/checkout/orders/5O190127TN364715T",
30
            "rel": "update",
31
            "method": "PATCH"
32
          },
33
          {
34
            "href": "https://api-m.paypal.com/v2/checkout/orders/5O190127TN364715T/capture",
35
            "rel": "capture",
36
            "method": "POST"
37
          }
38
        ]
39
      }', true);
40
    }
41
 
42
    /**
43
     * @return empty
44
     */
45
    public function mockUpdateOrdersResponse()
46
    {
47
        return '';
48
    }
49
 
50
    /**
51
     * @return array
52
     */
53
    public function mockOrderDetailsResponse(): array
54
    {
55
        return Utils::jsonDecode('{
56
        "id": "5O190127TN364715T",
57
        "status": "PAYER_ACTION_REQUIRED",
58
        "intent": "CAPTURE",
59
        "payment_source": {
60
          "alipay": {
61
            "name": "John Doe",
62
            "country_code": "C2"
63
          }
64
        },
65
        "purchase_units": [
66
          {
67
            "reference_id": "d9f80740-38f0-11e8-b467-0ed5f89f718b",
68
            "amount": {
69
              "currency_code": "USD",
70
              "value": "100.00"
71
            },
72
            "payee": {
73
              "email_address": "payee@example.com"
74
            }
75
          }
76
        ],
77
        "create_time": "2018-04-01T21:18:49Z",
78
        "links": [
79
          {
80
            "href": "https://www.paypal.com/payment/alipay?token=5O190127TN364715T",
81
            "rel": "payer-action",
82
            "method": "GET"
83
          },
84
          {
85
            "href": "https://api-m.paypal.com/v2/checkout/orders/5O190127TN364715T",
86
            "rel": "self",
87
            "method": "GET"
88
          }
89
        ]
90
      }', true);
91
    }
92
 
93
    /**
94
     * @return array
95
     */
96
    public function mockOrderPaymentAuthorizedResponse(): array
97
    {
98
        return Utils::jsonDecode('{
99
        "id": "5O190127TN364715T",
100
        "status": "COMPLETED",
101
        "payer": {
102
          "name": {
103
            "given_name": "John",
104
            "surname": "Doe"
105
          },
106
          "email_address": "customer@example.com",
107
          "payer_id": "QYR5Z8XDVJNXQ"
108
        },
109
        "purchase_units": [
110
          {
111
            "reference_id": "d9f80740-38f0-11e8-b467-0ed5f89f718b",
112
            "shipping": {
113
              "address": {
114
                "address_line_1": "2211 N First Street",
115
                "address_line_2": "Building 17",
116
                "admin_area_2": "San Jose",
117
                "admin_area_1": "CA",
118
                "postal_code": "95131",
119
                "country_code": "US"
120
              }
121
            },
122
            "payments": {
123
              "authorizations": [
124
                {
125
                  "id": "0AW2184448108334S",
126
                  "status": "CREATED",
127
                  "amount": {
128
                    "currency_code": "USD",
129
                    "value": "100.00"
130
                  },
131
                  "seller_protection": {
132
                    "status": "ELIGIBLE",
133
                    "dispute_categories": [
134
                      "ITEM_NOT_RECEIVED",
135
                      "UNAUTHORIZED_TRANSACTION"
136
                    ]
137
                  },
138
                  "expiration_time": "2018-05-01T21:20:49Z",
139
                  "create_time": "2018-04-01T21:20:49Z",
140
                  "update_time": "2018-04-01T21:20:49Z",
141
                  "links": [
142
                    {
143
                      "href": "https://api-m.paypal.com/v2/payments/authorizations/0AW2184448108334S",
144
                      "rel": "self",
145
                      "method": "GET"
146
                    },
147
                    {
148
                      "href": "https://api-m.paypal.com/v2/payments/authorizations/0AW2184448108334S/capture",
149
                      "rel": "capture",
150
                      "method": "POST"
151
                    },
152
                    {
153
                      "href": "https://api-m.paypal.com/v2/payments/authorizations/0AW2184448108334S/void",
154
                      "rel": "void",
155
                      "method": "POST"
156
                    },
157
                    {
158
                      "href": "https://api-m.paypal.com/v2/payments/authorizations/0AW2184448108334S/reauthorize",
159
                      "rel": "reauthorize",
160
                      "method": "POST"
161
                    }
162
                  ]
163
                }
164
              ]
165
            }
166
          }
167
        ],
168
        "links": [
169
          {
170
            "href": "https://api-m.paypal.com/v2/checkout/orders/5O190127TN364715T",
171
            "rel": "self",
172
            "method": "GET"
173
          }
174
        ]
175
      }', true);
176
    }
177
 
178
    /**
179
     * @return array
180
     */
181
    public function mockOrderPaymentCapturedResponse(): array
182
    {
183
        return Utils::jsonDecode('{
184
        "id": "5O190127TN364715T",
185
        "status": "COMPLETED",
186
        "payer": {
187
          "name": {
188
            "given_name": "John",
189
            "surname": "Doe"
190
          },
191
          "email_address": "customer@example.com",
192
          "payer_id": "QYR5Z8XDVJNXQ"
193
        },
194
        "purchase_units": [
195
          {
196
            "reference_id": "d9f80740-38f0-11e8-b467-0ed5f89f718b",
197
            "shipping": {
198
              "address": {
199
                "address_line_1": "2211 N First Street",
200
                "address_line_2": "Building 17",
201
                "admin_area_2": "San Jose",
202
                "admin_area_1": "CA",
203
                "postal_code": "95131",
204
                "country_code": "US"
205
              }
206
            },
207
            "payments": {
208
              "captures": [
209
                {
210
                  "id": "3C679366HH908993F",
211
                  "status": "COMPLETED",
212
                  "amount": {
213
                    "currency_code": "USD",
214
                    "value": "100.00"
215
                  },
216
                  "seller_protection": {
217
                    "status": "ELIGIBLE",
218
                    "dispute_categories": [
219
                      "ITEM_NOT_RECEIVED",
220
                      "UNAUTHORIZED_TRANSACTION"
221
                    ]
222
                  },
223
                  "final_capture": true,
224
                  "disbursement_mode": "INSTANT",
225
                  "seller_receivable_breakdown": {
226
                    "gross_amount": {
227
                      "currency_code": "USD",
228
                      "value": "100.00"
229
                    },
230
                    "paypal_fee": {
231
                      "currency_code": "USD",
232
                      "value": "3.00"
233
                    },
234
                    "net_amount": {
235
                      "currency_code": "USD",
236
                      "value": "97.00"
237
                    }
238
                  },
239
                  "create_time": "2018-04-01T21:20:49Z",
240
                  "update_time": "2018-04-01T21:20:49Z",
241
                  "links": [
242
                    {
243
                      "href": "https://api-m.paypal.com/v2/payments/captures/3C679366HH908993F",
244
                      "rel": "self",
245
                      "method": "GET"
246
                    },
247
                    {
248
                      "href": "https://api-m.paypal.com/v2/payments/captures/3C679366HH908993F/refund",
249
                      "rel": "refund",
250
                      "method": "POST"
251
                    }
252
                  ]
253
                }
254
              ]
255
            }
256
          }
257
        ],
258
        "links": [
259
          {
260
            "href": "https://api-m.paypal.com/v2/checkout/orders/5O190127TN364715T",
261
            "rel": "self",
262
            "method": "GET"
263
          }
264
        ]
265
      }', true);
266
    }
267
}