The Community Forum is not available for new posts or responses; previous posts remain available to review. For comprehensive support options, please visit PayPal.com/HelpCenter
Merchant Technical Support: For technical support and related questions, please visit our Technical Support Help Center or Developer Central
If you want to report illegal content under the EU Digital Services Act, please do so here
Friends,
I'm trying to implement the solution described in this post:
So I added the PHP PayPal SDK on my server-side code to PATCH the order after I get the information back:
protected function patchOrder($orderId, $invoiceId)
{
$client = PayPalClient::client();
$request = new OrdersPatchRequest($orderId);
$request->body = [ ['op' => 'add',
'path' => '/purchase_units/@reference_id==\'default\'/invoice_id',
'value' => $invoiceId] ];
$client->execute($request);
}
But my current client-side implementation completes the transaction so I get the fatal ORDER_ALREADY_COMPLETED error. I have tried various solutions like passing commit=false and intent=authorize into the script tag and actions.order.create() method but I still can't seem to intercept it before it completes. What am I missing?
Please don't link me to https://developer.paypal.com/docs/checkout/integration-features/update-order-details/ , that's the page I'm referencing but something is malfunctioning.
paypal.Buttons({
createOrder: function (data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
value: amt.toFixed(2)
}
}]
});
},
commit: false,
onApprove: function (data, actions) {
return actions.order.capture().then(function (details) { // also tried actions.order.authorize() but no luck
if (details.purchase_units.length > 0) {
$("#orderid").val(details.id);
$("#amount").val(details.purchase_units[0].amount.value);
$("#address1").val(details.purchase_units[0].shipping.address.address_line_1);
$("#address2").val(details.purchase_units[0].shipping.address.address_line_2);
$("#city").val(details.purchase_units[0].shipping.address.admin_area_2);
$("#province").val(details.purchase_units[0].shipping.address.admin_area_1);
$("#zipcd").val(details.purchase_units[0].shipping.address.postal_code);
}
$("form#payment").submit();
});
}
}).render('#paypal-button');
Thanks,
Dan Hermann
MUUSA Webmaster