LogoLogo
  • GENERAL
    • Introduction
    • Overview
    • Authentification
    • ENUM description
  • ACQUIRING
    • Customer wallets
    • Invoices
    • Onramp
  • EXCHANGE
    • Crypto exchange
  • PAYOUTS
    • Single Payout
    • Mass Payout
  • WEBHOOKS
    • Overview
    • Types of events
    • Webhook payload
    • Webhook sign check
  • GUIDES
    • General questions
      • What is Calypso Pay?
      • Which blockchains and tokens we support?
    • Calypso UI guides and questions
      • Introduction to Calypso Pay
      • Sandbox mode and limits
      • General
        • How to create new API key
        • How to create an additional account
        • How to add a new asset to account
        • How to add funds to your wallet
        • Protect your withdrawals with additional signatures
        • How to change your top-up address
        • How to use address book
        • How to set up auto currency conversion
        • How to transfer money within Calypso pay
        • Create a webhook
      • Accept Payments via UI
        • How to create an invoice via UI
        • Accept Payments FAQ
      • Make Payments via UI
        • How to create a single payout via UI
        • How to create mass payout via UI
        • Make Payments FAQ
      • Make Exchanges via UI
        • How to exchange one crypto asset to the other
      • Reports
        • How to get reports
        • Report contents description
    • Integration guides and questions
      • Get started with API
      • Use Customer purse via API
        • How create a customer
        • How to get a purse
        • How to get a transaction data
      • Accept Payments via API
        • How to create a Limited Invoice via API
        • How to create a Limited Fiat Invoice via API
        • How to create an Unlimited Invoice via API
        • How to manage interventions via API
        • How to embed invoice data to your payment page
      • Payment widget
        • How to create a limited fiat payment widget via API
        • How to create unlimited payment widget
        • How to embed a payment widget on a web page
      • Make Exchange via API
        • How to create a exchange
        • Get balance information via API
      • Make Payments via API
        • Get balance information via API
        • How to create a single payout via API
        • How to create a mass payout via API
  • API REFERENCE
    • Report API
    • Settlement Payout API
    • Webhook API
    • Payout API
    • Exchange API
    • Fiat API
    • User API
    • Rate API
    • Settlement Wallet API
    • Fiat withdrawal API
    • Account API
    • Currency API
    • Invoice API
    • Settlement Report API
    • Crypto to fiat API
    • Customer Purse API
    • Fiat deposit API
    • Payment Widget API
    • Models
Powered by GitBook
On this page
  • General API integration rules
  • Payment Widget
  • Limited Fiat Payment widget API integration
  • Create Single Fiat Payment widget
  • Tracking payment state
  • Successful Single Fiat invoice payment scenario
Export as PDF
  1. GUIDES
  2. Integration guides and questions
  3. Payment widget

How to create a limited fiat payment widget via API

PreviousPayment widgetNextHow to create unlimited payment widget

Last updated 3 days ago

General API integration rules

Before starting an integration please check our page for more info.

Payment Widget

Payment Widget is a functionality that allows you to create widget, using which your users will be able to pay for your products/services choosing the currency they’re most comfortable with.

The widget indicates the amount to be paid, the available cryptocurrencies and description of payment.

It uses Invoice functionality inside of it and allows you to customize the widget the way you want to use it.

Limited Fiat Payment widget API integration

To accept a single payment for a product with a fixed price when initial price specified in fiat currency you can use Single Fiat 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.

The invoice is paid in cryptocurrency but the pay amount is being recalculated every 15 minutes according to fiat amount value that you used during widget creation.

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:

Create Single Fiat Payment widget

To create a new Payment widget use the following endpoint: Create new Single Fiat payment widget (POST https://api.calypso.finance/api/v1/payment-widget/single-fiat/create)

Here we describe the most important ones.

  • fiatAmount - the amount of fiat money merchant wants to receive for a product/service.

  • fiatCurrency - the fiat currency of future payment. The pay amount in crypto recalculates every 15 minutes after the invoice creation according to this value.

  • description - the description of product/service.

  • cryptoCurrencies - the list of available for payment crypto currencies.

  • 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 for 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:

JSX

curl --location --request POST 'https://api.calypso.finance/api/v1/payment-widget/single-fiat/create' \
--header 'Key: <your_api_key>' \
--header 'Sign: <your_sign>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "timestamp": 13292792792,
    "account": "0xc195df92dd9db2a8f28e597981f113d6e7582f8b",
    "payload": {
        "description": "Single Fiat Payment Widget example",
        "fiatAmount": 100,
        "fiatCurrency": "EUR",
        "cryptoCurrencies": [
          "BTC", "ETH"
        ],
        "idempotencyKey": "5743852b-c182-4b70-8475-2c714c98fdde",
        "externalId": "unique_id_111222333"
    }
}'

