Skip to content

Hosted payment page integration

Accept Mastercard payments on your website through MyBank's N-Genius Online hosted payment page: card data is entered on PCI DSS compliant pages run by Network International.

Overview

A hosted payment page is the most common integration for small and medium-sized businesses accepting payments online. It offers:

Before you start

You need these from MyBank when your merchant account is set up:

Keep your API key on your server. Never put it in browser JavaScript or a mobile app. The examples below use the sandbox; production endpoints are provided with your live credentials.

Authentication

Request an access token first. It expires after 5 minutes and is required for every other call.

POSThttps://api-gateway.sandbox.mybank.ngenius-payments.com/identity/auth/access-token

HeaderValue
Content-Typeapplication/vnd.ni-identity.v1+json
AuthorizationBasic your_api_key
PHP: request an access token

$apikey = 'your_api_key';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api-gateway.sandbox.mybank.ngenius-payments.com/identity/auth/access-token");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    "accept: application/vnd.ni-identity.v1+json",
    "authorization: Basic ".$apikey,
    "content-type: application/vnd.ni-identity.v1+json"
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
$output = json_decode(curl_exec($ch));
$access_token = $output->access_token;

Create an order

Each payment needs an order, which you use for tracking and management.

POSThttps://api-gateway.sandbox.mybank.ngenius-payments.com/transactions/outlets/[outlet-reference]/orders

ParameterDescriptionExample
actionOrder type"PURCHASE"
amount.currencyCodeOrder currency"AED", "USD", "EUR"
amount.valueOrder amount in minor units1000 (= 10.00)
PHP: create an order

$postData = new StdClass();
$postData->action = "PURCHASE";
$postData->amount = new StdClass();
$postData->amount->currencyCode = "USD";
$postData->amount->value = 900;
$postData->emailAddress = "customer@test.com";
$postData->merchantOrderReference = "ORDER-123";
$postData->merchantAttributes = new StdClass();
$postData->merchantAttributes->redirectUrl = "https://your-site.com/payment/callback";
$postData->merchantAttributes->skipConfirmationPage = true;

$json = json_encode($postData);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api-gateway.sandbox.mybank.ngenius-payments.com/transactions/outlets/".$outlet."/orders");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    "Authorization: Bearer ".$access_token,
    "Content-Type: application/vnd.ni-payment.v2+json",
    "Accept: application/vnd.ni-payment.v2+json"
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
$response = json_decode(curl_exec($ch));

Webhooks

Webhooks send you payment status updates in real time, so you do not need to poll for order status.

EventMeaning
AUTHORISEDPayment has been authorised
CAPTUREDPayment has been captured in full
DECLINEDPayment was declined by the issuing bank
REFUNDEDPayment has been refunded
PHP: webhook handler

<?php
// Receive webhook data
$payload = file_get_contents('php://input');
$event = json_decode($payload);

// Verify webhook signature (implement your own security checks)
if (!verifyWebhookSignature($payload)) {
    http_response_code(401);
    exit('Invalid signature');
}

// Process the event
switch ($event->eventName) {
    case 'AUTHORISED':
        handleAuthorizedPayment($event->order);
        break;
    case 'CAPTURED':
        handleCapturedPayment($event->order);
        break;
    case 'DECLINED':
        handleDeclinedPayment($event->order);
        break;
    // Handle other events...
}

// Always respond with 200 OK
http_response_code(200);
echo json_encode(['status' => 'success']);

Support

For help with your integration or a merchant account: