NAV Navbar
Logo
shell JavaScript PHP Java C#

Introduction

The PayDock platform is designed to be as simple and easy to use as possible.

There are a few different ways to interact with PayDock:

Getting started

You can get up and running using the PayDock API in just a few minutes.

Start by signing up for a sandbox account. This will give you access to the admin portal.

From the admin portal you can connect services. If you do not already have services to connect, you can usually sign up for test accounts You can see a list of some of the services we support here.

Then add a gateway in Gateway –> Add New:

Add Gateway

You can retrieve your API public and secret key from the admin portal in My Account –> API & Settings, which you’ll need to authenticate:

API public key

Once done, jump into one of our Recipes:

Key Concepts

There are a few key concepts that help understand how to get the most out of PayDock’s Platform

Concept Description
one-time token This is a token that represents payment information. This is often generated on client (using Paydock.js or Client SDK). One time tokens expire after 3 hours.
payment source A payment source represents a way of paying for something. This could be credit card details, bank account details or a PayPal account. There can be multiple payment sources associated with a customer.
gateway A gateway is a payment gateway of any type that payments are routed to, eg Braintree, PayPal.
vault The vault is PayDock’s PCI compliant storage vault of payment sources.
vault token A vault token is the reference code for a payment source, eg a credit card and expiry date
subscription A subscription is a scheduled payment plan for a customer.
sandbox A sandbox environment is a place where test API calls can be made without charging customers.
customer An individual who can make payments.
admin portal Web interface to manage your PayDock account

Endpoints

An endpoint is a unique URL that represents an object or collection of objects which serves as the base of all PayDock API interactions.

PayDock provides two different public environments to access. You can access the different environments from the following URLS:

Environment API Admin portal
Sandbox https://api-sandbox.paydock.com https://app-sandbox.paydock.com
Production https://api.paydock.com https://app.paydock.com

To set up API calls, prepend all calls with:

Throughout the documentation URLs are provided relative to these base URLs.

eg GET /v1/gateways for Sandbox, represents

GET https://api-sandbox.paydock.com/v1/gateways

eg GET /v1/gateways for Production, represents

GET https://api.paydock.com/v1/gateways

Authentication

Authenticate with our API is provided by providing either your API Public Key or API Secret Key, depending on how you are using the Paydock platform. These are 40 character strings which you can find in out web app: API public key

Authentication is managed slightly differently depending on how you’re connecting to Paydock.

Connecting to the Paydock from the client side is managed through the Public Key. There are a couple of ways to use the public key:

All other authentication is through the API Secret Key. This is used to secure server side calls:

Response codes / Error codes

PayDock’s API follows REST principles on status codes returned from our API.

Request type Response code Response description
POST 201 A charge (or any other resource) has been created successfully
GET 200 Call successful
POST 400 Error. The transaction has been declined because of error. Check the “error_summary” section for the details.
Any 408 The response from the .Net SDK when it can’t reach the API for some time
GET 404 The charge (or any other requested resource) not found
Any 403 Permission denied
Any 500 Server Error.

In addition, the API will generally return a detailed error message and any downstream errors. See the right panel for examples


"Gateway processing error"

"error_summary": {
        "message": "Transaction Declined",
        "code": "transaction_declined",
        "status_code": "05",
        "status_code_description": "Do not honour",
        "details": {
            "gateway_specific_code": "DECLINED",
            "gateway_specific_description": "The requested operation was not successful",
            "messages": [
                "Transaction Declined"
            ]
        }
    }

http code

Cause

Error Code

Error Structure

400

Internal validation

  • validation_error

  • required_error

  • unfulfilled_condition

{
message: string,
code: string,
details: {
path?: string,
messages: string[]
} }

400

gateway validation

  • gateway_error

  • insufficient_funds

  • сredit_card_invalid_or_expired

  • transaction_declined

  • transaction_declined_hard

  • system_error

  • fraud_warning

  • invalid_transaction_details

  • unknown

{
message: string,
code: string,
details: {
path?: string,
gateway_specific_code: string,
gateway_specific_description: string
messages: string[]
} }

400

gateway proccesing

  • gateway_error

  • insufficient_funds

  • сredit_card_invalid_or_expired

  • transaction_declined

  • transaction_declined_hard

  • system_error

  • fraud_warning

  • invalid_transaction_details

  • unknown

{ message: string,
code: string,
status_code: string,
status_code_description: string,
details: {
path?: string,
gateway_specific_code: string,
gateway_specific_description: string
messages: string[]
} }

400 - 599

other

  • unspecified_error

  • *

{
message: string,
code: string,
details: {
messages: string[]
} }

PayDock vault

"Example response with vault token"
{
  "status": 201,
  "error": null,
  "resource": {
    "type": "customer",
    "data": {
      "__v": 0,
      "created_at": "2017-01-24T23:28:14.045Z",
      "updated_at": "2017-01-24T23:28:14.045Z",
      "status": "active",
      "default_source": "5887e30d28e281756b883f64",
      "reference": "Fuga consequuntur sint ab magnam",
      "first_name": "Natalie",
      "last_name": "Foster",
      "email": "nwashington@gmail.com",
      "_id": "5887e30c28e281756b883f63",
      "payment_sources": [
        {
          "updated_at": "2017-01-24T23:28:14.045Z",
          "vault_token": "dd634c0c-ea3b-4d82-b7fb-5ef2d2949ff6",
          "gateway_id": "58377235377aea03343240cc",
          "card_name": "Natalie Foster",
          "expire_month": 1,
          "expire_year": 2019,
          "card_number_last4": "1111",
          "card_scheme": "visa",
          "ref_token": "53774915",
          "status": "active",
          "created_at": "2017-01-24T23:28:13.826Z",
          "_id": "5887e30d28e281756b883f64",
          "type": "card"
        }
      ],
      "statistics": {
        "total_collected_amount": 0,
        "successful_transactions": 0
      },
      "_service": {
        "default_gateway_id": "58377235377aea03343240cc"
      }
    }
  }
}

PayDock provides a PCI compliant vault for payment details. When the vault is enabled, all payment details are stored in the vault. The vault is enabled or disabled across a whole PayDock account, rather than for individual requests.

When the vault is enabled, any time a payment source is added, this information is stored in the vault. This most commonly happens when a payment source is added to a customer or a new customer is created. This is also visible in the response, which includes the id for the vault token, see example to the right (payment_sources -> vault_token).

Recipes

We are building a number of recipes that cover the most common use cases for the PayDock platform.

Recipes available:

Taking a single payment

The simplest use of the PayDock platform is also the most common: taking a payment. This example shows how to take a credit card payment using the Client SDK and Charges.

The best way to take a payment on PayDock is to:

  1. Generate an iFrame using the Client SDK that collects the payment details from a customer - this will convert the payment details to a one-time token.

  2. A “Charge” call will be submitted to PayDock’s API using the token and payment amount to make the payment.

Set up

You’ll need a page to display a payment form and your PayDock public key (How do I get my public key?).

Generating a one-time token using the Client SDK

<!DOCTYPE html>
<html lang="en">

    <head>
        <meta charset="UTF-8">
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
        <title>Donate to save puppies</title>
        <style>iframe {border: 0;width: 100%;height: 300px;}</style>
    </head>

    <body>

        <div class="container">
            <div class="col-sm-5">
                <h1>Donate to save puppies</h1>
                <form id="donation_form" method="post" action="form.php">
                    <div class="form-group">
                        <label>Donate </label>
                        <select class="form-control" name="donation">
                            <option value="100">$100</option>
                            <option value="50">$50</option>
                        </select>
                    </div>
                    <div class="form-group" id="iframeForm">
                    </div>
                    <input type="hidden" id="payment_source" name="payment_source">
                </form>
            </div>
        </div>

        <script src="https://app.paydock.com/v1/widget.umd.min.js"></script>
        <script>
            var widget = new paydock.HtmlWidget('#iframeForm', 'YOUR_PUBLIC_KEY', 'YOUR_GATEWAY_ID'); // public key, gateway_id here
            widget.setEnv('sandbox');
            widget.onFinishInsert('#payment_source', 'payment_source');

            widget.on('finish', function (data) {
                 document.forms[0].submit();
            });

            widget.load();
        </script>

    </body>
</html>

In this example we’ll use the Client SDK to create a one-time token, which we’ll use to make the payment.

In this case, our payment page lets someone select an amount to donate and provides their credit card details. The payment details on the donation page are collected through the PayDock iFrame, which means that the payment details are never sent to through to your server.

The Client SDK attaches the one time token to the form, then submits the form.

Note: The form will not process the transaction until the backend infrastructure is set up to handle the token.

Taking a payment

<?php
$chargeSvc = new Charges();
$res = $chargeSvc->create(10, "AUD")
    ->withToken($_POST["payment_source"])
    ->call();
?>

Next, to take a payment, use the one-time token to add the charge.

When a customer submits the form to make a donation, this sends the token that represents their payment details to the server.

From there, this token and the amount needs to be sent to PayDock to make a payment.

Note: Toggle PHP in the top right to see an example code snippet on the right

Creating a subscription with PayPal Checkout

Another common use case for the PayDock platform is driving subscriptions through the platform with PayPal into your website.

We’re going to use the PayDock Client SDK to generate a payment form with the PayPal Checkout button that we’re going to create a subscription with.

We’ve set the subscription to end after 12 transactions, however you can change this by referring to our subscription parameters.

Add PayPal Checkout Gateway

First, you must connect the PayPal Checkout gateway to PayDock.

Please refer to our PayPal Checkout integration guide.

Generating a one-time token through PayPal Checkout

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
  <title>Title</title>
</head>

<body>
  <div class="container">
    <div class="col-sm-5">

      <form id="button_form" method="post" action="https://app-1508376871.000webhostapp.com/form.php">

        <div class="form-group">
          <label>Amount</label>
          <select class="form-control" name="amount">
                  <option value="100">$100</option>
                  <option value="50">$50</option>
              </select>
        </div>

        <div class="form-group">
          <label>Interval</label>
          <select class="form-control" name="interval">
                  <option value="day">day</option>
                  <option value="week">week</option>
                  <option value="month">month</option>
                  <option value="year">year</option>
              </select>
        </div>

        <button type="button" id="button">
              <img src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" align="left" style="margin-right:7px;">
          </button>

        <input type="hidden" id="payment_source_token" name="payment_source_token" />

      </form>

      <input type="text" name="pst" />

    </div>
  </div>


  <script src="https://app.paydock.com/v1/widget.umd.js"></script>
  <script>
    var button = new paydock.CheckoutButton('#button', 'input public key', 'your paypal checkout gateway id');
    button.onFinishInsert('input[name="pst"]', 'payment_source_token');
    button.onFinishInsert('#payment_source_token', 'payment_source_token');
    button.onFinishInsert('#amount', 'amount');
    button.onFinishInsert('#interval', 'interval');

    button.setMeta({
      brand_name: 'Paydock',
      reference: '15',
      first_name: 'receiver-name',
      last_name: 'receiver-last-name',
      phone: '9379992'
    });

    button.on('finish', function(data) {
      console.log('on:finish', data);
      button_form.submit();
    });
  </script>
</body>

</html>

Use our Client SDK to generate a payment form that redirects the customer towards the external PayPal Checkout proces.

After the customer completes the PayPal Checkout process, we’ll generate a one time token that is used to create a subscription by calling the PayDock API.

The payment details on the donation page are collected through the PayPal Checkout process and then tokenised in PayDock meaning the payment details are never sent to your server.

Note: The form will not process the transaction until the backend infrastructure is set up to handle the token.

Creating the subscription

<?php
$subscriptionSvc = new Subscriptions();
$res = $subscriptionSvc->create(1$_POST["amount"], "AUD")
    ->withToken($_POST["payment_source_token"])
    ->withSchedule($_POST["interval"], 1, null, "2020-01-01")
    ->call();
    //You can change the end conditions - please see https://docs.paydock.com/#add-subscription
?>

Next, use the one-time token to create a subscription.

After a customer submits the form, we’ll call the PayDock API and create a subscription using the payment token generated in the previous step.

Note: Toggle PHP in the top right to see an example code snippet on the right

API Reference

The PayDock API is organized around REST. Our API has predictable, resource-oriented URLs, and uses HTTP response codes to indicate API errors. We use built-in HTTP features, like HTTP authentication and HTTP verbs, which are understood by off-the-shelf HTTP clients. JSON is returned by all API responses, including errors.

To make the API as explorable as possible, accounts have test mode and live mode API keys. There is no “switch” for changing between modes, just use the appropriate URL to perform a live or test transaction. Requests made with test mode credentials never hit the banking networks and incur no cost.

PayDock users can interact with the service in a number of ways.

Visit PayDock Postman documentation page:

Visit API Reference

Development SDKs

PayDock provides SDKs or libaries for different programming languages to make integration as simple as possible.

Client side

Client SDK

The Client SDK is our recommended solution for collecting payment details on your website.

Client SDK documentation

The Client SDK is also available through npm.

More detailed documentation on classes and methods available through npm - reference by class.

PayDock.js

PayDock.js is a legacy solution to tokenise credit card credentials and taking payments online. Our recommended solution is to use the Client SDK.

PayDock.js is a client side library for converting all Credit Card and Direct Debit credentials into one-time tokens and securely sending financial information through a web form.

PayDock.js documentation

PayDock iFrame

PayDock iFrame is a legacy solution for tokenising credit card information and sending it through to PayDock. Our recommended solution is to use the Client SDK.

iFrame documentation

php SDK

The php SDK is available through composer on Packagist.

It’s open source, with the code available on github. We welcome feedback on the SDK.

.Net SDK

The .Net SDK comes in 2 flavours: .Net 4.0 and .Net Core:

It’s open source, with the code available on github. We welcome feedback on the SDK.

Java SDK

The Java SDK is available from JCentre.

There are different dependency snippets to be inserted in your code based on your build settings (we support Gradle, Maven or Ivy).

It’s open source, with the code available on github. We welcome feedback on the SDK.

Android SDK

The Android SDK is available from JCentre.

There are different dependency snippets to be inserted in your code based on your build settings (we support Gradle, Maven or Ivy).

It’s open source, with the code available on github. We welcome feedback on the SDK.

Client-sdk

It is a solution for collecting and handling payment sources in secure way.

With SDK you can create a payment form widget as an independent part or insert use inside your form.

The SDK supports methods for customization of widget by your needs (styling, form fields, etc)

Other information

To work with the widget you will need public_key (see Authentication)

Also you will need added gateway (see API Reference by gateway)

Get started

Download from CDN

<script src="https://widget.paydock.com/sdk/latest/widget.umd.min.js"></script>
<script>
    var widget = new paydock.HtmlWidget('#tag', 'publicKey', 'gatewayId');
</script>

You should begin by including the library in your page.

Add this script tag to your page to get started with with the url below:

Compressed version for production https://widget.paydock.com/sdk/latest/widget.umd.min.js

Full version for development and debug https://widget.paydock.com/sdk/latest/widget.umd.js

Also can download library the production version or the development version

The library will always be available via the global variable paydock.

Also for more advanced use, the library has UMD format, thus can be used in requireJs, webpack, etc.

With package manager

// ES2015 / TypeScript

import { HtmlWidget } from '@paydock/client-sdk/widget';

