Create a new payment - WalletConnect Pay Docs

Create a new payment

cURL

curl --request POST \
  --url https://api.pay.walletconnect.com/v1/payments \
  --header 'Api-Key: <api-key>' \
  --header 'Content-Type: application/json' \
  --header 'Merchant-Id: <merchant-id>' \
  --data '
{
  "amount": {
    "unit": "iso4217/USD",
    "value": "100"
  },
  "expiresAt": null,
  "referenceId": "ORDER-123"
}'

Python

import requests

url = "https://api.pay.walletconnect.com/v1/payments"

payload = {
    "amount": {
        "unit": "iso4217/USD",
        "value": "100"
    },
    "expiresAt": None,
    "referenceId": "ORDER-123"
}
headers = {
    "Api-Key": "<api-key>",
    "Merchant-Id": "<merchant-id>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)

JavaScript (Fetch)

const options = {
  method: 'POST',
  headers: {
    'Api-Key': '<api-key>',
    'Merchant-Id': '<merchant-id>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    amount: {unit: 'iso4217/USD', value: '100'},
    expiresAt: null,
    referenceId: 'ORDER-123'
  })
};

fetch('https://api.pay.walletconnect.com/v1/payments', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));

PHP

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.pay.walletconnect.com/v1/payments",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode([
    'amount' => [
        'unit' => 'iso4217/USD',
        'value' => '100'
    ],
    'expiresAt' => null,
    'referenceId' => 'ORDER-123'
  ]),
  CURLOPT_HTTPHEADER => [
    "Api-Key: <api-key>",
    "Content-Type: application/json",
    "Merchant-Id: <merchant-id>"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

Go

package main

import (
    "fmt"
    "strings"
    "net/http"
    "io"
)

func main() {

url := "https://api.pay.walletconnect.com/v1/payments"

payload := strings.NewReader("{\n  \"amount\": {\n    \"unit\": \"iso4217/USD\",\n    \"value\": \"100\"\n  },\n  \"expiresAt\": null,\n  \"referenceId\": \"ORDER-123\"\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Api-Key", "<api-key>")
    req.Header.Add("Merchant-Id", "<merchant-id>")
    req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
    body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))
}

Java (Unirest)

HttpResponse<String> response = Unirest.post("https://api.pay.walletconnect.com/v1/payments")
  .header("Api-Key", "<api-key>")
  .header("Merchant-Id", "<merchant-id>")
  .header("Content-Type", "application/json")
  .body("{\n  \"amount\": {\n    \"unit\": \"iso4217/USD\",\n    \"value\": \"100\"\n  },\n  \"expiresAt\": null,\n  \"referenceId\": \"ORDER-123\"\n}")
  .asString();

Ruby

require 'uri'
require 'net/http'

url = URI("https://api.pay.walletconnect.com/v1/payments")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Api-Key"] = '<api-key>'
request["Merchant-Id"] = '<merchant-id>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"amount\": {\n    \"unit\": \"iso4217/USD\",\n    \"value\": \"100\"\n  },\n  \"expiresAt\": null,\n  \"referenceId\": \"ORDER-123\"\n}"

response = http.request(request)
puts response.read_body

Responses

201
Payment created successfully

{
  "expiresAt": 1718236800,
  "gatewayUrl": "https://api.pay.walletconnect.com/pay_123",
  "isFinal": false,
  "paymentId": "pay_fea2ecc101KQFN7X7QP87PNA9SVQNAQAFP",
  "pollInMs": 1000,
  "status": "requires_action"
}

Error Responses
400

{
  "message": "<string>"
}

401

{
  "message": "<string>"
}

500

{
  "message": "<string>"
}

Authorizations

Headers

Body

Application/JSON

Example:

{ "unit": "iso4217/USD", "value": "100" }

Response