I have created a Payment Provider for GlobalPayments and it works fine.
However, if the user enters a card which is then declined, I would like to return the user to a page from where they can then return to the payment page, with the current basket still intact.
I have “FinalizeAtContinueUrl” = true.
In “ProcessCallbackAsync” I return a status of Cancelled. I get to the required page but the basket is now empty.
Below is the basics of “ProcessCallback”
public override Task<CallbackResult> ProcessCallbackAsync(PaymentProviderContext<GlobalPaymentsSettings> context, CancellationToken cancellationToken = default(CancellationToken))
{
try
{
var responseCode = response.ResponseCode; // 00
if (responseCode == "00")
{
return Task.FromResult<CallbackResult>(new CallbackResult
{
TransactionInfo = new TransactionInfo
{
AmountAuthorized = (decimal)context.Order.TransactionAmount.Value,
TransactionFee = 0M,
TransactionId = response.OrderId,
PaymentStatus = PaymentStatus.Captured
},
MetaData = metaData
});
}
return Task.FromResult<CallbackResult>(new CallbackResult
{
TransactionInfo = new TransactionInfo
{
TransactionId = response.OrderId,
PaymentStatus = PaymentStatus.Cancelled
}
});
}
catch (ApiException ex)
{
return Task.FromResult(CallbackResult.BadRequest());
}
}
After return from GlobalPayments (and having gone through “processCallback”), using “GetCurrentOrder(storeId)” does not return the current order as required, so the basket is then empty.
How can I handle a declined card response from GlobalPayments and then return to the checkout flow with the current basket (Commerce Order) still active?