let widget = new HtmlWidget('#selector', 'publicKey', 'gatewayId');
<script src="@paydock/client-sdk/bundles/widget.umd.min.js"></script>
<script>
    var widget = new paydock.HtmlWidget('#tag', 'publicKey', 'gatewayId');
</script>

To install with package manager, enter the following command:

npm install @paydock/client-sdk

You can use ES2015 or TypeScript modules

@paydock/client-sdk/widget

Also can use UMD module (global visibility, see above)

@paydock/client-sdk/bundles/widget.umd.js

@paydock/client-sdk/bundles/widget.umd.min.js

Widget

You can find description of all methods and parameters here

A payment form where it is possible to enter card data/bank accounts and then receive a one-time token for charges, subscriptions etc. This form can be customized, you can customize the fields and set styles. It is possible in real-time to monitor the actions of user with widget and get information about payment-source using events.

Widget simple example

Container

<div id="widget"></div>

You must create a container for the widget. Inside this tag, the widget will be initialized

Initialization

var widget = new paydock.HtmlWidget('#widget', 'publicKey');
widget.load();
// ES2015 | TypeScript

import { HtmlWidget } from '@paydock/client-sdk/widget';

var widget = new HtmlWidget('#widget', 'publicKey');
widget.load();

Then write only need 2 lines of code in js to initialize widget

Full example

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>iframe {border: 0;width: 100%;height: 300px;}</style>
</head>
<body>
    <form id="paymentForm">
        <div id="widget"></div>
        <input name="payment_source_token" id="payment_source_token" type="hidden">
    </form>
    <script src="https://app-sandbox.paydock.com/v1/widget.umd.js" ></script>
    <script>
        var widget = new paydock.HtmlWidget('#widget', 'publicKey');
        widget.interceptSubmitForm('#paymentForm');
        widget.onFinishInsert('input[name="payment_source_token"]', 'payment_source');
        widget.load();
    </script>
</body>
</html>

Widget advanced example

Customization

widget.setStyles({
        background_color: 'rgb(0, 0, 0)',
        border_color: 'yellow',
        text_color: '#FFFFAA',
        button_color: 'rgba(255, 255, 255, 0.9)',
        font_size: '20px'
    });

This example shows how you can customize to your needs and design

Customization from html

<div id="widget"
     widget-style="text-color: #FFFFAA; border-color: #yellow"
     title="Payment form"
     finish-text="Payment resource was successfully accepted"></div>

This example shows how you can set style and texts from html

Settings

widget.setRefId('id'); // your unique identifier to identify the data

widget.setFormFields(['phone', 'email']); // add additional fields for form of widget

widget.setSupportedCardIcons(['mastercard', 'visa']); // add icons of supported card types

This example shows how you can use a lot of other methods to settings your form

Full example

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>iframe {border: 0;width: 100%;height: 400px;}</style>
</head>
<body>
<form id="paymentForm">
    <div id="widget"
        widget-style="text-color: #FFFFAA; border-color: #yellow"
        title="Payment form"
        finish-text="Payment resource was successfully accepted"></div>
</form>

<script src="https://widget.paydock.com/sdk/latest/widget.umd.js" ></script>
<script>
    var widget = new paydock.HtmlWidget('#widget', 'publicKey', 'gatewayId');

    widget.setSupportedCardIcons(['mastercard', 'visa']);
    widget.setFormFields(['phone', 'email']);
    widget.setRefId('custom-ref-id');
    widget.interceptSubmitForm('#paymentForm');
    widget.onFinishInsert('input[name="payment_source_token"]', 'payment_source');z

    widget.load();
</script>
</script>
</body>
</html>

Payment sources widget

You can find description of all methods and parameters here

This widget provides a list of previously added (saved) payment-sources by customer_id or reference. The widget provides an opportunity to use events to track the process of selecting payment-sources and provide meta information about the payment-sources.

Payment-source requires a query_token that represents a pre-generated and secure token for limiting the list payment-sources, for a specific user or reference.

In order to generate this token, you need to send a GET request to getCustomerList where required query parameter must be id or reference. In response you get response.query_token which you can use in the widget.

Payment sources simple example

Container

<div id="list"></div>

You must create a container for the widget. Inside this tag, the widget will be initialized

Initialization

var list = new paydock.HtmlPaymentSourceWidget('#list', 'publicKey', 'queryToken');
list.load();
// ES2015 | TypeScript

import { HtmlPaymentSourceWidget } from '@paydock/client-sdk/widget';

var list = new HtmlPaymentSourceWidget('#list', 'publicKey', 'queryToken');
list.load();

Then write only need 2 lines of code in js to initialize widget

Full example

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>iframe {border: 0;width: 40%;height: 300px;}</style>
</head>
<body>
    <div id="list"></div>
    <script src="https://app-sandbox.paydock.com/v1/widget.umd.js" ></script>
    <script>
        var list = new paydock.HtmlPaymentSourceWidget('#list', 'publicKey', 'queryToken');
        list.load();
    </script>
</body>
</html>

Payment sources advanced example

Customization

list.setStyles({
    icon_size: 'small'
});

This example shows how you can customize to your needs and design

Settings


list.filterByTypes(['card', 'checkout']); // filter by any payment source types
list.filterByGatewayIds(['gateway1']); // also other filters

list.setRefId('id'); // your unique identifier to identify the data

list.setLimit(4); // Pagination elements will show if count of elements more then argument passed

list.onSelectInsert('input[name="ps_id"]', 'payment_source_id'); // insert one-time-token to your input after finish checkout

list.on('select', function(data) {
    console.log(data);
});

This example shows how you can use a lot of other methods to settings your form

Full example

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>iframe {border: 0;width: 40%;height: 300px;}</style>
</head>
<body>
    <div id="list"></div>
    <input type="text" name="ps_id" />
    <script src="https://app-sandbox.paydock.com/v1/widget.umd.js" ></script>
    <script>
        var list = new paydock.HtmlPaymentSourceWidget('#list', 'publicKey', 'queryToken');
        list.filterByTypes(['card', 'checkout']);
        list.filterByGatewayIds(['gateway1']);
        list.setRefId('id');
        list.setLimit(4);
        list.setStyles({
            icon_size: 'small'
        });

        list.load();

        list.onSelectInsert('input[name="ps_id"]', 'payment_source_id');
        list.on('select', function(data) {
            console.log(data);
        });
    </script>
</body>
</html>

Checkout button

You can find description of all methods and parameters here PayPal meta parameters description here Zipmoney meta parameters description here

This widget allows you to turn your button into a full Checkout Button. As a result, you will be able to receive a one-time token for charges, subscriptions etc. And other data given to the user by the payment gateway.

Checkout button simple example

Container

<button type="button" id="button">
    checkout
</button>

You must create a button to turn it into checkout-button

Initialization

var button = new paydock.PaypalCheckoutButton('#button', 'publicKey', 'gatewayId');
// ES2015 | TypeScript


var button = new PaypalCheckoutButton('#widget', 'publicKey');

Then write only need 2 lines of code in js to initialize widget

Full example

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <button type="button" id="button">checkout</button>
    <script src="https://widget.paydock.com/sdk/latest/widget.umd.js" ></script>
    <script>
        var button = new paydock.PaypalCheckoutButton('#button', 'publicKey');
    </script>
</body>
</html>

Checkout button advanced example

Optional methods

button.onFinishInsert('input[name="pst"]', 'payment_source_token'); // insert one-time-token to your input after finish checkout

button.setMeta({
       brand_name: 'Paydock',
       reference: '15',
       first_name: 'receiver-name',
       last_name: 'receiver-last-name',
       phone: '9379992'}); // settings for checkout pages

button.on('finish', function (data) { // Add handler of event
       console.log('on:finish', data);
});

This example shows how you can use a lot of other methods to settings your button

Full Paypal example

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form id="paymentForm">
    <button type="button" id="button">
        <img src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" align="left" style="margin-right:7px;">
    </button>
</form>

<input type="text" name="pst" />

<script src="https://widget.paydock.com/sdk/latest/widget.umd.js" ></script>
<script>
    var button = new paydock.PaypalCheckoutButton('#button', 'publicKey', 'gatewayId');
    button.onFinishInsert('input[name="pst"]', 'payment_source_token');
    button.setMeta({
           brand_name: 'Paydock',
           reference: '15',
           first_name: 'Joshua',
           last_name: 'Wood',
           phone: '0231049872'}); 

    button.on('finish', function (data) { 
           console.log('on:finish', data);
    });
</script>
</body>
</html>

Full ZipMoney example

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form id="paymentForm">
    <button type="button" id="button">
        <img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTVrrEYxDmq4WXv7hfHygKD9ltnOqv0K6soSAhmbKNllPNYWiLiJA" align="left" style="margin-right:7px;">
    </button>
</form>

<input type="text" name="pst" />

<script src="https://widget.paydock.com/sdk/latest/widget.umd.js" ></script>
<script>
    var button = new paydock.ZipmoneyCheckoutButton('#button', 'publicKey', 'gatewayId');
    button.onFinishInsert('input[name="pst"]', 'payment_source_token');
    button.setMeta("first_name": "Joshua",
       "tokenize": true,
       "last_name": "Wood",
       "email":"joshuawood@hotmail.com.au",
       "gender": "male",
       "charge": {
           "amount": "4",
           "currency":"AUD",
           "shipping_address": {
               "first_name": "Joshua",
               "last_name": "Wood",
               "line1": "Suite 660",
               "line2": "822 Ruiz Square",
               "country": "AU",
               "postcode": "3223",
               "city": "Sydney",
               "state": "LA"
           },
           "billing_address": {
               "first_name": "Joshua",
               "last_name": "Wood",
               "line1": "Suite 660",
               "line2": "test",
               "country": "AU",
               "postcode": "3223",
               "city": "Sydney",
               "state": "LA"
           },
           "items": [
               {
                   "name":"ACME Toolbox",
                   "amount":"2",
                   "quantity": 1,
                   "reference":"Fuga consequuntur sint ab magnam"
               },
               {
                   "name":"Device 42",
                   "amount":"2",
                   "quantity": 1,
                   "reference":"Fuga consequuntur sint ab magnam"
               }
           ]
       },

       "statistics": {
           "account_created": "2017-05-05",
           "sales_total_number": "5",
           "sales_total_amount": "4",
           "sales_avg_value": "45",
           "sales_max_value": "400",
           "refunds_total_amount": "21",
           "previous_chargeback": "true",
           "currency": "AUD",
           "last_login": "2017-06-01"
       }); 

    button.on('finish', function (data) { 
           console.log('on:finish', data);
    });
</script>
</body>
</html>

Full Aftepay example

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<button type="button" id="button">
    <img src="https://daepxvbfwwgd0.cloudfront.net/assets/logo_scroll-0c43312c5845a0dcd7a3373325da6402bc1d635d3415af28ed40d6c1b48e3d5c.png" align="left" style="margin-right:7px;">
</button>

<input type="text" name="pst" />

<script src="https://widget.paydock.com/sdk/latest/widget.umd.js" ></script>
<script>
    var button = new paydock.AfterpayCheckoutButton('#button', 'publicKey', 'gatewayId');

    button.onFinishInsert('input[name="pst"]', 'payment_source_token');
    button.setMeta({
        amount: "5",
        currency: "AUD",
        brand_name: 'Paydock',
        reference: '15',
        email: 'joshuawood@hotmail.com.au',
        hdr_img: 'https://media.licdn.com/mpr/mpr/AAEAAQAAAAAAAAy4AAAAJDFmZTk5ZjJjLTE0MWYtNDI5OS1hMmUwLWJhOTlhNzQ2MDFhZA.jpg',
        logo_img: 'https://media.licdn.com/mpr/mpr/AAEAAQAAAAAAAAy4AAAAJDFmZTk5ZjJjLTE0MWYtNDI5OS1hMmUwLWJhOTlhNzQ2MDFhZA.jpg',
        first_name: 'Joshua',
        last_name: 'Wood',
        address_line: 'Suite 660',
        address_line2: '822 Ruiz Square',
        address_city: 'Sydney',
        address_postcode: '2671',
        hide_shipping_address: '1',
        phone: '0231049872'});

    button.on('finish', function (data) { 
           console.log('on:finish', data);
    });
</script>
</body>
</html>

PayPal Integration

Our recommended approach for Paypal integration is to use our Client SDK. This handles most of the complexity of integrating Paypal into your plaform. You can implement PayPal manually, in the process below.

PayPal checkout allows your customers to pay using PayPal. The PayPal checkout process creates a one-time token that can be used to add a payment source to a customer, create a customer or charge a customer.

The process for taking a payment with PayPal checkout is: Paypal checkout

curl -X "POST https://api-sandbox.paydock.com/v1/payment_sources/external_checkout" \
     -H "x-user-secret-key: x-user-secret-key" \
     -H "Content-Type: application/json" \
     -d "{\"mode\":\"tsest\",\"type\":\"paypal\",\"gateway_id\":\"583d7c75a1723f941b7137f4\",\"success_redirect_url\":\"https://docs.paydock.com\",\"error_redirect_url\":\"https://docs.paydock.com/charges.php\",\"description\":\"My test PayDock description\"}"
var request = require('request');

request({
    url: 'https://api.paydock.com/v1/payment_sources/external_checkout',
    method: 'POST',
    body: {
        "mode": "test",
        "gateway_id":"583d7c75a1723f941b7137f4",
        "success_redirect_url":"https://docs.paydock.com",
        "error_redirect_url": "https://docs.paydock.com/charges.php",
        "description": "My test PayDock description"
    },
    headers: {
        'content-type' : 'application/json',
        'x-user-secret-key': 'user_secret_key'
    }
}, function(error, response, body){
    if(error) {
        console.log(error);
    } else {
        console.log(response.statusCode, body);
    }
});
<?php
$svc = new ExternalCheckout();
$response = $svc->create("test", "58bf55343c541b5b87f741bd", "https://wwww.success.com", "https://www.failure.com", "", [])
    ->call();
"Example of response (201)"

{
  "status": 200,
  "error": null,
  "resource": {
    "type": "payment_source",
    "data": {
      "checkout_type": "link",
      "link": "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-12D76527BK035913Y",
      "reference_id": "EC-12D76527BK035913Y",
      "mode": "test",
      "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0eXBlIjoicGF5cGFsIiwiZ2F0ZXdheV9pZCI6IjU4M2JlYjViYTIzMjc3ZjYxOTExZjg2YiIsImdhdGV3YXlfdHlwZSI6IlBheXBhbENsYXNzaWMiLCJzcGVjaWZpY0RhdGEiOnsiY2hlY2tvdXRfdG9rZW4iOiJFQy0xMkQ3NjUyN0JLMDM1OTEzWSJ9LCJtb2RlIjoidGVzdCIsImlhdCI6MTQ4MDQ1MjI5MH0.DN5eLG-VyAIcQJlkBRX0NHav5svPQ4jrM_u0V9QRD1I"
    }
  }
}

Checkout link redirects a user to PayPal website which will require them to accept the agreements for using PayPal to process further transactions. The Merchant should place this link on the site, so that the end user can accept the checkout token for further operations (create customers, charges, subscriptions, update customer payment sources).

POST /v1/payment_sources/external_checkout

