Returns an array in the format of PayPal’s purchase_unit_request
object.
$cart->payPalPurchaseUnits(): array
If you use this method in combination with the paypal.purchaseUnits
option you can provide additional information of the user’s cart to PayPal.
Return Type
array
Returns an array in the format of PayPal’s purchase_unit_request
Example
$cart = cart([
[
'id' => 'apple',
'title' => 'Apple',
'quantity' => 6,
'price' => 0.99,
],
[
'id' => 't-shirt',
'title' => 'T-Shirt',
'quantity' => 2,
'price' => 49.99,
]
]);
dump($cart->toPayPalPurchaseUnits());
Returns
Array
(
[0] => Array
(
[description] => My Online Shop
[amount] => Array
(
[value] => 105.92
[currency_code] => EUR
[breakdown] => Array
(
[item_total] => Array
(
[value] => 105.92
[currency_code] => EUR
)
)
)
[items] => Array
(
[0] => Array
(
[name] => Apple
[unit_amount] => Array
(
[value] => 0.99
[currency_code] => EUR
)
[quantity] => 6
)
[1] => Array
(
[name] => T-Shirt
[unit_amount] => Array
(
[value] => 49.99
[currency_code] => EUR
)
[quantity] => 2
)
)
)
)
Source Code