Quickstart

This guide will walk you through creating your first payment charge with the Shift4 Payments API.

Install SDK

First, install the Shift4 SDK for your preferred language:

npm

npm install @shift4/payments-sdk

pip

pip install shift4-payments

Create a charge

Here's how to create a simple charge:

Create a charge

import Shift4 from '@shift4/payments-sdk';

const shift4 = new Shift4('sk_test_your_key');

const charge = await shift4.charges.create({
  amount: 1999,
  currency: 'USD',
  description: 'Coffee mug',
  card: {
    number: '4242424242424242',
    expMonth: 12,
    expYear: 2025,
    cvc: '123',
  },
});

console.log(charge);

Handle response

The API returns a charge object with the transaction details:

Response

{
  "id": "char_test_abc123",
  "amount": 1999,
  "currency": "USD",
  "status": "successful",
  "captured": true,
  "description": "Coffee mug",
  "created": 1699564800
}

Next steps

Was this page helpful?