Field Name Description Details
mode Parameter which determines PayPal account mode. Values: test, live String, optional
gateway_id ID of a PayDock gateway. Note: only a PayPal Express checkout gateway has ability to work with checkout tokens String, required
success_redirect_url URL to which customers will be redirected to after accepting agreements on the PayPal checkout page. After redirecting, PayPal will add query param “token=[some PayPal token here]”. In PayDock response this token is named as “reference_id”. See examples String, required
error_redirect_url URL to which customers will be redirected to after canceling operations or experiencing an error on the PayPal checkout page. After redirecting, PayPal will add query param “token=[some PayPal token here]”. In PayDock response this token is named as “reference_id”. See examples String, required
description Custom description that will be shown on a PayPal page when accepting the token String, optional
meta Object where can be specified optional information about customer Object, optional, optional
brand_name A label that overrides the business name in the PayPal account on the PayPal hosted checkout pages String, optional
reference Merchant Customer Service number displayed on the PayPal pages String, optional
email The consumer’s email String, optional
hdr_img URL for the image you want to appear at the top left of the payment page String, optional
logo_img A URL to your logo image String, optional
first_name The consumer’s given names String, optional
last_name The consumer’s surname String, optional
address_line Street address String, optional
address_line2 Second line of the address String, optional
address_city City String, optional
address_postcode Postcode String, optional
hide_shipping_address Determines whether PayPal displays shipping address fields on the PayPal pages String, optional
phone The consumer’s phone number in E.164 international notation (Example: +12345678901) String, optional

Create PayDock one-time token using PayPal checkout token

curl -X "POST https://api-sandbox.paydock.com/v1/payment_sources/tokens?public_key=[users_public_key]" \
     -H "Content-Type: application/json" \
     -d "{\"type\":\"checkout_token\",\"gateway_id\":\"583d78caa17233341b712bbc\",\"checkout_token\":\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0eXBlIjoicGF5cGFsIiwiZ2F0ZXdheV9pZCI6IjU4M2JlYjViYTIzMjc3ZjYxOTExZjg2YiIsImdhdGV3YXlfdHlwZSI6IlBheXBhbENsYXNzaWMiLCJzcGVjaWZpY0RhdGEiOnsiY2hlY2tvdXRfdG9rZW4iOiJFQy0xMkQ3NjUyN0JLMDM1OTEzWSJ9LCJtb2RlIjoidGVzdCIsImlhdCI6MTQ4MDQ1MjI5MH0.DN5eLG-VyAIcQJlkBRX0NHav5svPQ4jrM_u0V9QRD1I\"}"
var request = require('request');

request({
    url: 'https://api.paydock.com/v1/payment_sources/tokens?public_key=[users_public_key]',
    method: 'POST',
    body: {
        "type":"checkout_token",
        "gateway_id":"583d78caa17233341b712bbc",
        "checkout_token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0eXBlIjoicGF5cGFsIiwiZ2F0ZXdheV9pZCI6IjU4M2JlYjViYTIzMjc3ZjYxOTExZjg2YiIsImdhdGV3YXlfdHlwZSI6IlBheXBhbENsYXNzaWMiLCJzcGVjaWZpY0RhdGEiOnsiY2hlY2tvdXRfdG9rZW4iOiJFQy0xMkQ3NjUyN0JLMDM1OTEzWSJ9LCJtb2RlIjoidGVzdCIsImlhdCI6MTQ4MDQ1MjI5MH0.DN5eLG-VyAIcQJlkBRX0NHav5svPQ4jrM_u0V9QRD1I"
    },
    headers: {
        'content-type' : 'application/json'
    }
}, function(error, response, body){
    if(error) {
        console.log(error);
    } else {
        console.log(response.statusCode, body);
    }
});
<?php
$apiLink       = 'https://api-sandbox.paydock.com/v1/payment_sources/tokens?public_key=[users_public_key]';
$apiPublicKey  = 'user_public_key';

$query = http_build_query([
    'public_key'   => $apiPublicKey
]);

$data = json_encode([
    'type'                 => 'checkout_token',
    'gateway_id'           => '583d78caa17233341b712bbc',
    'checkout_token'       => 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0eXBlIjoicGF5cGFsIiwiZ2F0ZXdheV9pZCI6IjU4M2JlYjViYTIzMjc3ZjYxOTExZjg2YiIsImdhdGV3YXlfdHlwZSI6IlBheXBhbENsYXNzaWMiLCJzcGVjaWZpY0RhdGEiOnsiY2hlY2tvdXRfdG9rZW4iOiJFQy0xMkQ3NjUyN0JLMDM1OTEzWSJ9LCJtb2RlIjoidGVzdCIsImlhdCI6MTQ4MDQ1MjI5MH0.DN5eLG-VyAIcQJlkBRX0NHav5svPQ4jrM_u0V9QRD1I'
]);

$ch = curl_init();
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_URL, $apiLink . '?' . $query);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Content-Type: application/json",
    "Content-Length: ". strlen($data),
    "x-user-secret-key:". $apiKey,
]);

$res = json_decode(curl_exec($ch));
?>
"Example of response (201)"

{
  "status": 201,
  "error": null,
  "resource": {
    "type": "token",
    "data": "bb7fcdfc-1322-sdd8-adba-2c265adb8b25"
  }
}

Before initiating a call to create a one-time token for PayPal, the user must have created a PayPal checkout token using the checkout link. The response returns a one-time token that can be used to:

POST /v1/payment_sources/tokens?public_key=[users_public_key]

Field Name Description Details
type Type of payment source gateway to be created. Available values: “checkout_token” String, required
gateway_id Id of a gateway, that was previously added to PayDock String, required
public_key PayDock users public key String, required
checkout_token Token, that was created on previously step. String, required

Afterpay Integration

Afterpay checkout allows your customers to pay using Afterpay. The Afterpay checkout process creates a one-time token that can be used to add a direct payment.

Before allowing a customer to checkout with Afterpay, check the configuration for Afterpay to ensure that this order will be accepted successfully. You can do this by calling (Afterpay configuration)[#afterpay-configuration]. The configuration does not need to be checked before every order, but it should be checked regularly (eg every day).

Using the client SDK

The easiest way to do this is through the client SDK

Direct API integration

You can also integrate directly with the Paydock API, without using the client SDK.

The process for taking a payment with Afterpay checkout is:

curl -X "POST https://api-sandbox.paydock.com/v1/payment_sources/external_checkout" \
     -H "x-user-secret-key: x-user-secret-key" \
     -H "Content-Type: application/json" \
     -d "{\”mode\”:\”test\”, \”error_redirect_url\”: \”https://docs.paydock.com\”, \”success_redirect_url\”: \”https://google.com\”, \”type\”:\”afterpay\”, \”gateway_id\”:\”59003f15eccac620e61aad6c\”, \”meta\”: { \”amount\”: \”50\”, \”currency\”: \”AUD\”, \”reference\”: \”testreference\”, \”email\”: \”samwashington@gmail.com\”,  \”first_name\”: \”Samantha\”, \”last_name\”: \”Washington\”, \”address_line1\”: \”Suite 660\”, \”address_line2\”: \”822 Ruiz Square\”,  \”address_city\”: \”Lake Edward\”, \”address_state\”: \”NSW\”, \”address_postcode\”: \“1234\”,  \”address_country\”: \”Australia\”,  \”phone\”: \”040000000\”} }"
var request = require('request');

request({
    url: 'https://api.paydock.com/v1/payment_sources/external_checkout',
    method: 'POST',
    body: {
            "error_redirect_url": "https://docs.paydock.com",
            "success_redirect_url": "https://google.com",
            "gateway_id":"59003f15eccac620e61aad6c",
            "meta":
                {
                "amount": "20",
                "currency": "AUD",
                "items":[{
                    "name": "widget1",
                    "sku": "1234122346",
                    "quantity": 1,
                    "price": {
                       "amount": "10.00",
                        "currency": "AUD"
                     }
                    },
                    { "name": "widget2",
                      "sku": "1234122345",
                      "quantity": 1,
                      "price": {
                         "amount": "10.00",
                         "currency": "AUD"
                        }
                    }
                ],
                "reference": "Vitae commodi provident assumenda",
                "email": "samwashington@gmail.com",
                "first_name": "Samantha",
                "last_name": "Washington",
                "address_line1": "Suite 660",
                "address_line2": "822 Ruiz Square",
                "address_city": "Lake Edward",
                "address_state": "NSW",
                "address_postcode": "1234",
                "address_country": "Australia",
                "phone": "040000000"
                }
          },
    headers: {
        'content-type' : 'application/json',
        'x-user-secret-key': 'user_secret_key'
    }
}, function(error, response, body){
    if(error) {
        console.log(error);
    } else {
        console.log(response.statusCode, body);
    }
});
<?php
$svc = new ExternalCheckout();

$meta =  [
    'amount' => '50',
    'currency' => 'AUD',
    'reference' => 'Vitae commodi provident assumenda',
    'email' => 'samwashington@gmail.com',
    'first_name' => 'Samantha',
    'last_name' => 'Washington',
    'address_line1' => 'Suite 660',
    'address_line2' => '822 Ruiz Square',
    'address_city' => 'Lake Edward',
    'address_state' => 'NSW',
    'address_postcode' => '1234',
    'address_country' => 'Australia',
    'phone' => '040000000'
];

$reference = uniqid();
$response = $svc->create("test", "59714107fd3abd105fd8ea42",  "https://wwww.success.com", "https://www.failure.com", "", $meta, "", $reference)
    ->call();
?>
"Example of response (201)"

{
  "status": 200,
  "error": null,
  "resource": {
    "type": "payment_source",
    "data": {
      "link": "https://www-sandbox.secure-afterpay.com.au/checkout/?token=4a76e7gd007j2dfducnrhpiemd79q37ocbp8drlt0041mnbn9afd",
      "mode": "test",
      "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0eXBlIjoiY2hlY2tvdXRfdG9rZW4iLCJnYXRld2F5X2lkIjoiNTkwMDNmMTVlY2NhYzYyMGU2MWFhZDZjIiwiZ2F0ZXdheV90eXBlIjoiQWZ0ZXJwYXkiLCJzcGVjaWZpY0RhdGEiOnsiY2hlY2tvdXRfdG9rZW4iOiI0YTc2ZTdnZDAwN2oyZGZkdWNucmhwaWVtZDc5cTM3b2NicDhkcmx0MDA0MW1uYm45YWZkIn0sIm1vZGUiOiJ0ZXN0IiwiaWF0IjoxNDkzMjk3MjY3fQ.z5pva920TWoe9q4wqAFii97j4Y9OEG0q6nnNICPaxn0"
    }
  }
}

Checkout link redirects a user to Afterpay website which will require them to accept the agreements for using Afterpay to process transaction. The Merchant should place this link on the site, so that the end user can accept the checkout token for further operation (create charge).

POST /v1/payment_sources/external_checkout

Field Name Description Details
gateway_id ID of a PayDock gateway. Note: only “Afterpay” gateway has ability to work with this type of checkout tokens String, required
success_redirect_url URL to which customers will be redirected to after accepting agreements on the Afterpay checkout page. After redirecting, Afterpay will add query param “token=[some Afterpay token here]”. In PayDock response this token is named as “reference_id”. See examples String, required
error_redirect_url URL to which customers will be redirected to after canceling operations or experiencing an error on the Afterpay checkout page. After redirecting, Afterpay will add query param “token=[some Afterpay token here]”. In PayDock response this token is named as “reference_id”. See examples String, required
description Custom description that will be shown on a Afterpay page when accepting the token String, optional
meta Object with additional information, needed for particular gateway Object, optional
amount Amount to be payed String, required
currency Currency code String, optional
items Additional information of an order items Array, optional
name Product name String, required
sku Product SKU String, optional
quantity The quantity of the item Number, required
price The price of the item String, required
amount The amount of an item rounded to 2 decimal places Number, required
currency The currency is a ISO 4217 format value. Currently only AUD is supported String, required
email The consumer’s email String, optional
first_name The consumer’s given names String, optional
last_name The consumer’s surname String, optional
address_line1 Street address String, optional
address_line2 Second line of the address String, optional
address_city City String, optional
address_state State String, optional
address_postcode Postcode String, optional
address_country ISO 3166-1 country code String, optional
phone The consumer’s phone number in E.164 international notation (Example: +12345678901) String, optional

Create Afterpay one-time token using Afterpay checkout token

curl -X "POST https://api-sandbox.paydock.com/v1/payment_sources/tokens?public_key=[users_public_key]" \
     -H "x-user-secret-key: x-user-secret-key" \
     -H "Content-Type: application/json" \
     -d "{\"type\": \"checkout_token\" ,\"gateway_id\":\"583d7c75a1723f941b7137f4\",\"checkout_token\":\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0eXBlIjoicGF5cGFsIiwiZ2F0ZXdheV9pZCI6IjU4M2JlYjViYTIzMjc3ZjYxOTExZjg2YiIsImdhdGV3YXlfdHlwZSI6IlBheXBhbENsYXNzaWMiLCJzcGVjaWZpY0RhdGEiOnsiY2hlY2tvdXRfdG9rZW4iOiJFQy0xMkQ3NjUyN0JLMDM1OTEzWSJ9LCJtb2RlIjoidGVzdCIsImlhdCI6MTQ4MDQ1MjI5MH0.DN5eLG-VyAIcQJlkBRX0NHav5svPQ4jrM_u0V9QRD1I\"}"
var request = require('request');

request({
    url: 'https://api.paydock.com/v1/payment_sources/tokens?public_key=fdsrtk5jl83d7c75a1723f941b7137f4',
    method: 'POST',
    body: {
        "type": "checkout_token",
        "gateway_id":"583d78caa17233341b712bbc",
        "checkout_token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0eXBlIjoicGF5cGFsIiwiZ2F0ZXdheV9pZCI6IjU4M2JlYjViYTIzMjc3ZjYxOTExZjg2YiIsImdhdGV3YXlfdHlwZSI6IlBheXBhbENsYXNzaWMiLCJzcGVjaWZpY0RhdGEiOnsiY2hlY2tvdXRfdG9rZW4iOiJFQy0xMkQ3NjUyN0JLMDM1OTEzWSJ9LCJtb2RlIjoidGVzdCIsImlhdCI6MTQ4MDQ1MjI5MH0.DN5eLG-VyAIcQJlkBRX0NHav5svPQ4jrM_u0V9QRD1I"
    },
    headers: {
        'content-type' : 'application/json'
    }
}, function(error, response, body){
    if(error) {
        console.log(error);
    } else {
        console.log(response.statusCode, body);
    }
});
<?php
$apiLink       = 'https://api-sandbox.paydock.com/v1/payment_sources/tokens';
$apiKey        = 'user_secret_key';
$apiPublicKey  = 'user_public_key';

$query = http_build_query([
    'public_key'   => $apiPublicKey
]);

$data = json_encode([
    'type'                 => 'checkout_token',
    'gateway_id'           => '583d78caa17233341b712bbc',
    'checkout_token'       => 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0eXBlIjoicGF5cGFsIiwiZ2F0ZXdheV9pZCI6IjU4M2JlYjViYTIzMjc3ZjYxOTExZjg2YiIsImdhdGV3YXlfdHlwZSI6IlBheXBhbENsYXNzaWMiLCJzcGVjaWZpY0RhdGEiOnsiY2hlY2tvdXRfdG9rZW4iOiJFQy0xMkQ3NjUyN0JLMDM1OTEzWSJ9LCJtb2RlIjoidGVzdCIsImlhdCI6MTQ4MDQ1MjI5MH0.DN5eLG-VyAIcQJlkBRX0NHav5svPQ4jrM_u0V9QRD1I'
]);

$ch = curl_init();
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_URL, $apiLink . '?' . $query);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Content-Type: application/json",
    "Content-Length: ". strlen($data),
    "x-user-secret-key:". $apiKey,
]);

