How to create unlimited payment widget
Last updated
Last updated
Before starting an integration please check our page for more info.
To accept an unlimited amount of payments for a product with customer-defined price you can use Unlimited Linked Payment Widget. It allows your client to choose the crypto currency he wants to pay you with.
After choosing the crypto currency the invoice will be automatically created for your client to pay.
Your client may also return back to Payment widget and choose another crypto currency to pay you with.
You can find more information about other features of Public API integration in our documentation:
To create a new Unlimited Linked Payment widget use the following endpoint: Create new Unlimited Linked payment widget (POST https://api.calypso.finance/api/v1/payment-widget/unlimited-linked/create
)
You can find the detailed description of all the parameters in the documentation:
Here we describe the most important ones.
cryptoCurrencies
- the list of available for payment crypto currencies.
description
- the description of product/service.
idempotencyKey
- a specific UUID for the Payment widget link which guarantees uniqueness of the request. It forms the link via client can access the payment widget.
externalId
- the unique custom ID to your Payment widget and all the future invoices created from it. It allows you to check the status of payment by this parameter after creation.
So to create a Payment widget without additional options you just have to send request:
Bash
Some additional options:
You can customize interface of your Payment widget by transmitting return_url
, support_url
and logo_url
fields.
By default the transaction fee for transferring the received money from the invoice address (created by Payment widget) to the merchant’s wallet is debited from merchant’s Hot Wallet address. If you want to use Calypso liquidity for paying the transaction fee you may transmit the value “true” to the parameter useLiquidity
.
If the creation was successful you would receive the response:
Response exampleJSON
Now after you’ve successfully created Payment widget you can send link for payment to your client. Link format: https://pay.calypso.finance/pay?widgetKey={idempotencyKey}
Payment widget link view:
After creating Unlimited Linked Payment widget you can receive information about it from the system.
The best way to do it is by tracking changes in invoices (created from your Payment widget) via Webhooks.
Another way is by manually requesting information about Payment widget and its invoices using API
After creating Unlimited Linked Payment widget you can receive information about it from the system. The best way to do it is by tracking changes in invoices (created from your Payment widget) via Webhooks.
As we mentioned earlier Payment widget automatically creates an invoice after your user chooses the currency he wants to pay with. So by tracking the state of created Invoice you can track the state of your payment.
To track the state of your created Invoice you can use Calypso Pay functionality which is called Webhooks.
Webhook is a way for an app to provide other applications with real-time information. The Webhooks API allows you to subscribe to events happening with your created objects (Invoices or Payouts) in Calypso. Rather than making an API call to check status of invoice or payout during processing, Calypso can send an HTTP request to an endpoint you configure.
First of all, to receive information about Invoice state change you need to create a subscription for system events which you want to track.
There are several types of events which you need to track in order to understand what is happening to your Invoices.
The main events are:
INVOICE_FUNDS_RECEIVED_FOR_INVOICE
The event shows if funds have been received to invoice wallet
We’ll look at more scenarios of using Webhooks in following sections of this guide.
To create a subscription for those events you can use the Create Webhook Public API endpoint: POST https://api.calypso.finance/api/v1/subscription/webhook/create
Bash
You can subscribe to all types of events if you specify value “INVOICE” in the notificationServiceTypes
field instead of enumeration all types of events in notificationEventTypes
.
In the response you will get:
JSON
After successful creation of subscription for Payment events and providing your client with Payment Widget link you can wait for your client to make payment.
To receive information about earlier created Unlimited Linked Payment widget you can use Get Unlimited Linked payment widget By ID endpoint (POST https://api.calypso.finance/api/v1/payment-widget/unlimited-linked/find
)
You can request widget by idempotencyKey
.
Example of the request by id
:
Bash
In response you will receive Payment widget data:
Response exampleJSON
The most important fields you need to pay attention to:
invoices
- list of all invoices created by your client using this Payment widget.
You may also request information about every invoice in the list.
To receive information about earlier created Invoice you can use Get a Specific Invoice endpoint (POST https://api.calypso.finance/api/v1/invoice
).
You can request invoice by id
or idempotencyKey
.
Example of the request by id
:
Bash
In response you will receive invoice data:
Response exampleJSON
The most important fields you need to pay attention to are:
totalDebitAmount
- total received amount of money to this invoice.
If client successfully paid the invoice you will receive webhook with type INVOICE_FUNDS_RECEIVED_FOR_INVOICE.
The example of webhook payload:JSON
You can understand that the invoice refers to Payment widget that you created earlier by looking at externalId
value. It will be the same value that you have set earlier for Payment widget during its creation.
To get detailed information about invoice you can use Get a Specific Invoice endpoint (POST https://api.calypso.finance/api/v1/invoice
) using idempotencyKey
, externalId
or parentExternalId
(id
in request).
You will see changes in the fields:
The value of totalDebitAmount
is changed to received payment amount.
That means that the money were sent by client and they were received to invoice wallet address (invoiceAddress
field).
After receiving money to invoice wallet address received money amount will be credited to the balance.
More detailed information about Calypso Webhooks functionality:
More info on Calypso Webhooks event types:
More info on Webhooks management in Calypso Pay system:
More info on Get Unlimited Linked payment widget By ID endpoint:
More info on Get a Specific Invoice endpoint: