🖇️Payment Links

Introduction

  • Payment links are a quick and easy way for merchants to accept payments from customers. With Sonic Payment Gateway, you can create unique payment links that can be shared via email, social media, or any other medium.

  • Payment links can be customized with various options such as custom amounts, currency, and expiration date. They can also be associated with a specific product or pricing.

  • Payment links can be created using our API or through the Sonic Payment Gateway Dashboard.

POST https://api.sonicpay.org/v1/payment_links

Request Body

Name
Type
Description

amount*

1000

currency*

USDT

price_id*

def456

expiry_date*

2022-12-31

metadata

"customer_name: "John Smith"

{
    "id": "ghi789",
    "url": "https://sonicpay.org/p/ghi789",
    "amount": 1000,
    "currency": "USDT",
    "product_id": "abc123",
    "price_id": "def456
}
  • To retrieve an existing payment link, you can use the GET endpoint and pass in the payment link ID. This will return a JSON object containing information about the link, including its status, expiration date, and any metadata associated with it.

GET https://api.sonicpay.org/v1/payment_links/{link_id}

Headers

Name
Type
Description

Authorization: Bearer*

xxxxxx

{
    "id": "5f0efa72-f2b9-4b5d-9c1b-8f8f1e0b0c2d",
    "status": "active",
    "amount": 100,
    "currency": "USD",
    "expires_at": "2022-10-01T00:00:00.000Z",
    "metadata": {
        "product_id": "5f0efa72-f2b9-4b5d-9c1b-8f8f1e0b0c2d"
    }
  • To delete a payment link, you will need to make a DELETE request to our API endpoint at https://api.sonicpay.org/api/v1/%3Cpayment_link_id%3E. The <payment_link_id> in the endpoint should be replaced with the unique identifier of the payment link you want to delete.

  • Before making the request, you will need to include your API key in the headers of the request for authentication.

DELETE https://api.sonicpay.org/api/v1/links/<payment_link_id>

Headers

Name
Type
Description

Authorization: Bearer*

YOUR_API_KEY

{
    "status": "success",
    "message": "Payment link with id e7f0a97-9de8-4cdc-b130-e8dd5f06caf4 was successfully deleted"
}
  • To update a payment link, you will need to make a PUT request to the https://api.sonicpay.org/api/v1/payment_links/:id endpoint, passing in the updated values in the request body.

  • The request body should include the updated values for the payment link such as the name, description, amount, and currency.

Here is an example of how to update a payment link using our SDK:

const SonicPaymentGateway = require('SonicPaymentGateway')
const client = new SonicPaymentGateway({apiKey: 'your_api_key'})

const linkId = 'link_id'
const updates = {
    name: 'updated name',
    description: 'updated description',
    amount: 1000,
    currency: 'USDT'
}

client.updatePaymentLink(linkId, updates).then((response) => {
    console.log(response)
}).catch((error) => {
    console.log(error)
})

PUT https://api.sonicpay.org/api/v1/payment_links/:id

Headers

Name
Type
Description

Authorization: Bearer *

your_api_key

Content-Type*

application/json

Request Body

Name
Type
Description

name*

Updated Name

description*

Updated Description

amount*

100

currency*

USDT

HTTP/1.1 200 OK
Content-Type: application/json
{
    "id": "5f0efa72-f2b9-4b5d-9c1b-8f8f1e0b0c2d",
    "name": "updated name",
    "description": "updated description",
    "amount": 100,
    "currency": "USDT",
    "created_at": "2022-01-19T00:00:00.000Z",
    "updated_at": "2022-01-19T00:00:00.000Z"
}
Parameter
Type
Required
Description

name

string

Yes

Updated name of the payment link

description

string

No

Updated description of the payment link

amount

number

No

Updated amount of the payment link

currency

string

No

Updated currency of the payment link

Here is an example of how to retrieve all payment links using our SDK:

const SonicPay = require('SonicPay')
const client = new SonicPay({apiKey: 'your_api_key'})

client.getAllPaymentLinks().then((response) => {
    console.log(response)
}).catch((error) => {
    console.log(error)
})

GET https://api.sonicpay.org/api/v1/payment_links

Headers

Name
Type
Description

Content-Type*

application/json

Authorization: Bearer*

your_api_key

HTTP/1.1 200 OK
Content-Type: application/json
{
    "payment_links": [
        {
            "id": "5f0efa72-f2b9-4b5d-9c1b-8f8f1e0b0c2d",
            "name": "Payment Link 1",
            "description": "This is a payment link for product 1",
            "amount": 100,
            "currency": "USD",
            "created_at": "2022-01-19T00:00:00.000Z",
            "updated_at": "2022-01-19T00:00:00.000Z"
        },
        {
            "id": "5f0efa72-f2b9-4b5d-9c1b-8f8f1e0b0c2e",
            "name": "Payment Link 2",
            "description": "This is a payment link for product 2",
            "amount": 50,
            "currency": "USD",
            "created_at": "2022-01-19T00:00:00.000Z",
            "updated_at": "2022-01-19T00:00:00.000Z"
        }
    ]
}

You can also pass in query parameters to filter the payment links returned such as status, created_at, updated_at, and limit.

Example:

const filters = {
    status: 'active',
    limit: 10
}

client.getAllPaymentLinks(filters).then((response) => {
    console.log(response)
}).catch((error) => {
    console.log(error)
})

Last updated