$res = json_decode(curl_exec($ch));
?>
"Example of response (201)"

{
  "status": 201,
  "error": null,
  "resource": {
    "type": "token",
    "data": "bb7fcdfc-1322-sdd8-adba-2c265adb8b25"
  }
}

Before initiating a call to create a one-time token for Afterpay, the user must have created a Afterpay checkout token using the checkout link. The response returns a one-time token that can be used to:

POST /v1/payment_sources/tokens?public_key=[users_public_key]

Field Name Description Details
type Type of payment source gateway to be created. Use checkout_token for case, when token created on previous step in PayDock. Use external_checkout_token for token, that was created and accepted on gateway side String, required
gateway_id Id of a gateway, that was previously added to PayDock String, required
public_key PayDock users public key String, required
checkout_token Token, that was created on previous step (used with type - checkout_token) or generated and accepted on gateways side (used with type - external_checkout_token) . String, required

Afterpay Configuration

curl -X "GET https://api-sandbox.paydock.com/v1/gateways/[afterpay_gateway_id]/config" \
     -H "x-user-secret-key: x-user-secret-key" \
     -H "Content-Type: application/json"
var request = require('request');

request({
    url: 'https://api-sandbox.paydock.com/v1/gateways/[afterpay_gateway_id]/config',
    method: 'GET',
    headers: {
        'content-type' : 'application/json',
        'x-user-secret-key': 'user_secret_key'
    }
}, function(error, response, body){
    if(error) {
        console.log(error);
    } else {
        console.log(response.statusCode, body);
    }
});
<?php
$apiLink = 'https://api-sandbox.paydock.com/v1/gateways/[afterpay_gateway_id]/config';
$apiKey  = 'user_secret_key';

$ch = curl_init();
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_URL, $apiLink);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
  "Content-Type: application/json",
  "x-user-secret-key:". $apiKey,
]);

$res = json_decode(curl_exec($ch));
?>
"Example of response (200)"

{
    "status": 200,
    "error": null,
    "resource": {
        "type": "configs",
        "data": [
            {
                "type": "PAY_BY_INSTALLMENT",
                "description": "Pay over time",
                "maximumAmount": {
                    "amount": "1000.00",
                    "currency": "AUD"
                }
            }
        ]
    }
}

Retrieve the configuration from Afterpay to confirm the maximum amount allowed for a transaction. This should be called regularly (eg every day).

GET https://api-sandbox.paydock.com/v1/gateways/[afterpay_gateway_id]/config

Other features

You can also use other standard requests from the Paydock API to work with Afterpay transactions including:

Zip Money Integration

ZipMoney checkout allows your customers to pay using ZipMoney or ZipPay. The checkout process creates a one-time token that can be used to add a direct payment.

The process includes the customer logging in or signing up for ZipMoney or ZipPay.

ZipMoney will allow you to store payment details, without needing the customer to log in again. This needs to be approved by ZipMoney for your account. If tokenisation is enabled for your account, you can through tokenize = true to enable.

We also recommend that you send through as many parameters as possible, as it is more likely that transactions will be approved with more information.

When a new account is being created, it might not be immediately approved. See Refer Process for more details.

Using the client SDK

The easiest way to do this is through the client SDK, which handles the process of displaying a login window through to creating a payment token. Once you have a token, you can use that to either save the payment details or create a payment, see Client SDK Documentation.

Direct API integration

We recomment that the client SDK should be used with ZipMoney. However you can also directly integrate with the PayDock API.

The process for taking a payment with ZipMoney checkout is:

curl -X "POST https://api-sandbox.paydock.com/v1/payment_sources/external_checkout" \
     -H "x-user-secret-key: x-user-secret-key" \
     -H "Content-Type: application/json" \
     -d "{\"mode\": \"test\",\"gateway_id\":\"59637d35f2aa0c136b0128e2\",\"redirect_url\":\"https://docs.paydock.com\",\"reference\": \"transaction_reference_number\",\"meta\": {\"first_name\": \"Samantha\",\"last_name\": \"Washington\",\"tokenize\": true,\"shipping_address\": { \"first_name\": \"Samantha\", \"last_name\": \"Washington\", \"line1\": \"Suite 660\", \"country\": \"AU\", \"postcode\": \"2000\", \"city\": \"Sydney\", \"state\": \"NSW\" }, \"billing_address\": { \"first_name\": \"Samantha\", \"last_name\": \"Washington\", \"line1\": \"Suite 660\", \"country\": \"AU\", \"postcode\": \"2000\", \"city\": \"Sydney\", \"state\": \"NSW\" },\"amount\": \"4\", \"currency\":\"AUD\",\"reference\":\"transaction_reference\",\"email\":\"curtischarles@diaz-brown.net.au\",\"items\": [{\"name\":\"ACME Tollbox\",\"amount\":\"2\",\"quantity\": 1,\"reference\":\"sds\"},{\"name\":\"Device 42\",\"amount\":\"2\",\"quantity\": 1,\"reference\":\"sds1\"}],\"statistics\": {\"account_created\": \"2017-05-05\",\"sales_total_number\": \"5\",\"sales_total_amount\": \"4\",\"sales_avg_value\": \"45\",\"sales_max_value\": \"400\",\"refunds_total_amount\": \"1\",\"previous_chargeback\": \"false\",\"currency\": \"AUD\",\"last_login\": \"2017-06-01\"}},\"description\": \"Vitae commodi provident assumenda\"}"
var request = require('request');

request({
    url: 'https://api.paydock.com/v1/payment_sources/external_checkout',
    method: 'POST',
    body: {
            "mode": "test",
            "gateway_id":"59637d35f2aa0c136b0128e2",
            "redirect_url":"https://docs.paydock.com",
            "reference": "transaction_reference_number",
            "meta": {
                "first_name": "Samantha",
                "last_name": "Washington",
                "email":"curtischarles@diaz-brown.net.au",
                "tokenize": true,
                 "description": "Vitae commodi provident assumenda",
                "charge": {
                    "shipping_address": {
                        "first_name": "Samantha",
                        "last_name": "Washington",
                        "line1": "Suite 660",
                        "country": "AU",
                        "postcode": "2000",
                        "city": "Sydney",
                        "state": "NSW"
                    },
                    "billing_address": {
                        "first_name": "Samantha",
                        "last_name": "Washington",
                        "line1": "Suite 660",
                        "country": "AU",
                        "postcode": "2000",
                        "city": "Sydney",
                        "state": "NSW"
                    },
                    "amount": "4",
                    "currency":"AUD",            
                    "items": [{
                        "name":"ACME Toolbox",
                        "amount":"2",
                        "quantity": 1,
                        "reference":"Fuga consequuntur sint ab magnam"
                    },
                    {
                        "name":"Device 42",
                        "amount":"2",
                        "quantity": 1,
                        "reference":"Fuga consequuntur sint ab magnam"
                    }],
                },
                "statistics": {
                    "account_created": "2017-05-05",
                    "sales_total_number": "5",
                    "sales_total_amount": "4",
                    "sales_avg_value": "45",
                    "sales_max_value": "400",
                    "refunds_total_amount": "1",
                    "previous_chargeback": "false",
                    "currency": "AUD",
                    "last_login": "2017-06-01"
                }
            },
        },
    headers: {
        'content-type' : 'application/json',
        'x-user-secret-key': 'user_secret_key'
    }
}, function(error, response, body){
    if(error) {
        console.log(error);
    } else {
        console.log(response.statusCode, body);
    }
});
<?php
$svc = new ExternalCheckout();

$meta =  [
    "first_name"=> "Samantha",
    "last_name"=> "Washington",
    "email"=>"curtischarles@diaz-brown.net.au",
    "tokenize"=> true,
    "description"=> "Vitae commodi provident assumenda",
    "charge"=> [
        "shipping_address"=> [
            "first_name"=> "Samantha",
            "last_name"=> "Washington",
            "line1"=> "Suite 660",
            "country"=> "AU",
            "postcode"=> "2000",
            "city"=> "Sydney",
            "state"=> "NSW"
        ],
        "billing_address"=> [
            "first_name"=> "Samantha",
            "last_name"=> "Washington",
            "line1"=> "Suite 660",
            "country"=> "AU",
            "postcode"=> "2000",
            "city"=> "Sydney",
            "state"=> "NSW"
        ],
        "amount"=> "4",
        "currency"=>"AUD",
        "items"=> [[
            "name"=>"ACME Tollbox",
            "amount"=>"2",
            "quantity"=> 1,
            "reference"=>"Fuga consequuntur sint ab magnam"
        ],
        [
            "name"=>"Device 42",
            "amount"=>"2",
            "quantity"=> 1,
            "reference"=>"Fuga consequuntur sint ab magnam"
        ]],
    ],
    "statistics"=> [
        "account_created"=> "2017-05-05",
        "sales_total_number"=> "5",
        "sales_total_amount"=> "4",
        "sales_avg_value"=> "45",
        "sales_max_value"=> "400",
        "refunds_total_amount"=> "1",
        "previous_chargeback"=> "false",
        "currency"=> "AUD",
        "last_login"=> "2017-06-01"
    ]
];

$reference = uniqid();
$response = $svc->create("test", "599a76529c1d950790167453", "", "", "https://www.redirecturl.com", $meta, "", $reference)
    ->call();
?>
"Example of response (201)"

{
  "status": 200,
  "error": null,
  "resource": {
    "type": "payment_source",
    "data": {
      "link": "https://www-sandbox.secure-Zip Money.com.au/checkout/?token=4a76e7gd007j2dfducnrhpiemd79q37ocbp8drlt0041mnbn9afd",
      "mode": "test",
      "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0eXBlIjoiY2hlY2tvdXRfdG9rZW4iLCJnYXRld2F5X2lkIjoiNTkwMDNmMTVlY2NhYzYyMGU2MWFhZDZjIiwiZ2F0ZXdheV90eXBlIjoiQWZ0ZXJwYXkiLCJzcGVjaWZpY0RhdGEiOnsiY2hlY2tvdXRfdG9rZW4iOiI0YTc2ZTdnZDAwN2oyZGZkdWNucmhwaWVtZDc5cTM3b2NicDhkcmx0MDA0MW1uYm45YWZkIn0sIm1vZGUiOiJ0ZXN0IiwiaWF0IjoxNDkzMjk3MjY3fQ.z5pva920TWoe9q4wqAFii97j4Y9OEG0q6nnNICPaxn0"
    }
  }
}

Checkout link redirects a user to Zip Money website which will require them to accept the agreements for using Zip Money to process transaction or create a new account. When this link is clicked the user can accept the checkout token for further operation (create charge).

When you create the checkout link, some of the information is optional. However providing as much information as possible will mean a new registration is more likely to be approved.

If someone is registering for the for a new account, their registration can be:

Referals require special handling, see Refer Process

POST /v1/payment_sources/external_checkout

Field Name Description Details
mode Parameter which determines Zip Money account mode. Values: ‘test’, ‘live’ String, optional
gateway_id ID of a PayDock gateway. Note: this will only work for gateways that are either Zip Money / Zip Pay String, required
redirect_url URL to which customers will be redirected to after signing into Zip Money / Zip Pay or registering for a new account. After redirecting, Zip Money will add query param “checkoutid=[some Zip Money token here]”. In PayDock response this token is named as “reference_id”. See examples String, required
description Custom description that will be shown on a Zip Money page when accepting the token String, optional
meta Object with additional information Object, required
first_name First name for the customer String, required
last_name Last name for the customer String, required
phone The consumer’s phone number in E.164 international notation (Example: +12345678901) String, optional
tokenize Controls whether to tokenize the Zip Money / Zip Pay account, defaults to ‘false’ Boolean, optional
email The consumer’s email String, required
gender Customer’s gender String, optional
date_of_birth Birthday of the customer String, optional
charge Charge information Object, required
amount Amount to be paid Float, required
currency Currency code String, required
items Collection of order items Object, required
name Name of the item String, required
amount Amount of the item String, required
quantity Quantity of the item Integer, required
type Type of the item, values can be: ‘sku’, ‘tax’, ‘shipping’, ‘discount’ String, optional
reference Reference of the item String, optional
item_uri Url of the item in your store String, optional
image_url Url of the image in your store String, optional
shipping_address Object with shipping address details Object, required
first_name Shipping first name String, optional
last_name Shipping last name String, optional
line1 Shipping address line 1 String, required
line2 Shipping address line 2 String, optional
city Shipping city String, required
state Shipping state String, required
postcode Shipping postcode String, required
country Shipping country String, required
billing_address Object with billing address details Object, optional
first_name Billing first name String, optional
last_name Billing last name String, optional
line1 Billing address line 1 String, required
line2 Billing address line 2 String, optional
city Billing city String, required
state Billing state String, required
postcode Billing postcode String, required
country Billing country String, required

Create Zip Money one-time token using Zip Money checkout token

curl -X "POST https://api-sandbox.paydock.com/v1/payment_sources/tokens?public_key=[users_public_key]" \
     -H "x-user-secret-key: x-user-secret-key" \
     -H "Content-Type: application/json" \
     -d "{\"type\": \"checkout_token\" ,\"gateway_id\":\"583d7c75a1723f941b7137f4\",\"checkout_token\":\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0eXBlIjoicGF5cGFsIiwiZ2F0ZXdheV9pZCI6IjU4M2JlYjViYTIzMjc3ZjYxOTExZjg2YiIsImdhdGV3YXlfdHlwZSI6IlBheXBhbENsYXNzaWMiLCJzcGVjaWZpY0RhdGEiOnsiY2hlY2tvdXRfdG9rZW4iOiJFQy0xMkQ3NjUyN0JLMDM1OTEzWSJ9LCJtb2RlIjoidGVzdCIsImlhdCI6MTQ4MDQ1MjI5MH0.DN5eLG-VyAIcQJlkBRX0NHav5svPQ4jrM_u0V9QRD1I\"}"
var request = require('request');

request({
    url: 'https://api.paydock.com/v1/payment_sources//tokens?public_key=fdsrtk5jl83d7c75a1723f941b7137f4',
    method: 'POST',
    body: {
        "type": "checkout_token",
        "gateway_id":"583d78caa17233341b712bbc",
        "checkout_token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0eXBlIjoicGF5cGFsIiwiZ2F0ZXdheV9pZCI6IjU4M2JlYjViYTIzMjc3ZjYxOTExZjg2YiIsImdhdGV3YXlfdHlwZSI6IlBheXBhbENsYXNzaWMiLCJzcGVjaWZpY0RhdGEiOnsiY2hlY2tvdXRfdG9rZW4iOiJFQy0xMkQ3NjUyN0JLMDM1OTEzWSJ9LCJtb2RlIjoidGVzdCIsImlhdCI6MTQ4MDQ1MjI5MH0.DN5eLG-VyAIcQJlkBRX0NHav5svPQ4jrM_u0V9QRD1I"
    },
    headers: {
        'content-type' : 'application/json'
    }
}, function(error, response, body){
    if(error) {
        console.log(error);
    } else {
        console.log(response.statusCode, body);
    }
});
<?php
$apiLink       = 'https://api-sandbox.paydock.com/v1/payment_sources/tokens';
$apiKey        = 'user_secret_key';
$apiPublicKey  = 'user_public_key';

