Skip to main content

Quickstart: Receive Your First Payment in 5 Minutes

This guide gets you from zero to a working payment in the sandbox. Copy-paste the code, run it, and see a live payment.

Prerequisites

  • WickiePay sandbox access (request here)
  • Your merchantId and API key pair (from the portal)
  • Node.js 18+ or Python 3.8+

Step 1: Create a Payment (30 seconds)

cURL

curl -X POST https://api.sandbox.layer1.com/api/v1/pay/summary \
-H "Content-Type: application/json" \
-H "Date: $(date -R)" \
-H "Signature-Input: sig=(\"@method\" \"@target-uri\" \"content-digest\" \"date\");keyid=\"YOUR_CLIENT_ID\";alg=\"rsa-v1_5-sha256\"" \
-H "Signature: sig=:YOUR_SIGNATURE:" \
-d '{
"merchantId": "YOUR_MERCHANT_ID",
"type": "IN",
"amount": 10.00,
"currency": "EUR",
"reference": "quickstart-001",
"expiryMinutes": 30,
"returnUrl": "https://yoursite.com/thanks"
}'

Node.js

const crypto = require('crypto');
const fs = require('fs');

// Load your private key
const privateKey = fs.readFileSync('api-client-key.pem', 'utf8');
const clientId = 'YOUR_CLIENT_ID';
const merchantId = 'YOUR_MERCHANT_ID';

async function createPayment() {
const url = 'https://api.sandbox.layer1.com/api/v1/pay/summary';
const body = JSON.stringify({
merchantId,
type: 'IN',
amount: 10.00,
currency: 'EUR',
reference: `test-${Date.now()}`,
expiryMinutes: 30,
returnUrl: 'https://yoursite.com/thanks',
});

// Sign the request (simplified — use your signing library)
const date = new Date().toUTCString();
const digest = crypto.createHash('sha256').update(body).digest('base64');
const signatureBase = `"@method": POST\n"@target-uri": ${url}\n"content-digest": sha-256=:${digest}:\n"date": ${date}`;
const signature = crypto.sign('sha256', Buffer.from(signatureBase), privateKey).toString('base64');

const res = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Date': date,
'Content-Digest': `sha-256=:${digest}:`,
'Signature-Input': `sig=("@method" "@target-uri" "content-digest" "date");keyid="${clientId}";alg="rsa-v1_5-sha256"`,
'Signature': `sig=:${signature}:`,
},
body,
});

const payment = await res.json();
console.log('Payment created!');
console.log('Status:', payment.status);
console.log('Pay here:', payment.redirectUrl);
console.log('Address:', payment.address?.address);
return payment;
}

createPayment();

Python

import hashlib
import base64
import json
import time
from cryptography.hazmat.primitives import hashes, serialization
from cryptography.hazmat.primitives.asymmetric import padding
import requests

# Load your private key
with open('api-client-key.pem', 'rb') as f:
private_key = serialization.load_pem_private_key(f.read(), password=None)

CLIENT_ID = 'YOUR_CLIENT_ID'
MERCHANT_ID = 'YOUR_MERCHANT_ID'

def create_payment():
url = 'https://api.sandbox.layer1.com/api/v1/pay/summary'
body = json.dumps({
'merchantId': MERCHANT_ID,
'type': 'IN',
'amount': 10.00,
'currency': 'EUR',
'reference': f'test-{int(time.time())}',
'expiryMinutes': 30,
'returnUrl': 'https://yoursite.com/thanks',
})

# Sign the request
date = time.strftime('%a, %d %b %Y %H:%M:%S GMT', time.gmtime())
digest = base64.b64encode(hashlib.sha256(body.encode()).digest()).decode()
sig_base = f'"@method": POST\n"@target-uri": {url}\n"content-digest": sha-256=:{digest}:\n"date": {date}'
signature = base64.b64encode(
private_key.sign(sig_base.encode(), padding.PKCS1v15(), hashes.SHA256())
).decode()

res = requests.post(url, data=body, headers={
'Content-Type': 'application/json',
'Date': date,
'Content-Digest': f'sha-256=:{digest}:',
'Signature-Input': f'sig=("@method" "@target-uri" "content-digest" "date");keyid="{CLIENT_ID}";alg="rsa-v1_5-sha256"',
'Signature': f'sig=:{signature}:',
})

payment = res.json()
print(f"Payment created! Status: {payment['status']}")
print(f"Pay here: {payment.get('redirectUrl')}")
return payment

create_payment()

Step 2: Complete the Payment (2 minutes)

The API returns a redirectUrl. Open it in your browser — you'll see the Hosted Payment Page.

In the sandbox, use a test wallet to send funds:

Step 3: Get Notified (automatic)

If you've set up a webhook listener, you'll receive:

{
"event": "payment.completed",
"data": {
"uuid": "pay-uuid-123",
"status": "COMPLETE",
"reference": "quickstart-001",
"displayCurrency": { "currency": "EUR", "amount": 10.00 },
"paidCurrency": { "currency": "USDC", "amount": 10.85 }
}
}

Step 4: Check the Payment (30 seconds)

curl https://api.sandbox.layer1.com/api/v1/pay/PAYMENT_UUID \
-H "Date: $(date -R)" \
-H "Signature-Input: ..." \
-H "Signature: ..."

What's Next?

You've created your first payment. Here's what to do next:

TaskGuide
Set up webhook notificationsWebhooks
Customize the checkout pageHosted Checkout
Accept recurring depositsPayment Channels
Go to productionSet Up Payment Processing
Need Help?

Your dedicated Solutions Engineer is available to help with integration. Contact us at wickiepay.com/contact.