Payment Link via API

Payment Link via API Flow

1. Create a Payment Link

To start accepting payments on your website, app or platform, you will need to create a Payment Link object that will help capture the payments made by your customers.

When creating a Payment Link object , make sure you bind it to one of your customers. This will ensure that you know who has made a payment when we notify you of a successful payment.

Xfers will try to provide all available payment methods for your customer on the payment page. Below, you'll be able to see an example of API request for a Payment Link.

# /api/v4/payment_links
{
   "data": {
     "attributes": {
       "amount": 10000,
       "referenceId": "Payment_link_reference_id",
       "description": "Order Number 0001",
       "customerName": "John Doe",
       "expiredAt": "2021-12-06T16:00:00+07:00",
       "customerEmail": "[email protected]",
       "customerPhoneNumber": "080000000000",
       "paymentMethodOptions": {
         "displayName": "Nama Tampilan"
       }
     }
   }
}

2. Show payment instructions to your customers if any.

You will receive an url that show all available payment methods and payment instruction for your customer to make the payment. Xfres will also send the url information on email to your customer. This is a sample response you will get.

{
    "data": {
        "id": "paymentlink_fd65953f01a9de1364fe899d2722f255",
        "type": "payment_links",
        "attributes": {
            "status": "pending",
            "amount": "10000.0",
            "referenceId": "Payment_link_reference_id",
            "createdAt": "2021-12-05 22:05:26 +0700",
            "description": "Order Number 0001",
            "expiredAt": "2021-12-06 16:00:00 +0700",
            "paymentLinkUrl": "https://id-payment-link.xfers.com/paymentlink_fd65953f01a9de1364fe899d2722f255",
            "customerName": "John Doe",
            "customerEmail": "[email protected]",
            "customerPhoneNumber": "080000000000",
            "paymentMethodOptions": {
              "displayName": "Nama Tampilan"
            }
        }
    }
}

3. Xfers will notify you when payment has been made successfully.

Some payment methods will require additional actions to be performed by your end-customers. Once a payment has been made successfully, we will notify you with a callback. The payment link's status will now be paid.

# Sample Callback
{
    "data": {
        "id": "paymentlink_fd65953f01a9de1364fe899d2722f255",
        "type": "payment_links",
        "attributes": {
            "status": "paid",
            "amount": "10000.0",
            "referenceId": "Payment_link_test_05122021_1",
            "createdAt": "2021-12-05 22:05:26 +0700",
            "description": "Order Number 0001",
            "expiredAt": "2021-12-06 16:00:00 +0700",
            "paymentLinkUrl": "https://id-payment-link.xfers.com/paymentlink_fd65953f01a9de1364fe899d2722f255",
            "customerName": "John Doe",
            "customerEmail": "[email protected]",
            "customerPhoneNumber": "080000000000",
            "paymentMethodOptions": {
              "displayName": "Nama Tampilan"
            }
        }
    }
}

Present the payment results to your customer, and you may now fulfill your order.

4. Xfers will further notify you when funds have been made available for you to withdraw or transfer.

In most cases, funds may not be immediately available for withdrawal or transfer. Xfers will further notify you with a callback when funds have been made available. The payment's status will then be set to completed.

# Sample Callback
{
    "data": {
        "id": "paymentlink_fd65953f01a9de1364fe899d2722f255",
        "type": "payment_links",
        "attributes": {
            "status": "completed",
            "amount": "10000.0",
            "referenceId": "Payment_link_test_05122021_1",
            "createdAt": "2021-12-05 22:05:26 +0700",
            "description": "Order Number 0001",
            "expiredAt": "2021-12-06 16:00:00 +0700",
            "paymentLinkUrl": "https://id-payment-link.xfers.com/paymentlink_fd65953f01a9de1364fe899d2722f255",
            "customerName": "John Doe",
            "customerEmail": "[email protected]",
            "customerPhoneNumber": "080000000000",
            "paymentMethodOptions": {
              "displayName": "Nama Tampilan"
            }
        }
    }
}

Did this page help you?