I can create a PayPal Order inside my Laravel Controller like so:
$provider = PayPal::setProvider();
$provider->setApiCredentials(config('paypal'));
$token = $provider->getAccessToken();
$provider->setAccessToken($token);
$price = '2';
$currency = '';
$order = $provider->createOrder([
'intent' => 'CAPTURE',
'purchase_units' => [
[
'amount' => [
'currency_code' => 'EUR',
'value' => $price
],
]
]
]);
return response()->json($order);
but when I try to add a quantity property (quantity of the same item to be bought):
$provider = PayPal::setProvider();
$provider->setApiCredentials(config('paypal'));
$token = $provider->getAccessToken();
$provider->setAccessToken($token);
$price = '2';
$currency = '';
$order = $provider->createOrder([
'intent' => 'CAPTURE',
'purchase_units' => [
[
'amount' => [
'currency_code' => 'EUR',
'value' => $price
],
'items' => [
'name' => 'photo',
'quantity' => '5'
]
]
]
]);
return response()->json($order);
I’m getting a warning:
click_initiate_payment_reject {err: 'Error: Expected an order id to be passedn at ht…ng=card,giropay,sepa,sofort¤cy=EUR:2:14811)', timestamp: '1657705690794', referer: 'www.sandbox.paypal.com', sdkCorrelationID: 'f857450e442be', sessionID: 'uid_c2bc52c0a2_mdk6mzg6mta', …}
and this error:
Uncaught Error: Expected an order id to be passed
at https://www.sandbox.paypal.com/smart/buttons?
Am I setting the quantity incorrectly? What’s the right way to do it? I really just want to send the total quantity of purchases, so that it’s displayed in the paypal checkout.