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 and Paysafecard.

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/3005370/cancel
Authorization: Basic MzAyMDE6aEo1Um9iWXg5cjdGZk53Q3ZIWTlMWEhxcXIrRkV6cmM3YUp2UVFrNEdhejFtZzdSeXk=

Response:

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

{
  "Payment": {
    "ID": 3005370,
    "SkinID": null,
    "ClientIP": null,
    "Created": "20170802144053",
    "MerchantTransactionID": "s2ptest_g26",
    "OriginatorTransactionID": null,
    "Amount": 980,
    "Currency": "EUR",
    "ReturnURL": "http://demo.smart2pay.com/redirect.php",
    "Description": null,
    "MethodID": 75,
    "MethodOptionID": null,
    "IncludeMethodIDs": null,
    "ExcludeMethodIDs": null,
    "PrioritizeMethodIDs": null,
    "SiteID": 30201,
    "NotificationDateTime": "20170802144302",
    "Customer": {
      "ID": 410,
      "MerchantCustomerID": "0125",
      "Email": "youremail@email.com",
      "FirstName": "Example",
      "LastName": "Test",
      "Gender": "1",
      "SocialSecurityNumber": "410321-9202",
      "Phone": "0765260000",
      "Company": "S2P",
      "DateOfBirth": null
    },
    "BillingAddress": {
      "ID": 896,
      "City": "Ankeborg",
      "ZipCode": "12345",
      "State": "Iasi",
      "Street": "Stargatan",
      "StreetNumber": "1",
      "HouseNumber": "22",
      "HouseExtension": "25",
      "Country": "SE"
    },
    "ShippingAddress": {
      "ID": 896,
      "City": "Ankeborg",
      "ZipCode": "12345",
      "State": "Iasi",
      "Street": "Stargatan",
      "StreetNumber": "1",
      "HouseNumber": "22",
      "HouseExtension": "25",
      "Country": "SE"
    },
    "Articles": [
      {
        "MerchantArticleID": "1231",
        "Name": "TEST",
        "Quantity": 1,
        "Price": 1000,
        "VAT": 1000,
        "Discount": 2,
        "Type": 1,
        "DiscountValue": 0
      }
    ],
    "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://securetest.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/3005670/cancel
Authorization: Basic MzAyMDE6aEo1Um9iWXg5cjdGZk53Q3ZIWTlMWEhxcXIrRkV6cmM3YUp2UVFrNEdhejFtZzdSeXk=

Response:

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

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