Cancel a Card Payment

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

Where:
  • {id} – GlobalPay Payment ID

A payment can be cancelled if it has an Authorized status. The Authorized status can only be obtained for direct card payments initiated with Capture parameter set to false.

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

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://securetest.smart2pay.com/v1/payments/202237/cancel
Authorization: Basic MTAxMDpnYWJp

Response:

HTTP/1.1 400 Bad Request
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": [
        {
          "Code": "1006",
          "Info": "Payment.State is invalid"
        }
      ]
    },
    "MethodTransactionID": null,
    "PaymentTokenLifetime": null,
    "Capture": false,
    "Retry": true,
    "RedirectURL": null,
    "3DSecure": null
  }
}