āŠ—  Cancel before pay

Some flows require cancelling a payment link after creating it but before the customer has paid (e.g. customer abandoned cart, internal admin cancellation). The Cancel API rescinds the link and fires payment.canceled.

What to do

  1. Click Run scenario. We'll create a payment, immediately cancel it via the API, and you'll see both API responses below.
  2. Within ~1 minute, payment.canceled webhook arrives.
  3. If you tried to open the link's hosted-page URL after cancellation, the page would show the link is no longer active.

No customer interaction needed — runs entirely server-side.

The code

// Node.js
// 1. Create
const create = await fetch('https://app.sknpay.com/api/v1/payments', {
  method: 'POST',
  headers: { Authorization: 'Bearer ' + KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({ amount: 1000, currency: 'USD', description: 'Will cancel' }),
})
const payment = await create.json()

// 2. Cancel — idempotent, no-op if already terminal
await fetch(`https://app.sknpay.com/api/v1/payments/${payment.id}/cancel`, {
  method: 'POST',
  headers: { Authorization: 'Bearer ' + KEY },
})
// payment.canceled webhook fires automatically
<?php
// 1. Create
$ch = curl_init('https://app.sknpay.com/api/v1/payments');
curl_setopt_array($ch, [/* … as in Standard … */]);
$payment = json_decode(curl_exec($ch), true);

// 2. Cancel
$ch = curl_init('https://app.sknpay.com/api/v1/payments/' . $payment['id'] . '/cancel');
curl_setopt_array($ch, [
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST           => true,
  CURLOPT_HTTPHEADER     => ['Authorization: Bearer ' . getenv('SKNPAY_API_KEY')],
]);
curl_exec($ch);
// payment.canceled webhook fires automatically
# Python
# 1. Create
r = requests.post('https://app.sknpay.com/api/v1/payments', headers=H, json={'amount':1000,'currency':'USD','description':'Will cancel'})
payment = r.json()

# 2. Cancel
requests.post(f'https://app.sknpay.com/api/v1/payments/{payment["id"]}/cancel', headers=H)
# payment.canceled webhook fires automatically