Developer - Globalpay Integration Docs
Developer - Globalpay Integration Docs
Documentation
1. Generate Payment Link
API https://paygw.globalpay.com.ng/globalpay-paymentgatewa
Endpoint y/api/paymentgateway/generate-payment-link
{
"amount": 100,
"merchantTransactionReference": "your reference no",
"redirectUrl": "www.yoururl.com",
"customer": {
"lastName": "lastname",
"firstName": "firstname",
"currency": "NGN",
"phoneNumber": "081XXXXXXXX",
"address": "string",
"emailAddress": "[email protected]"
}
}
Sample Request Payload 2 (Custom Fields)
{
"amount": 100,
"merchantTransactionReference": "your reference no",
"redirectUrl": "www.yoururl.com",
"customer": {
"lastName": "lastname",
"firstName": "firstname",
"currency": "NGN",
"phoneNumber": "081XXXXXXXX",
"address": "string",
"emailAddress": "[email protected]",
"paymentFormCustomFields": [
{
"name of custom field": "Grade",
"value of custom field": "Average"
}
]
}
}
Description
Header parameters:
language: en
apikey: enter your public key he
Sample Response
method.
2. query transaction with globalpay ref
API Key
API
description This API is used by the merchant to confirm the
transaction status of a transaction
Sample Request
Sample Response
{
"data": {
"txnref": "4914065XXX932792",
"merchantid": XXX,
"channel": "Bank",
"amount": 100.00,
"paymentDate": "2024-01-17T07:17:28.293",
"paymentStatus": "Failed",
"furtherProcessed": null,
"processDate": null,
"merchantTxnref": "CGSxxxxx637839",
"inAmount": 100.00,
"inCurrency": "NGN",
"rate": null,
"redirectUrl": null,
"transactionSource": "Website",
"transactionChannel": "Bank"
},
"successMessage": "Successful",
"responseCode": "0000",
"isSuccessful": true,
"error": null
}
API Key
API
description This API is used by the merchant to confirm the
transaction status of a transaction
Sample Request
Sample Response
{
"data": {
"txnref": "491406562XXX2792",
"merchantid": XXX,
"channel": "Bank",
"amount": 100.00,
"paymentDate": "2024-01-17T07:17:28.293",
"paymentStatus": "Failed",
"furtherProcessed": null,
"processDate": null,
"merchantTxnref": "CGxxxxxKD637839",
"inAmount": 100.00,
"inCurrency": "NGN",
"rate": null,
"redirectUrl": null,
"transactionSource": "Website",
"transactionChannel": "Bank"
},
"successMessage": "Successful",
"responseCode": "0000",
"isSuccessful": true,
"error": null
}
API Key
API
description This API is used by the merchant to get transaction
reports
Sample Request
Sample Response
"data": [
{
"txnref": "xxxxxxxxxxx",
"transactionFee": "ChargeMerchant",
"merchantid": xxxx,
"customerAccountNumber": "N/A",
"customerBankName": "N/A",
"amount": null,
"paymentDate": "2024-01-05T09:44:00",
"paymentStatus": "pending",
"merchantTxnref": "xxxxxxx",
"inAmount": 100.00,
"feeAmount": 1.50,
"inCurrency": "NGN",
"redirectUrl": "xxxxxxxxx",
"transactionSource": "xxxxxxx",
"transactionChannel": "xxxxxxx"
},
],
"successMessage": "Successful",
"responseCode": "0000",
"isSuccessful": true,
"error": null
}
5. download transactions reconciliation
API Key
API
description This API is used by the merchant to download transaction
reports
Sample Request
Globalpay SDks and
Libraries
Mobile SDKs
React Native
The GlobalPay React Native SDK is a comprehensive toolkit designed to seamlessly integrate
GlobalPay's payment capabilities into React Native applications. With this SDK, developers can
easily enable secure payment processing, providing a smooth and reliable checkout experience for
users.
Project Setup
To use packages from Azure Artifacts, configure your project to reference this feed.
Create a new text file called “.npmrc” in the same directory as your package.json, then copy the
snippet below:
@zenith/registry=https://pkgs.dev.azure.com/ZBPlc/ZenithSDKs/_packaging/ZenithSDKFeed/np
Restore packages
npm install
Installation
Usage
<GlobalPayRnSdk
Amount={300}
MerchantTransactionReference="your-reference"
RedirectUrl="your-redirect-url"
FirstName="customer's first name"
LastName="customer's last name"
Currency="NGN"
// Enviroment can be test or live Enviroment="live"
Address="customer's address"
EmailAddress="customer's email"
PhoneNumber="customer's phone"
onSuccess={(message) => return console.log(message)}
onFailure={(message) => return console.log(message)}
onClose={(message) => return console.log(message)}
/>
Flutter
Installation
Making Payments
The Plugin handles all the processes involved in making a payment with global pay flutter sdk.
import 'package:global_pay/global_pay.dart';
GlobalPay.launchGlobalPay(
context,
email: [email protected],
amount: 100,
currency: 'NGN',
merchantId: 'merchantId',
username: 'username',
userPhone: '07030297285',
environment: GlobalPayEnvironment.test,
apiKey: 'apikey',
redirectURL: 'redirecturl',
onClose: (_) {
***User closed the checkout
},
onSuccess: (TransactionData transactionData) {
***use the transaction data response in sync with your
application needs
},
onError: (String errorMessage) {
***use the error message in sync with your application
needs
},
);
Native Android
Installation
android {
// ... Other configuration code
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
// For kotlin codebases, include
kotlinOptions {
jvmTarget = "1.8"
}
}
Transaction Callback
When an error occurs or transaction concludes successfully, we will call the methods available
Sample Usage
Using Java
void makePayment(){
Button payBtn = findViewById(R.id.button);
GlobalPayCheckOut checkout = new
GlobalPayCheckOut.Builder(this, "[email protected]",
50, "NGN", "22903", "Aboyeji Dotun",
"08056162610","https://www.example.com/")
.build();
payBtn.setOnClickListener(view -> {
checkout.charge(new GlobalPayResultListener()
{
@Override
public void onSuccess(@NonNull String
message) {
String value =
String.format("Transaction complete - Ref: %s", message);
Toast.makeText(TestingActivity.this,
value, Toast.LENGTH_LONG).show();
Log.i("TAG", "Transaction Success");
}
@Override
public void onError(@NonNull Throwable
exception) {
Toast.makeText(TestingActivity.this,
"Transaction failed", Toast.LENGTH_LONG)
.show();
Log.e("TAG",
exception.getMessage(), exception);
}
@Override
public void onCancelled() {
Toast.makeText(TestingActivity.this,
"Transaction cancelled by user", Toast.LENGTH_LONG)
.show();
Log.i("TAG", "Payment process
cancelled!");
}
});
});
}
Using Kotlin
showMessage(exception.message.toString())
Log.e(TAG,
exception.message.orEmpty(), exception)
}
override fun onCancelled() {
showMessage("Transaction cancelled by user")
Log.e(TAG, "Cancelled!")
}
}
val checkoutBuilder =
GlobalPayCheckOut.Builder(
this, "[email protected]",
50, "NGN",merchantId = "XXXXX",names =
"Aboyeji Dotun",phone = "07030297285",RedirectUrl =
"https://www.example.com/"
)
val checkout = checkoutBuilder.build()
button.setOnClickListener {
checkout.charge(checkoutResultListener)
}
}
Frontend Libraries
React
React library for integrating GlobalPay Payment Gateway into React applications.
Project Setup
To use packages from Azure Artifacts, configure your project to reference this feed.
Create a new text file called “.npmrc” in the same directory as your package.json, then copy
the snippet below
@zenith/registry=https://pkgs.dev.azure.com/ZBPlc/ZenithSDKs/_packaging/ZenithSDKFee
d/npm
Installation
npm install @zenith/globalpay-react
Sample Usage
const style = {
background: 'green',
color: 'yellow'
};
function onError(error) {
console.log(error);
}
return (
<>
<GlobalPay
apiKey="your-api-key"
buttonText="Pay Me"
buttonStyle={style}
payload={payload}
onError={onError}
></GlobalPay>
</>
)
};
Angular
Angular library for integrating GlobalPay Payment Gateway into Angular applications.
Project Setup
To use packages from Azure Artifacts, configure your project to reference this feed.
Create a new text file called “.npmrc” in the same directory as your package.json, then copy the
snippet below
@zenith/registry=https://pkgs.dev.azure.com/ZBPlc/ZenithSDKs/_packaging/ZenithSDKFeed/np
m
Installation
npm install @zenith/globalpay-angular
Usage
Import GlobalPayModule into your Angular application's module where Globalpay is used:
@NgModule({
declarations: [
// Your components
],
imports: [
BrowserModule,
GlobalPayModule
],
providers: [],
bootstrap: [AppComponent]
})
@Component({
selector: 'your-component',
standalone: true,
imports: [GlobalPayModule],
templateUrl: './your-component.component.html',
styleUrls: ['./your-component.component.scss']
})
export class YourComponent {
}
Use the component
Use the globalpay component in your template:
<globalpay
[apiKey]="apiKey"
[payload]="payload"
[buttonStyle]="buttonStyle"
[buttonText]="buttonText"
(onError)="onError($event)"
>
</globalpay>
@Component({
selector: 'your-component',
templateUrl: './your-component.component.html',
styleUrls: ['./your-component.component.scss']
})
payload: GeneratePaymentLinkPayload = {
amount: 1500,
merchantTransactionReference: "your transaction reference",
customer: {
lastName: "Doe",
firstName: "John",
currency: "NGN",
address: "string",
};
buttonStyle = {
'background': 'red',
'font-size': '16px'
// other styles
};
onError(error: GeneratePaymentLinkError){
console.log(error)
}
Vue
VueJs library for integrating GlobalPay Payment Gateway into VueJs applications
Project Setup
To use packages from Azure Artifacts, configure your project to reference this feed.
Create a new text file called “.npmrc” in the same directory as your package.json, then copy the
snippet below
@zenith/registry=https://pkgs.dev.azure.com/ZBPlc/ZenithSDKs/_packaging/ZenithSDKFeed/np
m
Installation
npm install @zenith/globalpay-vue
Sample Usage
Import the GlobalPay Component (and Payload Type if you're using Typescript)
amount: 200,
merchantTransactionReference: "your-reference",
redirectUrl: "www.google.com",
customer: {
lastName: "customerfirstname",
firstName: "customerlastname",
currency: "NGN",
phoneNumber: "081000000000",
address: "",
};
const style = {
background: 'green',
color: 'yellow'
};
</script>
<template>
<GlobalPay
:isLive="false"
:apiKey="'your-api-key'"
:buttonText="'Pay'"
:buttonStyle="style"
:payload="payload"
:onError="erroHandler"
/>
</template>
Javascript
Plain Javascript library for integrating GlobalPay Payment Gateway into websites.
Sample Usage
Add a script tag as part of your header with link below as source
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="{link}/globalpay-javascript-library/dist/globalpay-library.js"></script>
</head>
<body>
<script>
function errorHandler(error){
window.alert(error.message);
function pay(){
let payload = {
"amount": 200,
"merchantTransactionReference": "your-reference",
"redirectUrl": "your-redirect-url",
"customer": {
"lastName": "CustomerFirstName",
"firstName": "CustomerLastName",
"currency": "NGN",
"phoneNumber": "customerphone",
"address": "string",
};
try{
}catch(error){
console.log(error.message);
</script>
</body>
</html>
WEBHOOKS
Webhook
1. Webhook url is set up on the globalpay dashboard by the merchant during activation.
2. For every transaction, a notification is sent via this webhook, for every successful and failed
transaction.
3. There must be a connection establishment using the public key.
4. There is encryption using the AES algorithm.
a. length - 16bytes
b. Decryption key - merchant public key
Decryption Engine:
result = Encoding.UTF8.GetString(msDecrypt.ToArray());
}
return result;
}
}
}
catch(Exception ex)
{
return
string.IsNullOrWhiteSpace(ex.Message)?ex?.InnerException.Message:ex.Message;
}
}
}
else
{
response.Status = false;
response.ResponseDescription = "Request was not
successful";
response.ResponseCode = "99";
}
return response;
}
(2) Data Contracts:
}
(b) Response Model:
public class WebhookResponse
{
public string ResponseCode { get; set; }
public string ResponseDescription { get; set; }
public bool Status { get; set; }
5. Status -
6. Response code:
a. If 00 = Successful
b. if 99 = Unsuccessful
anyone.