Inhalte aufrufen

Profilbild

Handle orders with failed payment


  • Bitte melden Sie sich an, um eine Antwort zu verfassen.
1 Antwort zu diesem Thema

#1 HatemHusam

HatemHusam

    Advanced Member

  • Members
  • PunktPunktPunkt
  • 30 Beiträge

Geschrieben: 30 March 2020 - 12:24

I have an inquiry with gateway integration please, I'm using the following code to mark the order as canceled  if the payment is failed.
 
But I wonder if this is the right way to handle rejected payment in Smart store @__@ ?
 
order.AuthorizationTransactionResult = "Declined";
 order.PaymentStatus = PaymentStatus.Voided;
 _orderService.UpdateOrder(order);
_orderProcessingService.CancelOrder(order, true);

 



#2 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3801 Beiträge

Geschrieben: 30 March 2020 - 17:08

If you cancel the payment by calling the payment provider, then it's not necessary to call OrderProcessingService.CancelOrder.
In your override for PaymentMethodBase.Void just return PaymentStatus.Voided through VoidPaymentResult.NewPaymentStatus.
And OrderService.UpdateOrder isn't required too. Here's a code example.
OrderProcessingService.CancelOrder is intended for offline cancelation (without calling the payment provider).

Marcus Gesing

Smartstore AG