Some additional options:

  • By default the Payment widget is available for 1 day. You can set custom expiration time of Payment widget by transmitting expiration field in request body but the expiration date may only be less than 30 days from the current moment. After this time the Payment widget will be unavailable for payment.

  • You can customize interface of your Payment widget by transmitting return_url, support_url and logo_url fields.

If the creation was successful you receive the response:

  • Response exampleJSON

    {
        "idempotencyKey": "5743852b-c182-4b70-8475-2c714c98fdde",
        "cryptoCurrencies": [
            "USDC"
        ],
        "widgetType": "SINGLE_FIAT",
        "widgetState": "IN_PROGRESS",
        "fiatCurrency": "EUR",
        "fiatAmount": 100,
        "description": "Single Fiat Payment Widget example",
        "externalId": "unique_id_111222333",
        "invoices": [],
        "createdDate": "2022-11-17T07:07:39.591444"
    }

Now after you’ve successfully created a Payment widget you can send link for payment to your client. Link format: https://pay.calypso.finance/pay?widgetKey={idempotencyKey}

Payment widget link view:

Tracking payment state

After creating Single Fiat 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

Receive information about your payments via Webhooks

As we mentioned earlier Payment widget automatically creates an invoice after 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.

  1. 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:

Event type
Description

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 the 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

curl --location --request POST 'https://api.calypso.finance/api/v1/subscription/webhook/create' \
--header 'Key: <your_api_key>' \
--header 'Sign: <your_sign>' \
--header 'Content-Type: application/json' \
--data-raw '{
  "timestamp": 13292792792,
  "account": "0xc195df92dd9db2a8f28e597981f113d6e7582f8b",
  "payload": {
    "notificationEventTypes": [
      "INVOICE_FUNDS_RECEIVED_FOR_INVOICE"
    ],
    "requestId": "bf9348b7-2c14-46d7-868c-b597852da319",
    "url": "Your App URL"
  }
}'

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

{
    "requestId": "bf9348b7-2c14-46d7-868c-b597852da319",
    "notificationEventTypes": [
      "INVOICE_FUNDS_RECEIVED_FOR_INVOICE"
    ],
    "url": "Your App URL",
    "createdDate": "2022-08-22T08:24:00.307535"
}
  1. 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.

Get data about specific Payment widget and related invoices

To receive information about earlier created Single Fiat Payment widget you can use Get Single Fiat payment widget By ID endpoint (POST https://api.calypso.finance/api/v1/payment-widget/single-fiat/find).

You can request widget by idempotencyKey.

Example of the request by id:

Bash

curl --location --request POST 'https://api.calypso.finance/api/v1/payment-widget/single-fiat/find' \
--header 'Key: <your_api_key>' \
--header 'Sign: <your_sign>' \
--header 'Content-Type: application/json' \
--data-raw '{
  "timestamp": 13292792792,
  "account": "0xc195df92dd9db2a8f28e597981f113d6e7582f8b",
  "payload": {
    "requestId": "daa596e4-623f-4a01-b47d-6159ffada299"
  }
}'

In response you will receive Payment widget data:

  • Response exampleJSON

    {
        "idempotencyKey": "daa596e4-623f-4a01-b47d-6159ffada299",
        "cryptoCurrencies": [
            "USDC"
        ],
        "widgetType": "SINGLE_FIAT",
        "widgetState": "IN_PROGRESS",
        "fiatCurrency": "EUR",
        "fiatAmount": 100,
        "description": "Single Fiat Payment Widget example",
        "externalId": "unique_id_111222333",
        "invoices": [
            {
                "invoiceId": "d9732536-acdd-41bd-87c3-ec40aeeb6a37",
                "cryptoCurrency": "USDC",
                "invoiceIdempotencyKey": "2b3ea2f9-a3c8-4cb6-a9cb-8c2e395cabe6",
                "invoiceExternalId": "unique_id_111222333"
            }
        ],
        "createdDate": "2022-11-17T07:07:39.593284"
    }

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 idor idempotencyKey.

