Skip to content

Commit 41b9d71

Browse files
authored
Merge pull request #10 from utrustdev/njokikiarie/sno-146-update-the-php-library
update php library
2 parents cc2bf8f + 1671133 commit 41b9d71

3 files changed

Lines changed: 7 additions & 44 deletions

File tree

examples/create_simple_order.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,6 @@
2424
'cancel_url' => 'http://example.com/order_canceled',
2525
'callback_url' => 'http://example.com/webhook_url',
2626
],
27-
'line_items' => [
28-
[
29-
'sku' => 'tshirt-1234',
30-
'name' => 'T-shirt',
31-
'price' => '10.00',
32-
'currency' => 'EUR',
33-
'quantity' => 1,
34-
],
35-
],
3627
];
3728

3829
// Build Customer data array

src/Validator.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,19 @@ public static function order($data)
5151
['amount.total'],
5252
['amount.currency'],
5353
['return_urls'],
54-
['return_urls.return_url'],
55-
['line_items'],
56-
['line_items.*.name'],
57-
['line_items.*.price'],
58-
['line_items.*.currency'],
59-
['line_items.*.quantity'],
54+
['return_urls.return_url']
6055
],
6156
'optional' => [
6257
['amount.details'],
6358
['amount.details.subtotal'],
6459
['amount.details.tax'],
6560
['amount.details.shipping'],
6661
['amount.details.discount'],
62+
['line_items'],
63+
['line_items.*.name'],
64+
['line_items.*.price'],
65+
['line_items.*.currency'],
66+
['line_items.*.quantity'],
6767
['line_items.*.sku'],
6868
['return_urls.cancel_url'],
6969
['return_urls.callback_url'],

tests/ValidatorTest.php

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,7 @@ public function testValidOrder(): void
5151
'cancel_url' => 'http://example.com/order_canceled',
5252
'callback_url' => 'http://example.com/webhook_url',
5353
],
54-
'line_items' => [
55-
[
56-
'sku' => 'tshirt-1234',
57-
'name' => 'T-shirt',
58-
'price' => '10.00',
59-
'currency' => 'EUR',
60-
'quantity' => 1,
61-
],
62-
],
54+
6355
];
6456

6557
$result = Validator::order($validOrderData);
@@ -78,30 +70,10 @@ public function testInvalidOrder(): void
7870
'return_url' => 'http://example.com/order_success',
7971
'cancel_url' => 'example.com/this-is-not-a-correct-url',
8072
],
81-
'line_items' => [
82-
[
83-
'sku' => 'tshirt-1234',
84-
'quantity' => 'this-is-not-an-integer',
85-
],
86-
],
8773
];
8874

8975
$expected_errors_message = print_r([
9076
"reference" => ["Reference is required"],
91-
"line_items.*.name" => [
92-
"Line Items.*.name is required",
93-
],
94-
"line_items.*.price" => [
95-
"Line Items.*.price is required",
96-
],
97-
"line_items.*.currency" => [
98-
"Line Items.*.currency is required",
99-
"Line Items.*.currency contains invalid characters",
100-
],
101-
"line_items.*.quantity" => [
102-
103-
"Line Items.*.quantity must be an integer",
104-
],
10577
"amount.currency" => [
10678
"Amount.currency contains invalid characters",
10779
],

0 commit comments

Comments
 (0)