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

Commit e83cb0b

Browse files
committed
feat: add payment information endpoint for guest
1 parent 98e6ab4 commit e83cb0b

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/Api/GuestCarts.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,23 @@ public function shippingInformation($cartId, $body = [])
102102
/**
103103
* List 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.
104104
*
105+
* @param string $cartId
105106
* @return array
106107
*/
107108
public function paymentMethods($cartId)
108109
{
109110
return $this->get('/guest-carts/'.$cartId.'/payment-methods');
110111
}
112+
113+
/**
114+
* Set payment information and place order for a specified cart.
115+
*
116+
* @param string $cartId
117+
* @param array $body
118+
* @return array
119+
*/
120+
public function paymentInformation($cartId, $body = [])
121+
{
122+
return $this->post('/guest-carts/'.$cartId.'/payment-information', $body);
123+
}
111124
}

tests/Api/GuestCartsTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,17 @@ public function test_can_call_guest_carts_payment_methods()
121121

122122
$this->assertTrue($api->ok());
123123
}
124+
125+
public function test_can_call_guest_carts_payment_information()
126+
{
127+
Http::fake([
128+
'*rest/all/V1/guest-carts/foo/payment-information' => Http::response([], 200),
129+
]);
130+
131+
$magento = new Magento();
132+
133+
$api = $magento->api('guestCarts')->paymentInformation('foo', ['bar']);
134+
135+
$this->assertTrue($api->ok());
136+
}
124137
}

0 commit comments

Comments
 (0)