$query = http_build_query([
    'public_key'   => $apiPublicKey
]);

$data = json_encode([
    'type'                 => 'checkout_token',
    'gateway_id'           => '583d78caa17233341b712bbc',
    'checkout_token'       => 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0eXBlIjoicGF5cGFsIiwiZ2F0ZXdheV9pZCI6IjU4M2JlYjViYTIzMjc3ZjYxOTExZjg2YiIsImdhdGV3YXlfdHlwZSI6IlBheXBhbENsYXNzaWMiLCJzcGVjaWZpY0RhdGEiOnsiY2hlY2tvdXRfdG9rZW4iOiJFQy0xMkQ3NjUyN0JLMDM1OTEzWSJ9LCJtb2RlIjoidGVzdCIsImlhdCI6MTQ4MDQ1MjI5MH0.DN5eLG-VyAIcQJlkBRX0NHav5svPQ4jrM_u0V9QRD1I'
]);

$ch = curl_init();
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_URL, $apiLink . '?' . $query);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Content-Type: application/json",
    "Content-Length: ". strlen($data),
    "x-user-secret-key:". $apiKey,
]);

$res = json_decode(curl_exec($ch));
?>
"Example of response (201)"

{
  "status": 201,
  "error": null,
  "resource": {
    "type": "token",
    "data": "bb7fcdfc-1322-sdd8-adba-2c265adb8b25"
  }
}

Before initiating a call to create a one-time token for Zip Money, the user must have created a Zip Money checkout token using the checkout link. The response returns a one-time token that can be used to:

POST /v1/payment_sources/tokens?public_key=[users_public_key]

Field Name Description Details
type Type of payment source gateway to be created. Use checkout_token for case, when token created on previous step in PayDock. Use external_checkout_token for token, that was created and accepted on gateway side String, required
gateway_id Id of a gateway, that was previously added to PayDock String, required
public_key PayDock users public key String, required
checkout_token Token, that was created on previous step (used with type - checkout_token) or generated and accepted on gateways side (used with type - external_checkout_token) . String, required

Zip Money Refer Process

In some cases when a new account is registered, it might not be possible to make an immediate approval. In this case, if this is approved, the user will get an email with a link to confirm their new account. This link will redirect them to the success_redirect_url configured in the checkout link. It’s important that this URL contains enough information for them to continue the checkout. For example, this should include the id for the shopping cart for the user.

From there, the process is similar to a standard checkout flow, Create a Paydock token then use that token to make the payment.

Other features

You can also use other standard requests from the Paydock API to work with ZipMoney transactions including:

PayDock.js

We do not recommend using PayDock.js to take payments - this is a legacy solution.

Our recommended approach of collecting payment details is to use our Client SDK.

Only if Client SDK is not an option should Paydock.js be used to collect payment details.

PayDock.js is a client side library for converting all Credit Card and Direct Debit credentials into one-time tokens and securely sending information from a web form. Using this library, you can avoid sending credit card or bank account details to your server, reducing your PCI compliance requirements.

This library is a wrapper around the PayDock API and provides a javascript friendly interface to creating tokens.

The overall process is: Paydock.js token

Quick start

Paydock.setPublicKey('YOUR_API_PUBLIC_KEY');
Paydock.setSandbox(true); // false is default value

It’s easy to start using PayDock.js. Just add the following script to your website, set the endpoint and public key and start making calls.

<script type="text/javascript" src="https://app.paydock.com/v1/paydock.min.js"></script>

Setting Customer public key

Your must set your Public Key before using Paydock.js to identify the website when communicating with PayDock.

Credentials can be gathered from the Customer Account page on the PayDock Admin Portal.

Paydock.setPublicKey('YOUR_API_PUBLIC_KEY');

API endpoints

Production

Use this method in script to send to Production endpoint

Paydock.setSandbox(false); // Default value.

Sandbox

Use this method in script to send to Sandbox endpoint

Paydock.setSandbox(true);

One-time token

CreateToken converts sensitive card data into one-time tokens which you can use to safely use to trigger operations related pass to your Customers such as creating charges, subscription, new Customers, or when updating the customer payment_source of a current customer.

You can create one-time tokens using either credit card or debit card details (see examples).

// create token with credit card
Paydock.createToken({
    gateway_id: "a133695479f51cdd1e2fc66b56455884215",
    type: "card",
    card_name: "Houston Willian",
    card_number: "4200000000000000",
    expire_month: "01",
    expire_year: "2019",
    card_ccv: "123",
    first_name: "Houston",
    last_name:"Willian"
    email: "houston@domain.com"},
    function (token, status) { // success callback
        console.log('token', token);
    },
    function (res, status) { // error callback
        console.log('errors', res);
    }
);

// create token with debit card
Paydock.createToken({
    gateway_id: "a133695479f51cdd1e2fc66b56455884215",
    type: "bsb",
    account_name: "Houston Willian",
    account_number: "1234",
    account_bsb: "123123",
    first_name: "Houston",
    last_name:"Willian"
    email: "houston@domain.com"},
    function (token, status) { // success callback
        console.log('token', token);
    },
    function (res, status) { // error callback
        console.log('errors', res);
    }
);

Parameters

Field Name Description Details
account_name Customer account name. Parameter required when using Direct Debit only String, required for bsb
account_bsb Customer bank state branch number. Parameter required when using Direct Debit only String, required for bsb
account_number Number of Customer account. Parameter required when using Direct Debit only Integer, required for bsb
account_routing Number of Customer account. BSB/Routing/SWIFT/IBAN Number. Integer, required for bank account
account_holder_type Account type (‘personal’ or ‘business’) Integer, required for bank account
account_bank_name Name of account bank Integer, required for bank account
gateway_id ID of a gateway in PayDock system. String, required
card_name Name on credit card String, required for credit card
card_number Credit card number Integer, required for credit card
expire_month Month of the credit card expiry Integer, required for credit card
expire_year Year of the credit card expiry Integer, required for credit card
card_ccv Security code on the back side of the card Integer, required for credit card
type Values are “card” or “bsb”. By default PayDock is using “card” type String, optional
first_name First name String, optional
last_name Last name String, optional
email Email String, optional

JQuery example

This example uses jquery to map the elements of the form to the data to be sent through using paydock.js.

The form includes customer details (email, phone etc), which are optional when creating a token.

Finally the form appends a hidden element, storing the one-time token in temp_token form field. This would need to be handled server side to create a customer, take a payment or create a subscription.

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Paydock-js</title>
    </head>
    <body>
        <table width="100%">
            <tr>
                <td>
                    <form name="payment_source" method="post" action="form.php">
                        <label>
                            <input type="text" name="gateway_id"/>
                            gateway_id *
                        </label>
                        <br/>
                        <label>
                            <input type="text" name="card_name"/>
                            card_name *
                        </label>
                        <br/>
                        <label>
                            <input type="text" name="card_number"/>
                            card_number *
                        </label>
                        <br/>
                        <label>
                            <input type="text" name="expire_month"/>
                            expire_month *
                        </label>
                        <br/>
                        <label>
                            <input type="text" name="expire_year"/>
                            expire_year *
                        </label>
                        <br/>
                        <label>
                            <input type="text" name="card_ccv"/>
                            card_ccv *
                        </label>
                        <br/>
                        <label>
                            <input type="text" name="first_name"/>
                            first_name *
                        </label>
                        <br/>
                        <label>
                            <input type="text" name="last_name"/>
                            last_name *
                        </label>
                        <br/>
                        <label>
                            <input type="text" name="email"/>
                            email *
                        </label>
                        <br/>
                        <label>
                            <input type="text" name="phone"/>
                            phone
                        </label>
                        <br/>
                        <label>
                            <input type="text" name="address_line1"/>
                            address_line1
                        </label>
                        <br/>
                        <label>
                            <input type="text" name="address_line2"/>
                            address_line2
                        </label>
                        <br/>
                        <label>
                            <input type="text" name="address_city"/>
                            address_city
                        </label>
                        <br/>
                        <label>
                            <input type="text" name="address_state"/>
                            address_state
                        </label>
                        <br/>
                        <label>
                            <input type="text" name="address_country"/>
                            address_country
                        </label>
                        <br/>
                        <label>
                            <input type="text" name="address_postcode"/>
                            address_postcode
                        </label>
                        <br/>
                        <button type="submit">Send</button>
                    </form>
                </td>
            </tr>
        </table>

        <script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
        <script src="https://app.paydock.com/v1/paydock.min.js"></script>
        <script language="text/javascript">
            // Token creation

            (function(form) {
                var form = $('form[name="payment_source"]');

                form.on('submit', function(event) {
                    Paydock.setPublicKey('YOUR_API_PUBLIC_KEY');

                    var formData = {};
                    form.serializeArray().map( function(input) {
                        formData[input.name] = input.value;
                    });

                    Paydock.createToken(
                        formData,
                        function (token, status) {
                            form.append($('<input type="hidden" name="temp_token" />').val(token));
                            form.get(0).submit();
                        },
                        function (res, status) {
                            $('#error').html(JSON.stringify(res));
                        }
                    );

                    event.preventDefault();
                });
            })();
        </script>
    </body>
</html>

iFrame

We do not recommend using this iFrame widget to take payments - this is a legacy solution.

Our recommended approach of collecting payment details is to initialise the iFrame through our Client SDK.

Our Client SDK wraps some of the complexity of creating an iframe in an easy to use javascript library. Only if you cannot use the Client SDK should you implement the iFrame manually via the process below.

The iFrame is a solution for collecting and handling payment sources in secure way. There are two steps to the iFrame configuration.

The overall process is:

iFrame token

First you need to generate a URL for your iframe, which you can do through our admin interface or by making calls to our API.

Once you have a iframe in place, you can collect the payment details from a number of sources:

Creating configuration token from the Web application

You can generate an iframe configuration token through the PayDock Admin Portal: iFrame token

Create configuration token with an API call

curl -X "POST https://api-sandbox.paydock.com/v1/remote-action/configs" \
     -H "x-user-secret-key: x-user-secret-key" \
     -H "Content-Type: application/json" \
     -d "{\"purpose\":\"payment_source\",\"predefined_fields\": {\"gateway_id\":\"1\",\"type\":\"card\"},\"defined_form_fields\": [\"first_name\",\"last_name\",\"email\",\"phone\",\"address_line1\",\"address_line2\",\"address_country\",\"address_city\",\"address_postcode\"]}"
var request = require('request');

request({
    url: 'https://api-sandbox.paydock.com/v1/remote-action/configs',
    method: 'POST',
    body: {
        "purpose": "payment_source",
        "defined_form_fields": [
            "first_name",
            "last_name",
            "email",
            "phone",
            "address_line1",
            "address_line2",
            "address_country",
            "address_city",
            "address_postcode"
        ],
        "allowed_response_data": {
            "url": ["payment_source"],
            "event": ["payment_source"]
        },
        "webhook_destination": "https://mywebsite.com/my-endpoint",
        "success_redirect_url": "https://docs.paydock.com",
        "error_redirect_url": "https://docs.paydock.com",
        "fields_validation": true,
        "supported_card_types": ['ausbc', 'visa', 'mastercard', 'diners', 'japcb', 'laser', 'solo', 'discover', 'amex'],
        "hidden_elements": ['submit_button', 'tabs'],
        "predefined_fields": {
            "gateway_id": "1",
            "type": "card"
        }
    },
    headers: {
        'content-type' : 'application/json',
        'x-user-secret-key': 'user_secret_key'
    }
}, function(error, response, body){
    if(error) {
        console.log(error);
    } else {
        console.log(response.statusCode, body);
    }
});
<?php
$apiLink = 'https://api-sandbox.paydock.com/v1/remote-action/configs';
$apiKey  = 'user_secret_key';

$data = json_encode([
    'purpose'               => 'payment_source',
    'predefined_fields'     => [
        'gateway_id'    => '58377235377aea03343240cc',
        'type'          => 'card' 
    ],
    'defined_form_fields'   => [
        'first_name',
        'last_name',
        'email',
        'phone',
        'address_line1',
        'address_line2',
        'address_country',
        'address_city',
        'address_postcode' 
    ],
    'webhook_destination'   => 'https://mywebsite.com/my-endpoint',
    'success_redirect_url'  => 'https://docs.paydock.com',
    'error_redirect_url'    => 'https://docs.paydock.com',
    'fields_validation'    => true,
    'supported_card_types'   => [
        'ausbc',
        'visa',
        'mastercard',
        'diners',
        'japcb',
        'laser',
        'solo',
        'discover',
        'amex' 
    ],
    'hidden_elements'   => [
            'submit_button',
            'tabs'
    ]
]);

$ch = curl_init();
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_URL, $apiLink);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Content-Type: application/json",
    "Content-Length: ". strlen($data),
    "x-user-secret-key:". $apiKey,
]);

$res = json_decode(curl_exec($ch));
?>
"Example of response (200)"

{
  "status": 200,
  "error": null,
  "resource": {
    "type": "configurationToken",
    "data": {
      "configuration_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwdXJwb3NlIjoicGF5bWVudF9zb3VyY2UiLCJwcmVkZWZpbmVkX2ZpZWxkcyI6eyJnYXRld2F5X2lkIjoiNTgxYzc1M2E4ZjUxNTY0NzIzNjYzZmU3IiwidHlwZSI6ImNhcmQifSwid2ViaG9va19kZXN0aW5hdGlvbiI6Imh0dHBzOi8vcmVxdWVzdGIuaW4vYmxhYmxhIiwiZGVmaW5lZF9mb3JtX2ZpZWxkcyI6WyJmaXJzdF9uYW1lIiwibGFzdF9uYW1lIiwiZW1haWwiLCJwaG9uZSIsImFkZHJlc3NfbGluZTEiLCJhZGRyZXNzX2xpbmUyIiwiYWRkcmVzc19jb3VudHJ5IiwiYWRkcmVzc19jaXR5IiwiYWRkcmVzc19wb3N0Y29kZSJdLCJpYXQiOjE0NzgyNzE0NTd9.YP-cAKsC3_pPBmuQdD17zHNj8B6dZ1SILj86h8IeQBQ"
    }
  }
}

Rather than using the PayDock Admin portal, you can automate creating a configuration token using our API. This is useful for custom usages of the iframe.

POST /v1/remote-action/configs