Example of the request by id:

Bash

curl --location --request POST 'https://api.calypso.finance/api/v1/invoice' \
--header 'Key: <your_api_key>' \
--header 'Sign: <your_sign>' \
--header 'Content-Type: application/json' \
--data-raw '{
  "timestamp": 13292792792,
  "account": "0xc195df92dd9db2a8f28e597981f113d6e7582f8b",
  "payload": {
    "id": "d9732536-acdd-41bd-87c3-ec40aeeb6a37"
  }
}'

In response you will receive invoice data:

  • Response exampleJSON

    {
        "id": "d9732536-acdd-41bd-87c3-ec40aeeb6a37",
        "invoiceAddress": "0xc7721217b3e919eeb618c5155df278da58521aef",
        "type": "SINGLE",
        "amount": 0.001,
        "fee": 0.000042026017236,
        "totalDebitAmount": 0,
        "currency": "ETH",
        "state": "PENDING_PAYMENT",
        "description": "invoice for client 1",
        "createdDate": "2022-08-25T12:47:28.200475",
        "idempotencyKey": "1be6a518-6dcd-477d-96af-dd914b1300ce",
        "expiration": "2022-09-24T12:47:28.171538",
        "invoicePayments": [],
        "isInterventionResolved": true,
        "subscriptionEnabled": false
    }

The most important fields you need to pay attention to:

  • totalDebitAmount - received amount of money to this invoice.

Successful Single Fiat invoice payment scenario

If client successfully paid the invoice you will receive webhook with type INVOICE_FUNDS_RECEIVED_FOR_INVOICE.

  • The example of webhook payload:JSON

    {
      "requestId": "e505bbf7-0dcd-4097-b0c7-70372a5c68d3",
      "id": 20282,
      "createdDate": "2022-09-05T07:07:09.456422",
      "level": "SUCCESS",
      "service": "INVOICE",
      "eventType": "INVOICE_FUNDS_RECEIVED_FOR_INVOICE",
      "data": {
        "type": "INVOICE_FUNDS_RECEIVED_FOR_INVOICE",
        "amount": 125.81,
        "message": "invoice for client 1",
        "currency": "USDC",
        "externalId": "unique_id_111222333",
        "fiatAmount": {},
        "createdDate": "2022-09-05T07:03:52.984874",
        "description": "Single Fiat Payment widget example",
        "paymentDate": "2022-09-05T07:07:09.418771",
        "senderAddress": "0xf17366cf1aa135acfe6b2b91aacd3c95610fad12",
        "invoiceAddress": "0xg18966c0yaa175acfe6b2b89kbcd3c95610fad45",
        "idempotencyKey": "f24480cb-2e60-4f23-b585-169576370177",
        "transactionHash": "0x0ee4bfbac386849f63cab5f55c99f897ff2be8f13b732bc76c3c44bcfd82dfa2",
        "parentExternalId": "d9732536-acdd-41bd-87c3-ec40aeeb6a37"
      }
    }

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 or parentExternalId (id in request).

You will see changes in the fields:

  • The value of state is PAID.

  • The value of totalDebitAmount is changed to received payment amount.

That means that the money was sent by client and it was successfully received to the invoice address (invoiceAddress field).

After receiving the correct amount of money to the invoice address in Calypso system the money will be automatically credited to the merchant balance.

You may also get detailed information about Payment widget. For that you can use Get Single Fiat payment widget By ID endpoint (POST https://api.calypso.finance/api/v1/payment-widget/single-fiat/find) using idempotencyKey of Payment widget in the request.

You will see changes in the fields:

  • The value of widgetState is COMPLETED

You can find the detailed description of all the parameters in the documentation:

Or you can check a real example of payment widget or watch entire payment flow .

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 Single Fiat payment widget By ID endpoint:

widgetState - represents status of the Payment widget. More info about possible states in documentation:

More info on Get a Specific Invoice endpoint:

state - represents status of the invoice. More info about possible states in documentation:

Get started with API
Payment Widget
Create new Single Fiat Payment widget
here
here
Webhooks
Types of events
Webhook API
Get Single Fiat Payment widget by ID
Payment Widget
Get a specific Invoice
Limited Invoice