Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Payment STAGE - When I click failure button it is cancelling the order #1

Open
santhoshinet opened this issue Jan 23, 2021 · 2 comments

Comments

@santhoshinet
Copy link

Dear All,

I have integrated the 4.3 version into my nop commerce application. I have configured the Paytm STAGE keys to complete the testing process.

Issue: It goes to payment screen successfully and Paytm asks two options (Failure / Success) , when I choose Failure it is cancelling the order on its callback method. And we could not able to do the re-pay. Please help how to set the current as failure instead of cancel so that user can try re-pay.

Also Please upload source code for 4.3 paytm plug in code.

Thanks in Advance

@pranaykothari
Copy link

Hi Santhosh,

Not sure if this still helps you, but here's how we have solved these two problems on our side. We had to modify the source code.

  1. Order cancelled on FAILURE of payment

Solution: Paytm plugin source code does that, so we commented it (file: PaymentPaytmController.cs)

//_orderProcessingService.CancelOrder(order, false); //order.OrderStatus = OrderStatus.Cancelled; //_orderService.UpdateOrder(order);

  1. Retry payment is not allowed

Solution: paytm does not allow paytment retry on the same order number. Hence, when sending the order number to paytm, we attach a random 8 digit after a hiphen everytime. When the data is returned from paytm, we remove that random 8 digit and hiphen on our side.

a) add 8 characters to orderid in file: PaytmPaymentProcessor.cs

`
...
...
//or add only an order total query parameters to the request
queryParameters.Add("MID", _paytmPaymentSettings.MerchantId.Trim().ToString());
queryParameters.Add("WEBSITE", _paytmPaymentSettings.Website.Trim().ToString());
queryParameters.Add("CHANNEL_ID", "WEB");
queryParameters.Add("INDUSTRY_TYPE_ID", _paytmPaymentSettings.IndustryTypeId.Trim().ToString());
queryParameters.Add("TXN_AMOUNT", postProcessPaymentRequest.Order.OrderTotal.ToString("0.00"));
//queryParameters.Add("ORDER_ID", postProcessPaymentRequest.Order.Id.ToString());

        #region create unique orderid

        //note: commented the line above to support unique orderIds during retry paytment
        queryParameters.Add("ORDER_ID", postProcessPaymentRequest.Order.Id.ToString() + "-" + Guid.NewGuid().ToString().Substring(0, 8));

        #endregion

...
...
`

b) remove code in file: PaymentPaytmController.cs

`...
....
orderId = parameters["ORDERID"];
#region create unique orderid

//This code ensures that if OrderId was generated to include a random 8 characters in the end with a "-" separator
//to send unique OrderId to Paytm (to support Retry Payment"), we will remove
//those extra characters here.

string orderIdx = parameters["ORDERID"];

if (orderIdx.Contains("-"))
orderId = orderIdx.Substring(0, orderIdx.Length - 9);

#endregion
...
...
if (ResCode == "01" && AuthDesc == "TXN_SUCCESS")
{
//if (TxnStatus(orderId, order.OrderTotal.ToString("0.00"))) //original
if (TxnStatus(orderIdx, order.OrderTotal.ToString("0.00"))) //updated code: send orderIdx to paytm to confirm
{
...
...
`

Hope this helps. @LalitChaudhary1 @MayankGupta1 Please note and suggest if there is a better way to do this.

@santhoshinet
Copy link
Author

Thanks for the comments, Can you please share source code for 4.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants