Skip to content

Commit 0bd732a

Browse files
committed
Add one more test
1 parent c7c68de commit 0bd732a

File tree

3 files changed

+229
-14
lines changed

3 files changed

+229
-14
lines changed

phpunit.xml.dist.bak

Lines changed: 0 additions & 14 deletions
This file was deleted.

tests/ClientTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,29 @@ public function testGetDisbursementDetails(): void
6767
$disbursement = $client->getJson();
6868
$this->assertIsArray($disbursement['disbursement'], "getDisbursementDetails() should return a disbursement");
6969
}
70+
71+
public function testGetPaymentMethods(): void
72+
{
73+
$client = new Client(self::$username, self::$password, self::$endpoint);
74+
$uri = $this->createOrder($client);
75+
$client->getPaymentMethods($uri);
76+
$paymentMethods = $client->getJson();
77+
$this->assertNotEmpty(
78+
$paymentMethods['payment_options'],
79+
"getPaymentMethods() should return payment methods inside payment_options"
80+
);
81+
}
82+
83+
private function createOrder($client): string
84+
{
85+
$order = json_decode(
86+
file_get_contents(__DIR__ . '/_files/order.json'),
87+
true
88+
);
89+
$order_data = $order['order'];
90+
$order_data['merchant']['id'] = self::$merchant;
91+
$order_data['cart']['cart_ref'] = "" . time();
92+
$client->startSolicitation($order_data);
93+
return $client->getOrderUri();
94+
}
7095
}