Field Name Description Details
purpose Purpose of iFrame form. Available parameters: ‘payment_source’ string, required
webhook_destination Destination, where customer will receive all successful responses. Response will contain “data” object with “payment_source” parameter. Parameter “payment_source” used as “token” in future requests and needed for string, required
allowed_response_data Object containing event information to send Object optional
url Array of parameters to send on redirect url, allowed values are ‘payment_source’. Pass empty array to avoid sending any events Array optional
event Array of parameters to send on javascript events, allowed values are ‘payment_source’. In case of empty array will be set as default Array optional
success_redirect_url URL to which the Customer will be redirected to after the processed operation String, optional
error_redirect_url URL to which the Customer will be redirected to if an error is triggered in the process of operation String, optional
predefined_fields Object with required information Object, required
gateway_id ID of a gateway connected to PayDock String, required
type Type of payment source which shows in iFrame form. Parameters : “card”, “bsb”. String, required
defined_form_fields Array with iFrame form field, which will be shown in form Array, required
first_name first_name String, optional
last_name last_name String, optional
email email String, optional
phone</span phone String, optional
address_line1 address_line1 String, optional
address_line2 address_line2 String, optional
address_state address_state String, optional
address_country address_country String, optional
address_city address_city String, optional
address_postcode address_postcode String, optional
account_bank_name account_bank_name available in case when “type” is bank account String, optional
account_bsb account_bsb available in case when “type” is bank account String, optional
account_holder_type account_holder_type available in case when “type” is bank account String, optional
account_routing account_routing available in case when “type” is bank account String, optional
account_type account_type available in case when “type” is bank account String, optional

Styling iFrame form

//for live mode use  'https://widget.paydock.com/remote-action?'
var url = 'https://widget-sandbox.paydock.com/remote-action?';

//  use several tokens for showing several payment source types
addParamToUrl('public_key', 'asdsdafdsglhewurewfjds0');
addParamToUrl('configurationToken', 'dfsdfsdfsdiFRAMECONFIGTOKENfsdfdsfdf');

addParamToUrl('finish_text', 'black');
addParamToUrl('background_color', 'black');
addParamToUrl('border_color', 'black');
addParamToUrl('form_values', 'user_name: John');

addParamToUrl('ref_id', 'testRefernce');

function addParamToUrl (param, value) {
  sandbox_mode_url += param + '=' +encodeURIComponent(value) + '&';
}
<?php
$url = 'https://widget-sandbox.paydock.com/remote-action';

$query = http_build_query([
    'public_key'          => 'public_key',
    'configuration_token' => 'configuration_token',
    'finish_text'         => 'black',
    'background_color'    => 'black',
    'border_color'        => 'black'
    'form_values'        => 'user_name: John'
    //.......
]);

$resultUrl = $url . '?' . $query;

print_r($resultUrl);
?>

Styles for the iFrame can be configured as encoded URL parameters. Examples as follows:

Field Name Description Details
background_color Color of a form background. Value could be in several types. Example: “black” or “#000000” or “rgb(0,0,0) or rgba(0,0,0,1)” String, required
text_color Color of a form text. Value could be in several types. Example: “black” or “#000000” or “rgb(0,0,0) or rgba(0,0,0,1)” String, required
public_key PayDock users public key String, required
configuration_token Token of iFrame configuration that was created in previous step. Using configuration with 1 payment source type will not show name of iFrame tab. String, required
configuration_tokens Tokens of iFrame configuration that was created in previous step. This parameter is needed only when using several configuration tokens (several payment source types, such as “card” or “bank_account”). Pass value to this parameter, separated by “,”. Each token will be shown in a separate tab inside the Customer iFrame. Values for this parameter generated in step “Create configuration token” (please, see above). In Examples tab, Customer can see how to use several token values. Array, optional
title Title of an iFrame form String, optional
border_color Color of all borders in a form. Value could be in several types. Example: “black” or “#000000” or “rgb(0,0,0) or rgba(0,0,0,1)” String, optional
button_color Color of a button in a form. Value could be in several types. Example: “black” or “#000000” or “rgb(0,0,0) or rgba(0,0,0,1)” String, optional
error_color Color of message text, when getting error. Value could be in several types. Example: “black” or “#000000” or “rgb(0,0,0) or rgba(0,0,0,1)” String, optional
success_color Color of message text, when operation success. Value could be in several types. Example: “black” or “#000000” or “rgb(0,0,0) or rgba(0,0,0,1)” String, optional
finish_text Custom text after successful completion of the operation String, optional
ref_id Custom value for identify result of processed operation String, optional
fields_validation Boolean value in case when it is true will be shown server validation for fields String, optional
supported_card_types Collection of available payment cards. Will be shown list of images above iframe Array, optional
hidden_elements Field for setting names of elements which can be hidden (e.g. ‘submit_button, tabs’) Array, optional
form_values Query string where can be set values and params which can be set as default for fields String, optional

Events sent from iFrame form

"Example of events and data that iframe sends"

  {
    "event": "afterLoad",
    "purpose": "payment_source",
    "message_source": "widget.paydock",
    "ref_id": "testRef"
  }
  {
    "event": "validationError",
    "purpose": "payment_source",
    "message_source": "widget.paydock",
    "ref_id": "testRef"
  }
  {
    "event": "submit",
    "purpose": "payment_source",
    "message_source": "widget.paydock",
    "ref_id": "testRef"
  }
  {
    "event": "finish",
    "purpose": "payment_source",
    "message_source": "widget.paydock",
    "ref_id": "testRef",
    "payment_source" : "162bfd33-212f-4546-8127-f9596e37d4d1"
  }

Events are fired throughout the lifecycle of the iFrame. Each event includes an “event.data” object containing data about the event. Note: “payment_source” can be configured to be disabled.

The following events are fired:

Event Description
afterLoad immediately after the iFrame has loaded
submit when the form is submitted
validationError when there is an error in the form
finish when all fields are filled correctly and token is created and returned
if (window.addEventListener) {
    window.addEventListener("message", listener);
} else {
    // IE8
    window.attachEvent("onmessage", listener);
}

function listener(event) {
    console.log('message', event.data);
    console.log('message - json parse', JSON.parse(event.data));
    //  event.data is equal to one of the event objects { "event": "finish", "purpose": "payment_source", "message_source": "widget.paydock", "ref_id": "testRef"}

}

"jquery function to get event"

$(window).on('message', listener);

function listener(event) {
    console.log('message', event.data);
    console.log('message - json parse', JSON.parse(event.data));
    //  event.data is equal to one of the event objects { "event": "finish", "purpose": "payment_source", "message_source": "widget.paydock", "ref_id": "testRef"}

}

Get and handle a redirect

By default, the iframe will not include the one-time token on the redirect. It can be configured to send this through the admin inteface or by setting the parameter in the API.

When a request is redirected, it will include “payment_source” in the URL.

Get and handle webhook result

"Example of response of webhook"

{
    "data": {
        "payment_source": "162bfd33-212f-4546-8127-f9596e37d4d1",
        "custom_reference": "testref",
        "configuration_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwdXJwb3NlIjoicGF5bWVudF9zb3VyY2UiLCJwcmVkZWZpbmVkX2ZpZWxkcyI6eyJ0eXBlIjoiY2FyZCIsImdhdGV3YXlfaWQiOiI1ODEwNDFhYWFmNDZlZGIzMGMxZmE1OTkifSwid2ViaG9va19kZXN0aW5hdGlvbiI6Imh0dHBzOi8vcmVxdWVzdGIuaW4vcGNmYWl4cGMiLCJzdWNjZXNzX3JlZGlyZWN0X3VybCI6IiIsImVycm9yX3JlZGlyZWN0X3VybCI6IiIsImRlZmluZWRfZm9ybV9maWVsZHMiOltdLCJpYXQiOjE0Nzg1MzMzOTJ9.AINNuIWd5of3bPw9V8bcg7xi6vLMsFRdXoqLf7Rjk-A"
    },
    "signature": "c67de0091aae55ebe432309f957f42f39e93beb71f5d38267b4dc521b8db53cf"
}

In result of iFrame process customer will get webhook with “data” object and “signature” value.

The signature can be used to verify the integrity of the data. To check if the data is correct, you will need to:

  1. Make string of Customer data object
  2. Encrypt secret key using ‘SHA-256’ algorithm.
  3. Combine string with Customer data string with encrypted secret key
  4. Encrypt string using ‘SHA-256’ algorithm which Customer get in step 3.
  5. Compare result with signature value from webhook
"Function to encrypt data in JavaScript using CryptoJS library"

var CryptoJS = require("crypto-js");
var secretHash = CryptoJS.SHA256('e38befe37f826fdcc103f44c0e661a4af16b925d').toString(CryptoJS.enc.Hex); // put secret-key
var bodyString = JSON.stringify({"payment_source":"162bfd33-212f-4546-8127-f9596e37d4d1","custom_reference":"testref","configuration_token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwdXJwb3NlIjoicGF5bWVudF9zb3VyY2UiLCJwcmVkZWZpbmVkX2ZpZWxkcyI6eyJ0eXBlIjoiY2FyZCIsImdhdGV3YXlfaWQiOiI1ODEwNDFhYWFmNDZlZGIzMGMxZmE1OTkifSwid2ViaG9va19kZXN0aW5hdGlvbiI6Imh0dHBzOi8vcmVxdWVzdGIuaW4vcGNmYWl4cGMiLCJzdWNjZXNzX3JlZGlyZWN0X3VybCI6IiIsImVycm9yX3JlZGlyZWN0X3VybCI6IiIsImRlZmluZWRfZm9ybV9maWVsZHMiOltdLCJpYXQiOjE0Nzg1MzMzOTJ9.AINNuIWd5of3bPw9V8bcg7xi6vLMsFRdXoqLf7Rjk-A"}); // put data
var hash = CryptoJS.SHA256(bodyString + secretHash).toString(CryptoJS.enc.Hex);

// hash == 'c67de0091aae55ebe432309f957f42f39e93beb71f5d38267b4dc521b8db53cf';
<?php
$userSecretKeyHash = hash('sha256', "e38befe37f826fdcc103f44c0e661a4af16b925d");
$data = json_encode([
    'payment_source'      => '162bfd33-212f-4546-8127-f9596e37d4d1',
    'custom_reference'    => 'testref',
    'configuration_token' => 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwdXJwb3NlIjoicGF5bWVudF9zb3VyY2UiLCJwcmVkZWZpbmVkX2ZpZWxkcyI6eyJ0eXBlIjoiY2FyZCIsImdhdGV3YXlfaWQiOiI1ODEwNDFhYWFmNDZlZGIzMGMxZmE1OTkifSwid2ViaG9va19kZXN0aW5hdGlvbiI6Imh0dHBzOi8vcmVxdWVzdGIuaW4vcGNmYWl4cGMiLCJzdWNjZXNzX3JlZGlyZWN0X3VybCI6IiIsImVycm9yX3JlZGlyZWN0X3VybCI6IiIsImRlZmluZWRfZm9ybV9maWVsZHMiOltdLCJpYXQiOjE0Nzg1MzMzOTJ9.AINNuIWd5of3bPw9V8bcg7xi6vLMsFRdXoqLf7Rjk-A'
]);

$resultString = $data . $userSecretKeyHash;

$resultHash = hash('sha256', $resultString);

print_r($resultHash);
// $resultHash = 'c67de0091aae55ebe432309f957f42f39e93beb71f5d38267b4dc521b8db53cf'
?>

Other Resources

Fraud detection service

Available only if configured for your account. PayDock Fraud detection API has an ability to operate in ‘active’ mode where PayDock will: Collect and report but also take the following actions

Or in ‘passive’ mode (where PayDock collects and reports, but does not respond to Fraud Service responses, and doesn’t block transaction processing)

PayDock API returns all fraud-related response data inside the “fraud” section of each processed transaction.

Fraud Data Description

Field Name Description Possible values
score Overall score of the fraud risk. Bigger number means bigger risk Optional. Not all fraud providers return it. Numeric
status Service-agnostic recommendation from PayDock on the base of the service response “approve”, “reject”, “review”, “failed”
specific_code Fraud service specific code Depends on the fraud service
specific_message Explanation of the code, coming from the fraud service Human-readable text

Testing

PayDock Fraud API in the Sandbox mode is set to return custom results based on the email. While creating one-time token request use “email” key or on tha stage of creating a charge with fraud check use “fraud.data.transaction.billing.customerEmailAddress” key to reproduce different type of responses:

Email value Fraud status
reject@example.com reject
review@example.com review
failed@example.com failed
any other approve

Also PayDock Fraud API in the Sandbox mode is set to return custom results based on the transaction amount.

Amount Fraud status
101 reject
102 review
103 failed
any other approve

Fraud API response examples

Required Fields by Gateway

Different gateways require different fields, see detailed listing below

