Integrate Checkout Page

The Checkout Page is the most common method used to integrate FasterPay as a payment option. Once your customer is ready to pay, FasterPay will take care of the payment, notify your system about the payment and return the customer back to your Thank You page.


Prerequisites

To integrate the Checkout Page you will need your API keys which you can find in your FasterPay Business account. If you don’t have a FasterPay Business account yet, you can sign up for one.

You can start testing the API and follow the steps below using the Test Mode and Go Live after.


How does the Checkout Page integration work?

  1. The customer clicks on the Pay Button on your website and is redirected to FasterPay checkout page.
  2. The customer makes a payment and FasterPay sends a Pingback to your servers.
  3. FasterPay redirects the customer to your Thank You page.
FasterPay payment page integration

To integrate the Checkout Page follow the steps below:

Step 1: Redirect your customer to the Checkout Page

Once your customer wants to pay, redirect them to FasterPay Checkout Page using the code below:

<?php
include('lib/autoload.php');
$gateway = new FasterPay\Gateway(array(
 'publicKey' 	=> '<your public key>',
 'privateKey'	=> '<your private key>',
));
$form = $gateway->paymentForm()->buildForm(
 array(
  'description' => 'Test order',
  'amount' => '10',
  'currency' => 'USD',
  'merchant_order_id' => 'xxxxxx',
  'success_url' => 'https://yourcompanywebsite.com/success'
 )
);
echo $form;
?>
from fasterpay.gateway import Gateway

if __name__ == "__main__":
  gateway = Gateway("<your private key>", "<your public key>")
  payload = {
    "description": "Golden Ticket",
    "amount": "0.01",
    "currency": "EUR",
    "merchant_order_id": "xxxxx",
    "success_url": "https://yourcompanywebsite.com/success"
  }
  paymentForm = gateway.payment_form().build_form(payload)
  print paymentForm
curl https://pay.fasterpay.com/payment/form \
-d "api_key: [YOUR_PUBLIC_KEY]" \
-d "merchant_order_id=w2183261236" \
-d "amount=9.99" \
-d "currency=USD" \
-d "email=user@host.com" \
-d "description=Golden Ticket" \
-d "hash=<hash generated using the combination of post params and merchant private key>"

You can find more information on the API parameters in the Checkout Page API.

Step 2: Process the Pingback

After the customer makes a payment, FasterPay will send a Pingback to your servers notifying you about the payment. You can use the code below to validate the Pingback, track the payment in your server and deliver the product:

<?php
include('lib/autoload.php');

$gateway = new Fasterpay\Gateway(array(
  'publicKey'     => '<your public key>',
  'privateKey'    => '<your private key>',
));

$pingbackData = json_decode(file_get_contents('php://input'), true);
if(!empty($pingbackData)){
  if($gateway->pingback()->validate(
    array("apiKey" => $_SERVER["HTTP_X_APIKEY"]))
  ){
    #TODO: Write your code to deliver contents to the End-User.
    echo "OK"; exit();
  }
}
echo "NOK";
?>
from flask import request
from fasterpay.gateway import FP_Gateway
gateway = Gateway("<your private key>", "<your public key>")
if gateway.pingback().validate({"apiKey": request.headers.get("X-ApiKey")}) is True:
  print "OK"
else:
  print "NOK"
curl --header "Content-Type: application/json" \
  --request POST \
  --data '{ \
    "event":"payment", \
    "payment_order":{ \
      "id":273281973, \
      "merchant_order_id":"w2981398127", \
      "payment_system":1, \
      "status":"successful", \
      "paid_amount":46.049999999999997, \
      "paid_currency":"EUR", \
      "merchant_net_revenue":42.227200000000003, \
      "merchant_rolling_reserve":2.3025000000000002, \
      "fees":1.5203, \
      "date":{ \
        "date":"2018-11-30 23:59:10.000000", \
        "timezone_type":3, \
        "timezone":"UTC" \
      } \
    }, \
    "user":{ \
      "firstname":"John", \
      "lastname":"Doe", \
      "username":"John-Doe@my.passport.io", \
      "country":"US", \
      "email":"johndoe@example.com" \
    }, \
    "with_risk_check":false, \
  }'
 https://your-pingback-url.com/pingback.php

FasterPay expects the following response: Response Status: 200 Response Body: ok

In case a different response is received, FasterPay will resend Pingbacks every 30 minutes for up to 10 times. You can also accept a range of Pingback types, such as refunds and chargebacks. More about Pingbacks.


Step 3: Show your Thank You page

Once the user makes a payment, they will be redirected to the success_url page that you specify during step.1. You can show your “Thank You” message on this screen.


Step 4: Test

Once you have completed implementation, go ahead and test it using the Test Credit Card numbers found in FasterPay’s Test Mode. You can turn on test mode by clicking the toggle in the header.


Step 5: Go Live

Once you’re done, simply fill out your Business Profile and Go Live!