How to cancel an XPay payment

In this tutorial, you'll learn how to

Register the relevant webhooks

Cancel an XPay transfer

Note

If you are new to XPay we recommend you read the XPay overview before starting this tutorial

The tutorial assumes you have a knowledge of APIs and how they work. Refer to the API overview for more details.

The tutorial uses these API endpoints

API

Description

POST /XPay/v1/payments/{id}/cancel

Cancel an outgoing push payment

The tutorial uses these webhooks

Webhook

Description

XPay.Payment.Canceled

Payment canceled at the sender's request or has expired

Before you begin

Make sure you have:

1. Register the relevant webhook events

To receive the webhook events for this tutorial both partner accounts need to register each specific webhook event type. Once you are registered, the event objects are sent to the registered URLs.

The event object contains a list of resource identifiers used to download details on each event.

2. Originate an XPay push transaction

In order to have a payment to cancel, you need to originate a push payment. Learn how to originate a payment in the How to originate an XPay payment tutorial.

3. Cancel the XPay payment

a. To cancel the push payment

  1. Call POST /XPay/v1/payments/{id}/cancel. For this call, the id attribute is required.

    The id attribute is the relatedPaymentID found in response body of the push request.

    Copy
    Cancel XPay payment example
    POST /xpay/v1/payments/id/cancel
    {
      "id": "123456789",
    }
  2. The XPay.Payment.Canceled webhook is triggered and the payment is canceled.