Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 98e6ab4

Browse files
committed
feat: payment information as customer endpoint
1 parent f4b991f commit 98e6ab4

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

src/Api/Carts.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ public function shippingInformation($body = [])
5858
/**
5959
* Lists available payment methods for a specified shopping cart. This call returns an array of objects, but detailed information about each object’s attributes might not be included.
6060
*
61-
* @param array $body
6261
* @return array
6362
*/
6463
public function paymentMethods()
@@ -67,4 +66,17 @@ public function paymentMethods()
6766

6867
return $this->get('/carts/mine/payment-methods');
6968
}
69+
70+
/**
71+
* Set payment information and place order for a specified cart.
72+
*
73+
* @param array $body
74+
* @return array
75+
*/
76+
public function paymentInformation($body = [])
77+
{
78+
$this->validateSingleStoreCode();
79+
80+
return $this->post('/carts/mine/payment-information', $body);
81+
}
7082
}

tests/Api/CartsTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,26 @@ public function test_must_pass_a_single_store_code_to_payment_methods()
122122
$magento = new Magento();
123123
$magento->api('carts')->paymentMethods([]);
124124
}
125+
126+
public function test_can_call_carts_payment_information()
127+
{
128+
Http::fake([
129+
'*rest/default/V1/carts/mine/payment-information' => Http::response([], 200),
130+
]);
131+
132+
$magento = new Magento();
133+
$magento->storeCode = 'default';
134+
135+
$api = $magento->api('carts')->paymentInformation([]);
136+
137+
$this->assertTrue($api->ok());
138+
}
139+
140+
public function test_must_pass_a_single_store_code_to_payment_information()
141+
{
142+
$this->expectException('exception');
143+
144+
$magento = new Magento();
145+
$magento->api('carts')->paymentInformation([]);
146+
}
125147
}

0 commit comments

Comments
 (0)