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

Commit a29e6c3

Browse files
committed
feat: add cart payment methods endpoint
1 parent 2df62ea commit a29e6c3

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

src/Api/Carts.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,17 @@ public function shippingInformation($body = [])
5454

5555
return $this->post('/carts/mine/shipping-information', $body);
5656
}
57+
58+
/**
59+
* 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.
60+
*
61+
* @param array $body
62+
* @return array
63+
*/
64+
public function paymentMethods()
65+
{
66+
$this->validateSingleStoreCode();
67+
68+
return $this->get('/carts/mine/payment-methods');
69+
}
5770
}

tests/Api/CartTotalsTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ public function test_can_call_cart_totals_mine()
1818
Http::fake();
1919

2020
$magento = new Magento();
21-
$magento->storeCode = 'default';
21+
$magento->storeCode = 'def
22+
ault';
2223

2324
$api = $magento->api('cartTotals')->mine();
2425

tests/Api/CartsTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,26 @@ public function test_must_pass_a_single_store_code_to_shipping_information()
100100
$magento = new Magento();
101101
$magento->api('carts')->shippingInformation([]);
102102
}
103+
104+
public function test_can_call_carts_payment_methods()
105+
{
106+
Http::fake([
107+
'*rest/default/V1/carts/mine/payment-methods' => Http::response([], 200),
108+
]);
109+
110+
$magento = new Magento();
111+
$magento->storeCode = 'default';
112+
113+
$api = $magento->api('carts')->paymentMethods([]);
114+
115+
$this->assertTrue($api->ok());
116+
}
117+
118+
public function test_must_pass_a_single_store_code_to_payment_methods()
119+
{
120+
$this->expectException('exception');
121+
122+
$magento = new Magento();
123+
$magento->api('carts')->paymentMethods([]);
124+
}
103125
}

0 commit comments

Comments
 (0)