Field Name Options
amount required
currency required
reference optional
description optional
first_name optional
last_name optional
email optional
address_line1 optional
address_line2 optional
address_city optional
address_state optional
address_country optional
address_postcode optional
gateway_id required
card_name optional
card_number required
expire_month required
expire_year required
card_ccv required
type n/a
account_name n/a
account_bsb n/a
account_number n/a
account_routing n/a
account_holder_type n/a
account_bank_name n/a
Field Name Options
amount required
currency required
reference optional
description optional
first_name required
last_name required
email optional
address_line1 optional
address_line2 optional
address_city optional
address_state optional
address_country optional
address_postcode optional
gateway_id required
card_name required
card_number required
expire_month required
expire_year required
card_ccv optional
type n/a
account_name n/a
account_bsb n/a
account_number n/a
account_routing n/a
account_holder_type n/a
account_bank_name n/a
Field Name Options
amount required
currency required
reference optional
description optional
first_name optional
last_name optional
email required
address_line1 optional
address_line2 optional
address_city optional
address_state optional
address_country optional
address_postcode optional
gateway_id required
card_name required
card_number required
expire_month required
expire_year required
card_ccv required
type n/a
account_name n/a
account_bsb n/a
account_number n/a
account_routing n/a
account_holder_type n/a
account_bank_name n/a
Field Name Options
amount required
currency required
reference optional
description optional
first_name optional
last_name optional
email optional
address_line1 optional
address_line2 optional
address_city optional
address_state optional
address_country optional
address_postcode optional
gateway_id required
card_name required
card_number required
expire_month required
expire_year required
card_ccv optional
type n/a
account_name n/a
account_bsb n/a
account_number n/a
account_routing n/a
account_holder_type n/a
account_bank_name n/a
Field Name Options
amount required
currency required
reference optional
description optional
first_name optional
last_name optional
email optional
address_line1 optional
address_line2 optional
address_city optional
address_state optional
address_country optional
address_postcode optional
gateway_id required
card_name n/a
card_number n/a
expire_month n/a
expire_year n/a
card_ccv n/a
type required
account_name required
account_bsb required
account_number required
account_routing n/a
account_holder_type n/a
account_bank_name n/a
Field Name Options
amount required
currency required
reference optional
description optional
first_name optional
last_name optional
email optional
address_line1 optional
address_line2 optional
address_city optional
address_state optional
address_country optional
address_postcode optional
gateway_id required
card_name optional
card_number required
expire_month required
expire_year required
card_ccv optional
type n/a
account_name n/a
account_bsb n/a
account_number n/a
account_routing n/a
account_holder_type n/a
account_bank_name n/a
Field Name Options
amount required
currency required
reference optional
description optional
first_name optional
last_name optional
email optional
address_line1 optional
address_line2 optional
address_city optional
address_state optional
address_country optional
address_postcode optional
gateway_id required
card_name required
card_number required
expire_month required
expire_year required
card_ccv optional
type n/a
account_name n/a
account_bsb n/a
account_number n/a
account_routing n/a
account_holder_type n/a
account_bank_name n/a
Field Name Options
amount required
currency required
reference optional
description optional
first_name optional
last_name optional
email optional
address_line1 optional
address_line2 optional
address_city optional
address_state optional
address_country optional
address_postcode optional
gateway_id required
card_name required
card_number required
expire_month required
expire_year required
card_ccv optional
type n/a
account_name n/a
account_bsb n/a
account_number n/a
account_routing n/a
account_holder_type n/a
account_bank_name n/a
Field Name Options
amount required
currency required
reference optional
description optional
first_name optional
last_name required
email optional
address_line1 optional
address_line2 optional
address_city optional
address_state optional
address_country optional
address_postcode optional
gateway_id required
card_name n/a
card_number n/a
expire_month n/a
expire_year n/a
card_ccv n/a
type required
account_name required
account_bsb required
account_number required
account_routing n/a
account_holder_type n/a
account_bank_name n/a
Field Name Options
amount required
currency required
reference optional
description optional
first_name optional
last_name optional
email optional
address_line1 optional
address_line2 optional
address_city optional
address_state optional
address_country optional
address_postcode optional
gateway_id required
card_name optional
card_number required
expire_month required
expire_year required
card_ccv optional
type n/a
account_name n/a
account_bsb n/a
account_number n/a
account_routing n/a
account_holder_type n/a
account_bank_name n/a
Field Name Options
amount required
currency required
reference optional
description optional
first_name optional
last_name optional
email optional
address_line1 optional
address_line2 optional
address_city optional
address_state optional
address_country optional
address_postcode optional
gateway_id required
card_name n/a
card_number n/a
expire_month n/a
expire_year n/a
card_ccv n/a
type required
account_name required
account_bsb required
account_number required
account_routing n/a
account_holder_type n/a
account_bank_name n/a
Field Name Options
amount required
currency required
reference optional
description optional
first_name optional
last_name optional
email optional
address_line1 optional
address_line2 optional
address_city optional
address_state optional
address_country optional
address_postcode optional
gateway_id required
card_name optional
card_number required
expire_month required
expire_year required
card_ccv required
type n/a
account_name n/a
account_bsb n/a
account_number n/a
account_routing n/a
account_holder_type n/a
account_bank_name n/a
Field Name Options
amount required
currency required
reference optional
description optional
first_name optional
last_name optional
email optional
address_line1 optional
address_line2 optional
address_city optional
address_state optional
address_country optional
address_postcode optional
gateway_id required
card_name optional
card_number required
expire_month required
expire_year required
card_ccv optional
type n/a
account_name n/a
account_bsb n/a
account_number n/a
account_routing n/a
account_holder_type n/a
account_bank_name n/a
Field Name Options
amount required
currency required
reference optional
description optional
first_name optional
last_name optional
email optional
address_line1 optional
address_line2 optional
address_city optional
address_state optional
address_country optional
address_postcode optional
gateway_id required
card_name optional
card_number required
expire_month required
expire_year required
card_ccv required
type n/a
account_name n/a
account_bsb n/a
account_number n/a
account_routing n/a
account_holder_type n/a
account_bank_name n/a
Field Name Options
amount required
currency required
reference optional
description optional
first_name optional
last_name optional
email required
address_line1 optional
address_line2 optional
address_city optional
address_state optional
address_country required
address_postcode required
gateway_id required
card_name required
card_number required
expire_month required
expire_year required
card_ccv required
type n/a
account_name n/a
account_bsb n/a
account_number n/a
account_routing n/a
account_holder_type n/a
account_bank_name n/a
Field Name Options
amount required
currency required
reference optional
description optional
first_name required
last_name required
email optional
address_line1 optional
address_line2 optional
address_city optional
address_state optional
address_country optional
address_postcode optional
gateway_id required
card_name optional
card_number required
expire_month required
expire_year required
card_ccv optional
type n/a
account_name n/a
account_bsb n/a
account_number n/a
account_routing n/a
account_holder_type n/a
account_bank_name n/a
Field Name Options
amount required
currency required
reference optional
description optional
first_name optional
last_name optional
email optional
address_line1 required
address_line2 optional
address_city required
address_state required
address_country required
address_postcode required
gateway_id required
card_name required
card_number required
expire_month required
expire_year required
card_ccv optional
type n/a
account_name n/a
account_bsb n/a
account_number n/a
account_routing n/a
account_holder_type n/a
account_bank_name n/a
Field Name Options
amount required
currency required
reference optional
description optional
first_name optional
last_name optional
email required
address_line1 optional
address_line2 optional
address_city required
address_state required
address_country required
address_postcode required
gateway_id required
card_name n/a
card_number n/a
expire_month n/a
expire_year n/a
card_ccv n/a
type required
account_name required
account_bsb required
account_number required
account_routing n/a
account_holder_type n/a
account_bank_name n/a
Field Name Options
amount required
currency required
reference optional
description optional
first_name optional
last_name optional
email optional
address_line1 optional
address_line2 optional
address_city optional
address_state optional
address_country optional
address_postcode optional
gateway_id required
card_name optional
card_number required
expire_month optional
expire_year optional
card_ccv optional
type n/a
account_name n/a
account_bsb n/a
account_number n/a
Field Name Options
amount required
currency required
reference optional
description optional
first_name optional
last_name optional
email optional
address_line1 optional
address_line2 optional
address_city optional
address_state optional
address_country optional
address_postcode optional
gateway_id required
card_name n/a
card_number n/a
expire_month n/a
expire_year n/a
card_ccv n/a
type required
account_name optional
account_bsb required
account_number required
Field Name Options
amount required
currency required
reference optional
description optional
first_name optional
last_name optional
email optional
address_line1 optional
address_line2 optional
address_city required
address_state required
address_country required
address_postcode required
gateway_id required
card_name required
card_number required
expire_month required
expire_year required
card_ccv optional
type n/a
account_name n/a
account_bsb n/a
account_number n/a
Field Name Options
amount required
currency required
reference optional
description optional
first_name optional
last_name optional
email optional
address_line1 optional
address_line2 optional
address_city required
address_state required
address_country required
address_postcode required
gateway_id required
card_name n/a
card_number n/a
expire_month n/a
expire_year n/a
card_ccv n/a
type required
account_name required
account_bsb required
account_number required
Field Name Options
amount required
currency required
reference optional
description optional
first_name optional
last_name optional
email optional
address_line1 optional
address_line2 optional
address_city optional
address_state optional
address_country optional
address_postcode optional
gateway_id required
card_name required
card_number required
expire_month required
expire_year required
card_ccv required
Field Name Options
amount required
currency required
reference optional
description optional
first_name optional
last_name optional
email optional
address_line1 optional
address_line2 optional
address_city optional
address_state optional
address_country optional
address_postcode optional
gateway_id required
card_name optional
card_number required
expire_month required
expire_year required
card_ccv optional
type n/a
account_name n/a
account_bsb n/a
account_number n/a
Field Name Options
amount required
currency required
reference optional
description optional
first_name optional
last_name optional
email optional
address_line1 optional
address_line2 optional
address_city optional
address_state optional
address_country optional
address_postcode optional
gateway_id required
card_name optional
card_number required
expire_month required
expire_year required
card_ccv required
type n/a
account_name n/a
account_bsb n/a
account_number n/a
Field Name Options
amount required
currency required
reference optional
description optional
first_name optional
last_name optional
email required
address_line1 optional
address_line2 optional
address_city optional
address_state optional
address_country required
address_postcode required
gateway_id required
card_name optional
card_number required
expire_month required
expire_year required
card_ccv required
type n/a
account_name n/a
account_bsb n/a
account_number n/a
Field Name Options
amount required
currency required
reference optional
description optional
first_name required
last_name optional
email required
address_line1 optional
address_line2 optional
address_city optional
address_state optional
address_country required
address_postcode optional
gateway_id required
card_name n/a
card_number n/a
expire_month n/a
expire_year n/a
card_ccv n/a
type required
account_name required
account_bsb n/a
account_number required
account_routing required
account_type required
account_holder_type required
account_bank_name required

Swap Values for templates

The notification templates can be used to load parameters from the customer or transaction into the notification. These can also be used to populate the destination (eg phone number for sms).

The full list of available swap values is:

Field Name Description
{{CHARGE_ID}} PayDock ID for the charge
{{EMAIL}} The email address for the customer associated with the event
{{FIRST_NAME}} The first name for the customer associated with the event
{{LAST_NAME}} The last name for the customer associated with the event
{{PHONE}} The phone number for the customer associated with the event
{{AMOUNT}} The amount for the transaction
{{CURRENCY}} The currency for the transation
{{CUSTOMER_REFERENCE}} The customer reference number provided by the merchant for the customer
{{CHARGE_REFERENCE}} The reference number provided by the merchant for the transaction
{{CHARGE_DESCRIPTION}} The description provided by the merchant for the transaction
{{CREATED_AT}} create date for the object (eg customer, subscription) in ISO format date and time (eg 2016-12-22T10:36:08.170Z)
{{UPDATED_AT}} updated date for the object (eg customer, subscription) in ISO format date and time (eg 2016-12-22T10:36:08.170Z)

Webhook event example

"Example of Transaction Success"
{
    "event": "transaction_success",
    "data": {
        "external_id": "ch_A5UQxvnd7B1aC2",
        "_id": "589c848fc1ecdd2a29fd2197",
        "created_at": "2017-02-09T15:02:39.971Z",
        "updated_at": "2017-02-09T15:02:41.498Z",
        "company_id": "5584018a27b2cf0b1e4f1a6c",
        "user_id": "5584018a27b2cf0b1e4f1a6b",
        "amount": 111,
        "currency": "AUD",
        "reference": "Reprehenderit laborum ea a optio iusto quis",
        "description": "Quidem in ea maiores illo quos esse",
        "__v": 1,
        "transactions": [
            {
                "created_at": "2017-02-09T15:02:39.968Z",
                "amount": 111,
                "currency": "AUD",
                "_id": "589c848fc1ecdd2a29fd2198",
                "status": "complete",
                "type": "sale"
            }
        ],
        "one_off": true,
        "archived": false,
        "customer": {
            "first_name": "Samantha",
            "last_name": "Washington",
            "email": "samwashington@gmail.com",
            "phone": "+61000000000",
            "reference": "Quidem in ea maiores illo quos esse",
            "payment_source": {
                "type": "card",
                "card_name": "Samantha Washington",
                "card_number_last4": "4444",
                "expire_month": 1,
                "expire_year": 2019,
                "address_line1": "Suite 660",
                "address_line2": "822 Ruiz Square",
                "address_city": "Sydney",
                "address_postcode": "1111",
                "address_state": null,
                "address_country": "AU",
                "gateway_id": "56a8ab12d6bd4e7d628576aa",
                "card_scheme": "mastercard",
                "gateway_name": "Gateway Name",
                "gateway_type": "GatewayType"
            }
        },
        "status": "complete"
    }
}

Paydock supports the following webhook events (see payload examples to the right):

