Skip to content

Payment Demo

The first step to make a payment is to know your API keys. We will need the public key (starting with pk_) and the secret key (starting with sk_). Then let's add a card form into our website.

The button and the card form

Add the following code into your website's html.

<form method="post" action="{your-endpoint}">
    <div id="button-container"></div>

<script src=""></script>
    var everypay = Everypay('{your-public-key}');

    everypay.button('#button-container', {"amount": 1200});


  • Make sure to replace {your-endpoint} with a POST endpoint on your site.
  • Also, replace {your-public-key} with your key.

When the card details are entered into the card form, the script will append the card token into the form as hidden input named everypay_token and will submit the form on your backend.

Charging the card

Now, on your site's backend, you need to handle the post request created by the form.

This code below is written in PHP using Laravel and EveryPay's PHP SDK.

You can install the sdk using composer:

composer require everypay/everypay-php

Then, in our backend, we handle the form and make a request to the payments API.

// Controller Class 
use EveryPay\EveryPay;
use EveryPay\Payment;

public function postAction()
    $tokenFromForm = request('everypay_token');

    Everypay::$isTest = true; // only for sandbox

    $paymentRequest = Payment::create([
        'amount' => 1200,
        'token' => $tokenFromForm

    if (isset($paymentRequest->error)) {
        echo 'Error ' . $paymentRequest->error->code . ': ' . $re->error->message;
    } else {
        echo 'Payment was successful!';

Congratulations! You've just completed a test card payment.