sveawebpay / php-integration

SDK for Sveas payment methods (standalone and Svea Checkout)
Other
15 stars 19 forks source link

Update the ClientOrderNumber after checkout #88

Open watta90 opened 3 years ago

watta90 commented 3 years ago

Hi,

The ClientOrderNumber is generated after the checkout is finished in my system. How can I update the ClientOrderNumber after the checkout in Svea? I've tried the following but it didn't update the ClientOrderNumber.

$orderBuilder = WebPay::checkout($config);
$orderBuilder->setCheckoutOrderId($checkoutId)
    ->setCountryCode('SE');

$item= WebPayItem::orderRow(); // I get the Items after quering the order.
$orderBuilder->addOrderRow($item);
$orderBuilder->setClientOrderNumber($newId);
$response = $orderBuilder->updateOrder();

I see that the regular orders are possible to update the ClientOrderNumber from this test: https://github.com/sveawebpay/php-integration/blob/1704c890d3a1122bca4403198025b533681b332b/test/IntegrationTest/AdminService/UpdateOrderRequestIntegrationTest.php#L23

fre-sund commented 3 years ago

Hi,

Unfortunately it's not possible to update the ClientOrderNumber after an order is finalized using Svea Checkout due to technical limitations in our payment gateway, this may be fixed in the future.

The last possible time to update the ClientOrderNumber is when responding to our callback that we send if you've set a CheckoutValidationCallbackUri in your MerchantSettings when creating the order.

If you've sent a CheckoutValidationCallbackUri we will send a callback when the end-user clicks the "Finalize purchase" which you will have to respond to with a CheckoutValidationCallbackResponse

Please note that the purchase may fail after this response is received so the callback should not be seen as a callback for a finalized purchased but rather as the end-user is trying to finalize the purchase. The purchase may fail for several reasons such as the end-user might not be accepted by our external scoring or the end-user might not finalize the purchase when selecting the card payment option and not filling out their information after being redirected to our payment gateway.

The only point that a order should be seen as finalized is when you receive a push to your PushUri and you fetch the order and see that the status is "Final".

The test you're refering to is for our standalone payment methods, where the ClientOrderNumber can be updated for some payment methods (such as invoices).

Best regards, fre-sund