Solved

Payments App how to handle cancel

dabedala
Shopify Partner
18 1 0

Hi team,

in processing a payment doc, it mentions that cancelled payments should go to 

cancel_url

 

as per request json example:

{
  "id": "8BLFxjEHP5PkA1kNsb6iRKX9",
  "gid": "gid://shopify/PaymentSession/8BLFxjEHP5PkA1kNsb6iRKX9",
  "group": "rZNvy+1jH6Z+BcPqA5U5BSIcnUavBha3C63xBalm+xE=",
  "amount": "123.00",
  "currency": "CAD",
  "test": false,
  "merchant_locale": "en",
  "payment_method": {
    "type": "offsite",
    "data": {
      "cancel_url": "https://my-test-shop.com/1/checkouts/4c94d6f5b93f726a82dadfe45cdde432"
    }
  },
  "proposed_at": "2020-07-13T00:00:00Z",
  "customer": {
    "billing_address": {
      "given_name": "Alice",
      "family_name": "Smith",
      "line1": "123 Street",
      "line2": "Suite B",
      "city": "Montreal",
      "postal_code": "H2Z 0B3",
      "province": "Quebec",
      "country_code": "CAN",
      "company": ""
    },
    "shipping_address": {
      "given_name": "Alice",
      "family_name": "Smith",
      "line1": "123 Street",
      "line2": "Suite B",
      "city": "Montreal",
      "postal_code": "H2Z 0B3",
      "province": "Quebec",
      "country_code": "CAN",
      "company": ""
    },
    "email": "buyer@example.com",
    "phone_number": "5555555555",
    "locale": "fr"
  },
  "kind": "sale"
}

 

My questions is, what to do with cancelled transaction? should my app send a  PaymentSessionReject mutation? or does my app do nothing and Shopify handles this case without resolve/reject?

 

Thanks

Accepted Solution (1)

Luke_K
Shopify Staff
402 66 98

This is an accepted solution.

Hey @dabedala 

Thanks for checking in with us. With payment apps, a call should be made to run the either paymentSessionResolve or paymentSessionReject mutations for any payment -  that would include cancellation. 

For a transaction for which the resolve mutation has not been called yet, paymentSessionReject would need to be called to let Shopify know the transaction was not completed and was cancelled. 

Additionally it's worth noting that if theresolve mutation has already been called, then the transaction is considered a success and cannot be reverted. Hope that helps explain more!

| Shopify |
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!

View solution in original post

Replies 7 (7)

Luke_K
Shopify Staff
402 66 98

This is an accepted solution.

Hey @dabedala 

Thanks for checking in with us. With payment apps, a call should be made to run the either paymentSessionResolve or paymentSessionReject mutations for any payment -  that would include cancellation. 

For a transaction for which the resolve mutation has not been called yet, paymentSessionReject would need to be called to let Shopify know the transaction was not completed and was cancelled. 

Additionally it's worth noting that if theresolve mutation has already been called, then the transaction is considered a success and cannot be reverted. Hope that helps explain more!

| Shopify |
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
adiputra22
Shopify Partner
7 0 1

hi @Luke_K please help me how to get Order after get key like `gid://shopify/PaymentSession/iJ6dOX11cFVzzWLVAWm-47VX`

martabel
Shopify Partner
72 1 7

Hello, but if reject is called then it's not possible to try again with same payment provider. There are only 2 types of codes for rejection. I would like it to create a new paymentsession.

martabel
Shopify Partner
72 1 7

@Luke_K 

In my case when user just wants to come back to the shop for a second from payment provider side it will get CANCELLED in our system, we would like to create a new transaction in our system for every click from the Shopify checkout page "Pay" button. When I do PaymentSessionReject it will not allow to use same payment provider again. I would like to cancel the old session and have it send a new request to our backend. Is it possible with current setup?

SeQura
Shopify Partner
10 0 3

I'm calling to paymentSessionReject after having set the payment as pending in first place with paymentSessionPending mutation. I get no errors in in the mutation response but the order remains as pending in the merchant's backoffice, What could the problem be?

Seguimos trabajando en ser tu solución de pagos preferida 🙂 Cualquier cosa que necesites no dudes en contactarnos enviando un email a sat@sequra.es
¡Gracias por tu confianza!
El equipo de SeQura
windcavedev
Visitor
3 0 0

Hi @Luke_K , it looks like there were some changes to the Payments App API, and this solution is not correct anymore? As per current version of documentation:

 

--

Rejecting a payment is final. You can't call other actions on a payment after it has been rejected. The payments app should retry a failed user attempt and complete the payment before calling the PaymentSessionReject. For example, if any of the following conditions are met, then you don't need to reject the payment:

  • The user doesn't interact with your payments app
  • The user cancels the payment
  • The user needs to retry the payment because of specific errors, such as user entering the wrong CVV

---

So we are not supposed to send PaymentSessionReject for cancelled payments anymore. It would be great to know the recommended behavior now. Do we just redirect to cancel_url without sending any webhooks? Also, what should be the behavior in the last case (the error case). We should return the customer back to Shopify, but the return URL is being provided only in the mutation response. However, since we are not supposed to send a mutation in the error case, we don't have the return URL. Do we redirect to cancel_url in that case as well?

 

Kind regards,

Igor

SeQura
Shopify Partner
10 0 3

Thanks for your response, but what happens when you call paymentSessionReject after having set the payment as pending calling the PaymentSessionPending mutation?

 

I get no errors in the mutation response but the order remains as pending in the merchant's backoffice, What could the problem be?

Seguimos trabajando en ser tu solución de pagos preferida 🙂 Cualquier cosa que necesites no dudes en contactarnos enviando un email a sat@sequra.es
¡Gracias por tu confianza!
El equipo de SeQura