Cancel a Payment

Definition: POST /v1/payments/{id}/cancel

Where:
  • {id} – GlobalPay Payment ID

A payment can be cancelled if it has an Authorized or an Open status. The Authorized status can only be obtained for some payment methods like: Cards, Klarna methods, Cards Russsia, Paysafecard, Paypal and PostFinance.

A payment with an Open status can be cancelled if the payment has been initiated but the customer hasn’t accessed the RedirectURL or the customer didn’t get to the provider’s side. For the offline payment methods the payment can be cancelled if the customer hasn’t yet received the payment details.

A 200 HTTP response (OK) is returned if the request was completed successfully.

Request:

POST https://paytest.smart2pay.com/v1/payments/3897979/cancel
Authorization: Basic MzAyMDE6aEo1Um9iWXg5cjdGZk53Q3ZIWTlMWEhxcXIrRkV6cmM3YUp2UVFrNEdhejFtZzdSeXk=

Response:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
  "Payment": {
    "ID": 3897979,
    "SkinID": 11,
    "ClientIP": null,
    "Created": "20180615091144",
    "MerchantTransactionID": "s2ptest_g242",
    "OriginatorTransactionID": null,
    "Amount": "899",
    "Currency": "GBP",
    "CapturedAmount": null,
    "ReturnURL": "http://demo.smart2pay.com/redirect.php",
    "Description": null,
    "MethodID": 1078,
    "MethodOptionID": null,
    "IncludeMethodIDs": null,
    "ExcludeMethodIDs": null,
    "PrioritizeMethodIDs": null,
    "SiteID": 30201,
    "NotificationDateTime": "20180615091304",
    "Customer": {
      "ID": 340,
      "MerchantCustomerID": "0125",
      "Email": "youremail@email.com",
      "FirstName": "Doe",
      "LastName": "Test",
      "Gender": "0",
      "SocialSecurityNumber": "0801363945",
      "Phone": "+440745785615",
      "Company": "S2P",
      "DateOfBirth": null
      },
    "BillingAddress": {
      "ID": 3959,
      "City": "London",
      "ZipCode": "W13 3BG",
      "State": "London",
      "Street": "New Burlington St 113",
      "StreetNumber": "Apt 214",
      "HouseNumber": null,
      "HouseExtension": null,
      "Country": "GB"
      },
    "ShippingAddress": {
      "ID": 3959,
      "City": "London",
      "ZipCode": "W13 3BG",
      "State": "London",
      "Street": "New Burlington St 113",
      "StreetNumber": "Apt 214",
      "HouseNumber": null,
      "HouseExtension": null,
      "Country": "GB"
      },
    "Articles": [
      {
      "MerchantArticleID": "1235",
      "Name": "Physical",
      "Quantity": 1,
      "Price": "1000",
      "VAT": "1200",
      "Discount": "0.09",
      "Type": "5",
      "DiscountValue": "100"
      }
    ],
    "Details": null,
    "ReferenceDetails": null,
    "CustomParameters": null,
    "PreapprovalID": null,
    "Status": {
      "ID": 3,
      "Info": "Cancelled",
      "Reasons": null
      },
    "MethodTransactionID": null,
    "TokenLifetime": null,
    "Capture": null,
    "PreapprovalDetails": null,
    "RedirectURL": null
  }
}

For Card payments the Authorized status can be obtained when a payment is initiated with the Capture parameter set to false.

Request:

POST https://paytest.smart2pay.com/v1/payments/202237/cancel
Authorization: Basic MTAxMDpnYWJp

Response:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
  "Payment": {
    "ID": 202237,
    "ClientIP": null,
    "SkinID": null,
    "Created": "20161205091456",
    "MerchantTransactionID": "s2ptest_h8",
    "OriginatorTransactionID": null,
    "Amount": "2000",
    "Currency": "EUR",
    "CapturedAmount": 0,
    "ReturnURL": "http://demo.smart2pay.com/redirect.php",
    "Description": "payment product",
    "StatementDescriptor": "bank statement message",
    "MethodID": 6,
    "MethodOptionID": null,
    "SiteID": 1010,
    "NotificationDateTime": null,
    "Customer": {
      "ID": 115,
      "MerchantCustomerID": "null",
      "Email": "customer@test.com",
      "FirstName": "John",
      "LastName": "Doe",
      "Gender": "1",
      "SocialSecurityNumber": "45908-28324",
      "Phone": "0744-783322",
      "Company": "S2P"
    },
    "BillingAddress": {
      "ID": 253,
      "City": "Iasi",
      "ZipCode": "7000-49",
      "State": "Iasi",
      "Street": "Sf Lazar",
      "StreetNumber": "37",
      "HouseNumber": "5A",
      "HouseExtension": "-",
      "Country": "RO"
    },
    "ShippingAddress": {
      "ID": 87,
      "City": "Iasi",
      "ZipCode": "700049",
      "State": "Iasi",
      "Street": "Sf Lazar",
      "StreetNumber": "37",
      "HouseNumber": "-",
      "HouseExtension": "-",
      "Country": "RO"
    },
    "Articles": null,
    "Card": null,
    "CreditCardToken": null,
    "Status": {
      "ID": 3,
      "Info": "Cancelled",
      "Reasons": []
    },
    "MethodTransactionID": null,
    "PaymentTokenLifetime": null,
    "Capture": false,
    "Retry": true,
    "RedirectURL": null,
    "3DSecure": null
  }
}

In case of an API error, an HTTP 4xx (you did something wrong) or HTTP 5xx (we did something wrong) response is returned.

For more information about the reasons of a wrong request response see our section GlobalPay Return Codes.

Request:

POST https://paytest.smart2pay.com/v1/payments/3897979/cancel
Authorization: Basic MzAyMDE6aEo1Um9iWXg5cjdGZk53Q3ZIWTlMWEhxcXIrRkV6cmM3YUp2UVFrNEdhejFtZzdSeXk=

Response:

HTTP/1.1 400 Bad Request
Content-Type: application/json; charset=utf-8

{
  "Payment": {
    "ID": 3897979,
    "SkinID": null,
    "ClientIP": null,
    "Created": "20180615091144",
    "MerchantTransactionID": null,
    "OriginatorTransactionID": null,
    "Amount": null,
    "Currency": null,
    "CapturedAmount": null,
    "ReturnURL": null,
    "Description": null,
    "MethodID": 1078,
    "MethodOptionID": null,
    "IncludeMethodIDs": null,
    "ExcludeMethodIDs": null,
    "PrioritizeMethodIDs": null,
    "SiteID": 30201,
    "NotificationDateTime": "20180615091304",
    "Customer": null,
    "BillingAddress": null,
    "ShippingAddress": null,
    "Articles": null,
    "Details": null,
    "ReferenceDetails": null,
    "CustomParameters": null,
    "PreapprovalID": null,
    "Status": {
      "ID": 3,
      "Info": "Cancelled",
      "Reasons": [
        {
        "Code": "17",
        "Info": "Payment is invalid - 3897979"
        }
      ]
    },
    "MethodTransactionID": null,
    "TokenLifetime": null,
    "Capture": null,
    "PreapprovalDetails": null,
    "RedirectURL": null
  }
}