Payments App how to handle cancel

Solved
dabedala
New Member
4 0 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)

Accepted Solutions
L_J_K
Shopify Staff
363 54 65

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!

| API Support @ 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

Reply 1 (1)
L_J_K
Shopify Staff
363 54 65

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!

| API Support @ 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