"Example of Transaction Failure"
{
    "event": "transaction_failure",
    "data": {
        "_id": "589da11f1958cb42532f2463",
        "created_at": "2017-02-10T11:16:47.538Z",
        "updated_at": "2017-02-10T11:16:48.480Z",
        "company_id": "5584018a27b2cf0b1e4f1a6c",
        "user_id": "5584018a27b2cf0b1e4f1a6b",
        "amount": 111,
        "currency": "AUD",
        "__v": 1,
        "transactions": [
            {
                "created_at": "2017-02-10T11:16:47.533Z",
                "amount": 111,
                "currency": "AUD",
                "_id": "589da11f1958cb42532f2464",
                "status": "failed",
                "type": "sale"
            }
        ],
        "one_off": true,
        "archived": false,
        "customer": {
            "first_name": "Samantha",
            "last_name": "Washington",
            "email": "samwashington@gmail.com",
            "phone": "+61000000000",
            "payment_source": {
                "type": "card",
                "card_name": "Samantha Washington",
                "card_number_last4": "4445",
                "expire_month": 1,
                "expire_year": 2019,
                "address_line1": "Suite 660",
                "address_line2": "822 Ruiz Square",
                "address_city": "Sydney",
                "address_postcode": "1111",
                "address_state": null,
                "address_country": "AU",
                "gateway_id": "56a8ab12d6bd4e7d628576aa",
                "card_scheme": "mastercard",
                "gateway_name": "Gateway Name",
                "gateway_type": "GatewayType"
            }
        },
        "status": "failed"
    }
}
"Example of Transaction by Subscription Success"
{
    "event": "subscription_transaction",
    "data": {
        "_id": "589da11f1958cb42532f2463",
        "created_at": "2017-02-10T11:16:47.538Z",
        "updated_at": "2017-02-10T11:16:48.480Z",
        "company_id": "5584018a27b2cf0b1e4f1a6c",
        "user_id": "5584018a27b2cf0b1e4f1a6b",
        "amount": 111,
        "currency": "AUD",
        "subscription_id": "589dae7aa6c87450a798348e",
        "__v": 1,
        "transactions": [
            {
                "created_at": "2017-02-10T11:16:47.533Z",
                "amount": 111,
                "currency": "AUD",
                "_id": "589da11f1958cb42532f2464",
                "status": "failed",
                "type": "sale"
            }
        ],
        "one_off": true,
        "archived": false,
        "customer": {
            "first_name": "Samantha",
            "last_name": "Washington",
            "email": "samwashington@gmail.com",
            "phone": "+61000000000",
            "payment_source": {
                "type": "card",
                "card_name": "Samantha Washington",
                "card_number_last4": "4445",
                "expire_month": 1,
                "expire_year": 2019,
                "address_line1": "Suite 660",
                "address_line2": "822 Ruiz Square",
                "address_city": "Sydney",
                "address_postcode": "1111",
                "address_state": null,
                "address_country": "AU",
                "gateway_id": "56a8ab12d6bd4e7d628576aa",
                "card_scheme": "mastercard",
                "gateway_name": "Gateway Name",
                "gateway_type": "GatewayType"
            }
        },
        "status": "complete"
    }
}
"Example of Transaction by Subscription Failed"
{
    "event": "subscription_transaction_failure",
    "data": {
        "_id": "589da11f1958cb42532f2463",
        "created_at": "2017-02-10T11:16:47.538Z",
        "updated_at": "2017-02-10T11:16:48.480Z",
        "company_id": "5584018a27b2cf0b1e4f1a6c",
        "user_id": "5584018a27b2cf0b1e4f1a6b",
        "amount": 111,
        "currency": "AUD",
        "subscription_id": "589dae7aa6c87450a798348e",
        "__v": 1,
        "transactions": [
            {
                "created_at": "2017-02-10T11:16:47.533Z",
                "amount": 111,
                "currency": "AUD",
                "_id": "589da11f1958cb42532f2464",
                "status": "failed",
                "type": "sale"
            }
        ],
        "one_off": true,
        "archived": false,
        "customer": {
            "first_name": "Samantha",
            "last_name": "Washington",
            "email": "samwashington@gmail.com",
            "phone": "+61000000000",
            "payment_source": {
                "type": "card",
                "card_name": "Samantha Washington",
                "card_number_last4": "4445",
                "expire_month": 1,
                "expire_year": 2019,
                "address_line1": "Suite 660",
                "address_line2": "822 Ruiz Square",
                "address_city": "Sydney",
                "address_postcode": "1111",
                "address_state": null,
                "address_country": "AU",
                "gateway_id": "56a8ab12d6bd4e7d628576aa",
                "card_scheme": "mastercard",
                "gateway_name": "Gateway Name",
                "gateway_type": "GatewayType"
            }
        },
        "status": "failed"
    }
}
"Example of Subscription Creation Success"
{
    "event": "subscription_creation_success",
    "data": {
        "__v": 0,
        "created_at": "2017-02-10T11:55:59.804Z",
        "updated_at": "2017-02-10T11:55:59.804Z",
        "amount": 111,
        "payment_source_id": "589daa4fa6c87450a798347d",
        "status": "active",
        "_id": "589daa4fa6c87450a798347f",
        "archived": false,
        "_service": {
            "customer_default_gateway_id": "56a8ab12d6bd4e7d628576aa",
            "tags": "Samantha Washington samwashington@gmail.com"
        },
        "customer": {
            "customer_id": "589daa4ea6c87450a798347c",
            "first_name": "Samantha",
            "last_name": "Washington",
            "email": "samwashington@gmail.com",
            "phone": "+61000000000"
        },
        "statistics": {
            "total_collected_amount": 0,
            "successful_transactions": 0
        },
        "schedule": {
            "interval": "week",
            "start_date": "2017-02-10T11:55:58.477Z",
            "next_assessment": "2017-02-10T11:55:58.477Z",
            "next_assessment_planned": "2017-02-10T11:55:58.477Z",
            "first_assessment": "2017-02-10T11:55:58.477Z",
            "status": "inprogress",
            "locked": false,
            "completed_count": 0,
            "retry_count": 0,
            "frequency": 2
        },
        "currency": "AUD"
    }
}
"Example of Subscription Creation Failure"
{
    "event": "subscription_creation_failure",
    "data": {
        "customer": {
            "first_name": "Samantha",
            "last_name": "Washington",
            "email": "samwashington@gmail.com",
            "phone": "+61000000000",
            "payment_source": {
                "address_country": "AU",
                "type": "card",
                "address_line1": "Suite 660",
                "address_line2": "822 Ruiz Square",
                "address_city": "Sydney",
                "address_postcode": "1111",
                "gateway_id": "56a8ab12d6bd4e7d628576aa",
                "card_name": "Samantha Washington",
                "card_number_last4": "4445",
                "expire_month": "**",
                "expire_year": "****",
                "card_ccv": "***"
            },
            "_check_expire_date": false
        },
        "amount": "111",
        "currency": "AUD"
    }
}
"Example of Subscription Finished"
{
    "event": "subscription_finished",
    "data": {
        "_id": "589dacaf1958cb42532f2482",
        "created_at": "2017-02-10T12:06:07.575Z",
        "updated_at": "2017-02-10T12:06:19.146Z",
        "amount": 111,
        "payment_source_id": "589dacaf1958cb42532f2480",
        "status": "expired",
        "__v": 0,
        "archived": false,
        "_service": {
            "customer_default_gateway_id": "56a8ab12d6bd4e7d628576aa",
            "tags": "Samantha Washington samwashington@gmail.com",
            "queue_id": "QU-DD034F558CB0C576"
        },
        "customer": {
            "customer_id": "589dacae1958cb42532f247f",
            "first_name": "Samantha",
            "last_name": "Washington",
            "email": "samwashington@gmail.com",
            "phone": "+61000000000"
        },
        "statistics": {
            "total_collected_amount": 111,
            "successful_transactions": 1
        },
        "schedule": {
            "last_assessment": "2017-02-10T12:06:19.143Z",
            "interval": "week",
            "start_date": "2017-02-10T12:06:06.596Z",
            "end_date": "2017-02-11T00:00:00.000Z",
            "next_assessment": "2017-02-10T12:06:06.596Z",
            "next_assessment_planned": "2017-02-10T12:06:06.596Z",
            "first_assessment": "2017-02-10T12:06:06.596Z",
            "status": "complete",
            "locked": false,
            "completed_count": 1,
            "retry_count": 0,
            "frequency": 1
        },
        "currency": "AUD"
    }
}
"Example of Subscription Updated"
{
    "event": "subscription_updated",
    "data": {
        "_id": "589dae7aa6c87450a798348e",
        "created_at": "2017-02-10T12:13:46.059Z",
        "updated_at": "2017-02-10T12:14:39.872Z",
        "user_id": "5584018a27b2cf0b1e4f1a6b",
        "company_id": "5584018a27b2cf0b1e4f1a6c",
        "amount": 111,
        "payment_source_id": "589dae79a6c87450a798348c",
        "_source_ip_address": "159.224.44.130",
        "status": "active",
        "archived": false,
        "customer": {
            "customer_id": "589dae78a6c87450a798348b",
            "first_name": "Samantha",
            "last_name": "Washington",
            "email": "samwashington@gmail.com",
            "phone": "+61000000000"
        },
        "statistics": {
            "total_collected_amount": 111,
            "successful_transactions": 1
        },
        "schedule": {
            "end_amount_total": null,
            "end_amount_before": null,
            "end_transactions": null,
            "end_amount_after": null,
            "end_date": null,
            "interval": "day",
            "start_date": "2017-02-12T00:00:00.000Z",
            "next_assessment": "2017-02-12T00:00:00.000Z",
            "next_assessment_planned": "2017-02-12T00:00:00.000Z",
            "first_assessment": "2017-02-12T00:00:00.000Z",
            "status": "complete",
            "last_assessment": "2017-02-10T12:13:49.469Z",
            "locked": false,
            "completed_count": 1,
            "retry_count": 0,
            "frequency": 1
        },
        "currency": "AUD",
        "gateway_type": "GatewayType",
        "gateway_name": "Gateway Name",
        "gateway_mode": "test"
    }
}
"Example of Subscription Failed"
{
    "event": "subscription_failed",
    "data": {
        "_id": "589dae7aa6c87450a798348e",
        "created_at": "2017-02-10T12:13:46.059Z",
        "updated_at": "2017-02-10T12:14:39.872Z",
        "user_id": "5584018a27b2cf0b1e4f1a6b",
        "company_id": "5584018a27b2cf0b1e4f1a6c",
        "amount": 111,
        "payment_source_id": "589dae79a6c87450a798348c",
        "_source_ip_address": "159.224.44.130",
        "status": "active",
        "archived": false,
        "customer": {
            "customer_id": "589dae78a6c87450a798348b",
            "first_name": "Samantha",
            "last_name": "Washington",
            "email": "samwashington@gmail.com",
            "phone": "+61000000000"
        },
        "statistics": {
            "total_collected_amount": 111,
            "successful_transactions": 1
        },
        "schedule": {
            "interval": "day",
            "start_date": "2017-02-12T00:00:00.000Z",
            "next_assessment": "2017-02-12T00:00:00.000Z",
            "next_assessment_planned": "2017-02-12T00:00:00.000Z",
            "first_assessment": "2017-02-12T00:00:00.000Z",
            "status": "complete",
            "last_assessment": "2017-02-10T12:13:49.469Z",
            "locked": false,
            "completed_count": 1,
            "retry_count": 0,
            "frequency": 1
        },
        "currency": "AUD",
        "gateway_type": "GatewayType",
        "gateway_name": "Gateway Name",
        "gateway_mode": "test"
    }
}
"Example of Refund Requested"
{
    "event": "refund_requested",
    "data": {
        "_id": "589dae7c1958cb42532f248a",
        "created_at": "2017-02-10T12:13:48.034Z",
        "updated_at": "2017-02-10T12:16:53.495Z",
        "company_id": "5584018a27b2cf0b1e4f1a6c",
        "user_id": "5584018a27b2cf0b1e4f1a6b",
        "amount": 111,
        "currency": "AUD",
        "subscription_id": "589dae7aa6c87450a798348e",
        "__v": 3,
        "external_id": "ch_A5ovQPHUOTprV7",
        "transactions": [
            {
                "created_at": "2017-02-10T12:13:48.029Z",
                "amount": 111,
                "currency": "AUD",
                "_id": "589dae7c1958cb42532f248b",
                "status": "complete",
                "type": "sale"
            },
            {
                "pended_at": "2017-02-11T12:16:53.509Z",
                "created_at": "2017-02-10T12:16:51.582Z",
                "amount": 111,
                "currency": "AUD",
                "_id": "589daf33a6c87450a7983491",
                "status": "requested",
                "type": "refund"
            }
        ],
        "one_off": false,
        "archived": false,
        "customer": {
            "customer_id": "589dae78a6c87450a798348b",
            "first_name": "Samantha",
            "last_name": "Washington",
            "email": "samwashington@gmail.com",
            "phone": "+61000000000",
            "payment_source": {
                "type": "card",
                "card_name": "Samantha Washington",
                "card_number_last4": "4444",
                "card_scheme": "mastercard",
                "expire_month": 1,
                "expire_year": 2019,
                "address_line1": "Suite 660",
                "address_line2": "822 Ruiz Square",
                "address_city": "Sydney",
                "address_postcode": "1111",
                "address_country": "AU",
                "gateway_id": "56a8ab12d6bd4e7d628576aa"
            }
        },
        "status": "refund_requested",
        "transaction": {
            "pended_at": "2017-02-11T12:16:53.509Z",
            "created_at": "2017-02-10T12:16:51.582Z",
            "amount": 111,
            "currency": "AUD",
            "_id": "589daf33a6c87450a7983491",
            "status": "requested",
            "type": "refund"
        }
    }
}
"Example of Refund Success"
{
    "event": "refund_success",
    "data": {
        "_id": "589dae7c1958cb42532f248a",
        "created_at": "2017-02-10T12:13:48.034Z",
        "updated_at": "2017-02-10T12:19:05.117Z",
        "company_id": "5584018a27b2cf0b1e4f1a6c",
        "user_id": "5584018a27b2cf0b1e4f1a6b",
        "amount": 111,
        "currency": "AUD",
        "subscription_id": "589dae7aa6c87450a798348e",
        "__v": 4,
        "external_id": "ch_A5ovQPHUOTprV7",
        "transactions": [
            {
                "created_at": "2017-02-10T12:13:48.029Z",
                "amount": 111,
                "currency": "AUD",
                "_id": "589dae7c1958cb42532f248b",
                "status": "complete",
                "type": "sale"
            },
            {
                "created_at": "2017-02-10T12:16:51.582Z",
                "amount": 111,
                "currency": "AUD",
                "_id": "589daf33a6c87450a7983491",
                "pended_at": "2017-02-11T12:16:53.509Z",
                "status": "complete",
                "type": "refund"
            }
        ],
        "one_off": false,
        "archived": false,
        "customer": {
            "customer_id": "589dae78a6c87450a798348b",
            "first_name": "Samantha",
            "last_name": "Washington",
            "email": "samwashington@gmail.com",
            "phone": "+61000000000",
            "payment_source": {
                "type": "card",
                "card_name": "Samantha Washington",
                "card_number_last4": "4444",
                "card_scheme": "mastercard",
                "expire_month": 1,
                "expire_year": 2019,
                "address_line1": "Suite 660",
                "address_line2": "822 Ruiz Square",
                "address_city": "Sydney",
                "address_postcode": "1111",
                "address_country": "AU",
                "gateway_id": "56a8ab12d6bd4e7d628576aa"
            }
        },
        "status": "refunded",
        "transaction": {
            "created_at": "2017-02-10T12:16:51.582Z",
            "amount": 111,
            "currency": "AUD",
            "_id": "589daf33a6c87450a7983491",
            "pended_at": "2017-02-11T12:16:53.509Z",
            "status": "complete",
            "type": "refund"
        }
    }
}
"Example of Refund Failure"
{
    "event": "refund_failure",
    "data": {
        "_id": "589daa621958cb42532f2476",
        "created_at": "2017-02-10T11:56:18.021Z",
        "updated_at": "2017-02-10T12:24:56.723Z",
        "company_id": "5584018a27b2cf0b1e4f1a6c",
        "user_id": "5584018a27b2cf0b1e4f1a6b",
        "amount": 111,
        "currency": "AUD",
        "subscription_id": "589daa4fa6c87450a798347f",
        "__v": 3,
        "external_id": "ch_A5odfEhbA7VaT1",
        "transactions": [
            {
                "created_at": "2017-02-10T11:56:18.017Z",
                "amount": 111,
                "currency": "AUD",
                "_id": "589daa621958cb42532f2477",
                "status": "complete",
                "type": "sale"
            },
            {
                "created_at": "2017-02-10T12:24:55.732Z",
                "amount": 11111111111,
                "currency": "AUD",
                "_id": "589db1171958cb42532f2497",
                "status": "failed",
                "type": "refund"
            }
        ],
        "one_off": false,
        "archived": false,
        "customer": {
            "customer_id": "589daa4ea6c87450a798347c",
            "first_name": "Samantha",
            "last_name": "Washington",
            "email": "samwashington@gmail.com",
            "phone": "+61000000000",
            "payment_source": {
                "type": "card",
                "card_name": "Samantha Washington",
                "card_number_last4": "4444",
                "card_scheme": "mastercard",
                "expire_month": 1,
                "expire_year": 2019,
                "address_line1": "Suite 660",
                "address_line2": "822 Ruiz Square",
                "address_city": "Sydney",
                "address_country": "AU",
                "gateway_id": "56a8ab12d6bd4e7d628576aa"
            }
        },
        "status": "complete",
        "transaction": {
            "created_at": "2017-02-10T12:24:55.732Z",
            "amount": 11111111111,
            "currency": "AUD",
            "_id": "589db1171958cb42532f2497",
            "status": "failed",
            "type": "refund"
        }
    }
}
"Example of Card Expiration Warning"
{
    "event": "card_expiration_warning",
    "data": {
        "_id": "589db4311958cb42532f24a3",
        "created_at": "2017-02-10T12:38:11.385Z",
        "updated_at": "2017-02-10T12:38:11.385Z",
        "status": "active",
        "default_source": "589db4331958cb42532f24a4",
        "company_id": "5584018a27b2cf0b1e4f1a6c",
        "user_id": "5584018a27b2cf0b1e4f1a6b",
        "first_name": "Samantha",
        "last_name": "Washington",
        "email": "samwashington@gmail.com",
        "statistics": {
            "total_collected_amount": 5555,
            "successful_transactions": 1,
            "currency": {
                "AUD": {
                    "total_amount": 5555,
                    "count": 1
                }
            }
        },
        "payment_source": {
            "updated_at": "2017-02-10T12:38:11.384Z",
            "vault_token": "f5900584-9ced-4b36-9b3a-5e8976d03d11",
            "address_country": "AU",
            "address_line1": "Suite 660",
            "address_line2": "822 Ruiz Square",
            "address_city": "Sydney",
            "address_postcode": "1111",
            "gateway_id": "56b22bc45a9cb7517bdb1079",
            "card_name": "Samantha Washington",
            "expire_month": 3,
            "expire_year": 2017,
            "card_number_last4": "4444",
            "card_scheme": "mastercard",
            "ref_token": "cus_A5pJfU1O30AJsj",
            "status": "active",
            "created_at": "2017-02-10T12:38:11.125Z",
            "_id": "589db4331958cb42532f24a4",
            "type": "card"
        }
    }
}