Give Pay Documentation
API Reference

Checkout Examples

Example requests for different payment types

One-Off Payment

A single one-time donation or payment.

const response = await fetch('https://api.givepay.co/api/v1/payment-session/checkout', {
  method: 'POST',
  headers: {
    'Authorization': 'YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    payment_type: 'one_time',
    currency: 'GBP',
    line_items: [
      {
        quantity: 1,
        amount: 5000, // £50.00
        country_iso: 'GB',
        intention: 'General Donation',
        project: 'Winter Appeal 2024'
      }
    ],
    payer: {
      email: 'donor@example.com',
      first_name: 'John',
      last_name: 'Doe'
    },
    return_url: 'https://yoursite.com/thank-you'
  })
});

const { checkout_url } = await response.json();
window.location.href = checkout_url;

Daily Subscription

A recurring daily payment.

const response = await fetch('https://api.givepay.co/api/v1/payment-session/checkout', {
  method: 'POST',
  headers: {
    'Authorization': 'YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    payment_type: 'subscription',
    currency: 'GBP',
    subscription: {
      interval: 'day',
      interval_count: 1,
      name: 'Daily Giving'
    },
    line_items: [
      {
        quantity: 1,
        amount: 100, // £1.00/day
        intention: 'Daily Donation'
      }
    ],
    payer: {
      email: 'donor@example.com'
    },
    return_url: 'https://yoursite.com/subscription-confirmed'
  })
});

const { checkout_url } = await response.json();
window.location.href = checkout_url;

Monthly Subscription

A recurring monthly payment.

const response = await fetch('https://api.givepay.co/api/v1/payment-session/checkout', {
  method: 'POST',
  headers: {
    'Authorization': 'YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    payment_type: 'subscription',
    currency: 'GBP',
    subscription: {
      interval: 'month',
      interval_count: 1,
      name: 'Monthly Sponsorship'
    },
    line_items: [
      {
        quantity: 1,
        amount: 3000, // £30.00/month
        country_iso: 'GB',
        intention: 'Child Sponsorship',
        project: 'Education Program'
      }
    ],
    payer: {
      email: 'sponsor@example.com',
      first_name: 'Jane',
      last_name: 'Smith'
    },
    return_url: 'https://yoursite.com/subscription-confirmed'
  })
});

const { checkout_url } = await response.json();
window.location.href = checkout_url;

Mixed (Subscription + One-Time Fee)

A subscription with an additional one-time charge (e.g., setup fee or enrollment fee).

const response = await fetch('https://api.givepay.co/api/v1/payment-session/checkout', {
  method: 'POST',
  headers: {
    'Authorization': 'YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    payment_type: 'subscription',
    currency: 'GBP',
    subscription: {
      interval: 'month',
      interval_count: 1,
      name: 'Monthly Giving Circle'
    },
    line_items: [
      {
        quantity: 1,
        amount: 2500, // £25.00/month recurring
        intention: 'Monthly Giving',
        project: 'Giving Circle Fund'
      }
    ],
    one_time_items: [
      {
        quantity: 1,
        amount: 1000, // £10.00 one-time enrollment fee
        intention: 'Enrollment Fee'
      }
    ],
    payer: {
      email: 'member@example.com',
      first_name: 'David',
      last_name: 'Brown',
      phone: '+447700900456',
      billing_address: {
        country: 'GB',
        city: 'Manchester',
        line1: '45 High Street',
        postcode: 'M1 1AB'
      }
    },
    return_url: 'https://yoursite.com/enrollment-complete'
  })
});

const { checkout_url } = await response.json();
window.location.href = checkout_url;