Skip to main content

Overview

Card payments use hosted checkout. Simply redirect the user to the payment_url from the API response, and card input through 3D Secure authentication is handled automatically.

Payment Flow

1

Create Payment

Call POST /v1/payments to create a payment and obtain payment_url
2

Redirect

Redirect user to payment_url
3

Payment Complete

After payment, user is automatically redirected to your configured success_redirect_url or failure_redirect_url

Implementation Example

// 1. Create payment via API
const response = await fetch('https://api.sandbox.zafapay.com/v1/payments', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    amount: 1000,
    currency: 'usd'
  })
});

const payment = await response.json();

// 2. Redirect user to hosted checkout
window.location.href = payment.payment_url;

// 3. User completes payment on hosted page
// 4. User is redirected to success_redirect_url or failure_redirect_url

Authorization & Capture

For two-step payments (authorize first, capture later):
// Step 1: Authorize
const payment = await createPayment({
  amount: 1000,
  currency: 'usd',
  capture_method: 'manual'  // Authorization only
});

// Step 2: Capture (when ready to charge)
await fetch(`https://api.sandbox.zafapay.com/v1/payments/${payment.transaction_id}/capture`, {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
  }
});

Test Cards

Card NumberDescription
4242424242424242Successful payment
4000002500003155Requires 3D Secure
4000000000000002Declined
4000000000000259Chargeback
4000000000009995Insufficient funds
4000000000009987Lost card
4000000000009979Stolen card
4000000000000069Expired card
4000000000000127Incorrect CVC
4000000000000119Processing error
For complete API parameters and response details, see the Create Payment API reference.