tests/_files/order.json

Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
{
2+
"order": {
3+
"state": "",
4+
"merchant": {
5+
"id": "REPLACE_WITH_MERCHANT_ID",
6+
"notify_url": "https://my.shop.tld/checkout/sequra-ipn/8765432",
7+
"notification_parameters": {
8+
"cart": "REPLACE_WITH_CART_REF",
9+
"signature": "K6hDNSwfcJjF+suAJqXAjA=="
10+
},
11+
"return_url": "https://my.shop.tld/checkout/confirmed",
12+
"approved_callback": "shop_callback_sequra_approved",
13+
"edit_url": "",
14+
"abort_url": "https://my.shop.tld/checkout/payment",
15+
"rejected_callback": "showHiddenMethods",
16+
"partpayment_details_getter": "partpaymentWidgetDetails",
17+
"approved_url": "https://my.shop.tld/checkout/approved",
18+
"options": {
19+
"has_jquery": true
20+
},
21+
"events_webhook": {
22+
"url": "https://my.shop.tld/checkout/sequra-events/8765432",
23+
"parameters": {
24+
"internal_identifier": "1234",
25+
"signature": "K6hDNSwfcJjF+suAJqXAjA=="
26+
}
27+
},
28+
"timeout": {
29+
"timeout_at": "2017-06-30T13:50:00+02:00",
30+
"timeout_url": "https://my.shop.tld/checkout/sequra-timeout/8765432"
31+
}
32+
},
33+
"merchant_reference": {
34+
"order_ref_1": "REPLACE_WITH_REF_1",
35+
"order_ref_2": "REPLACE_WITH_REF_2"
36+
},
37+
"cart": {
38+
"currency": "EUR",
39+
"gift": false,
40+
"order_total_with_tax": 215802,
41+
"cart_ref": "12223",
42+
"created_at": "2013-10-18T12:25:20+01:00",
43+
"updated_at": "2013-10-18T12:25:20+01:00",
44+
"items": [
45+
{
46+
"reference": "12-123-1234",
47+
"name": "Leather Case (iPod nano) - Negro / Chocolate",
48+
"price_with_tax": 3530,
49+
"quantity": 2,
50+
"total_with_tax": 217060,
51+
"downloadable": false,
52+
"perishable": false,
53+
"personalized": false,
54+
"restockable": true,
55+
"category": "ipod-accesorios",
56+
"description": "Este estuche de cuero de última moda ...",
57+
"manufacturer": "Apple",
58+
"supplier": "Mayorista Makro",
59+
"product_id": "6",
60+
"url": "http://shop.example.com/ipod-accesorios/leather-case",
61+
"tracking_reference": "first"
62+
},
63+
{
64+
"type": "handling",
65+
"reference": "seur24",
66+
"name": "SEUR entrega en 24 horas",
67+
"total_with_tax": 242
68+
},
69+
{
70+
"type": "discount",
71+
"reference": "HALFOFF",
72+
"name": "50 % off the full basket!",
73+
"total_with_tax": -750
74+
},
75+
{
76+
"type": "other_payment",
77+
"reference": "CASH",
78+
"name": "Paid in cash",
79+
"total_with_tax": -750
80+
}
81+
]
82+
},
83+
"trackings": [
84+
{
85+
"type": "pickup_store",
86+
"reference": "first",
87+
"operator_ref": "123-009",
88+
"store_ref": "maquinista",
89+
"tracking_number": "AB331",
90+
"available_at": "2014-02-05T13:21:22+01:00",
91+
"delivered_at": "2014-02-05T19:21:22+01:00",
92+
"address_line_1": "1600 Pennsylvania Avenue",
93+
"address_line_2": "",
94+
"postal_code": "08013",
95+
"city": "Barcelona",
96+
"state": "Barcelona",
97+
"country_code": "ES"
98+
},
99+
{
100+
"type": "pickup_point",
101+
"reference": "second",
102+
"operator_ref": "123-009",
103+
"store_ref": "maquinista",
104+
"tracking_number": "AB331",
105+
"available_at": "2014-02-05T13:21:22+01:00",
106+
"delivered_at": "2014-02-05T19:21:22+01:00",
107+
"address_line_1": "1600 Pennsylvania Avenue",
108+
"address_line_2": "",
109+
"postal_code": "08013",
110+
"city": "Barcelona",
111+
"state": "Barcelona",
112+
"country_code": "ES"
113+
},
114+
{
115+
"type": "postal",
116+
"reference": "third",
117+
"carrier": "SEUR",
118+
"tracking_number": "TX123",
119+
"tracking_url": "https://logistics.es/TX123",
120+
"delivered_at": "2014-02-05T19:21:22+01:00"
121+
}
122+
],
123+
"delivery_method": {
124+
"name": "SEUR24",
125+
"days": "¡Entrega día siguiente!",
126+
"provider": "Correos",
127+
"home_delivery": true
128+
},
129+
"delivery_address": {
130+
"given_names": "Maria José",
131+
"surnames": "Barroso Rajoy",
132+
"company": "",
133+
"address_line_1": "C/ Aragó 383",
134+
"address_line_2": "",
135+
"postal_code": "08013",
136+
"city": "Barcelona",
137+
"country_code": "ES",
138+
"phone": "933 033 033",
139+
"mobile_phone": "615 615 615",
140+
"state": "Barcelona",
141+
"extra": "I'm home between 9 and 12.",
142+
"vat_number": "B12345"
143+
},
144+
"invoice_address": {
145+
"given_names": "Maria José",
146+
"surnames": "Barroso Rajoy",
147+
"company": "",
148+
"address_line_1": "",
149+
"address_line_2": "",
150+
"postal_code": "",
151+
"city": "",
152+
"country_code": "ES",
153+
"phone": "933 033 033",
154+
"mobile_phone": "615 615 615",
155+
"state": "Tarragona",
156+
"extra": "I'm home between 9 and 12.",
157+
"vat_number": "B12345"
158+
},
159+
"customer": {
160+
"given_names": "Maria José",
161+
"surnames": "Barroso Rajoy",
162+
"title": "mr",
163+
"email": "[email protected]",
164+
"logged_in": true,
165+
"language_code": "es-ES",
166+
"ip_number": "12.23.34.45",
167+
"user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.36",
168+
"ref": 123,
169+
"date_of_birth": "1980-01-20",
170+
"nin": "13003009L",
171+
"company": "",
172+
"vat_number": "B12345",
173+
"created_at": "2013-08-15T21:07:37+01:00",
174+
"updated_at": "2013-09-27T16:50:25+01:00",
175+
"rating": 100,
176+
"nin_control": "15012018F2",
177+
"previous_orders": [
178+
{
179+
"created_at": "2013-06-11T12:27:40+02:00",
180+
"amount": 4656,
181+
"currency": "EUR",
182+
"raw_status": "Shipped",
183+
"status": "shipped",
184+
"payment_method_raw": "PayPal",
185+
"payment_method": "PP",
186+
"postal_code": "08013",
187+
"country_code": "ES"
188+
}
189+
]
190+
},
191+
"gui": {
192+
"layout": "desktop"
193+
},
194+
"platform": {
195+
"name": "REPLACE WITH CORRECT VALUE BEFORE QA",
196+
"version": "REPLACE WITH CORRECT VALUE BEFORE QA",
197+
"plugin_version": "REPLACE WITH CORRECT VALUE BEFORE QA",
198+
"uname": "REPLACE WITH CORRECT VALUE BEFORE QA",
199+
"db_name": "REPLACE WITH CORRECT VALUE BEFORE QA",
200+
"db_version": "REPLACE WITH CORRECT VALUE BEFORE QA",
201+
"php_version": "REPLACE WITH CORRECT VALUE BEFORE QA"
202+
}
203+
}
204+
}

0 commit comments

Comments
 (0)