razorcreations / plott-global-payments

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Plott / Freightport

Global Payments API

A small set of tools to allow an invoice to be paid via Global Payments hosted payments page, after capturing the minimum required information from the user first.

Design to sit on a sub-folder of a website, e.g. freightport.co.uk/invoices, etc.

Config

composer install
cp .env.example .env

And populate the following variables in .env:

# The full URI the application is running on
APP_URL=

# Global Payments merchant ID, Account ID, Secret Key, and sandbox or production hosted payment page
GP_MERCHANT_ID=
GP_ACCOUNT_ID=
GP_SECRET=
GP_PAYMENT_URL=https://pay.sandbox.realexpayments.com/pay

What This Does...

index.php starts by determining what state we're in (information has been captured or not, etc.) as well as loading in packages and .env vars. For a first hit, it will load includes/form.php and display to the user.

Once the user has populated the form, we'll validate it, and then use include/dispatch.php to spin up a new classes/GlobalPaymentsService.php instance, wrap up the information along with the .env variables and generate some JSON. This JSON is generated by the Global Payments PHP SDK and contains information about the order, and some hashes, account IDs, etc.

When the JSON has been generated, our app will then spin up a second page (includes/iframe.php) with a button and the Global Payments JS SDK included. Upon clicking the button, the JS SDK populates an iframe with the hosted payment page.

Upon successful payment, the iframe posts a message back to the SDK allowing us to alert the user that their payment has been successful or failed.

Resources

About


Languages

Language:JavaScript 60.5%Language:PHP 39.0%Language:Shell 0.4%Language:CSS 0.1%