onah-payment-sdk v0.0.9
Onah Payment SDK User Guide
Collect payment on your web page using Onah Payment SDK
Installation
npm i onah-payment-sdk
# or
yarn add onah-payment-sdk
Usage
import the package
import {OnahSdk} from 'onah-payment-sdk';
Create a new OnahSdk instance
const onahSdk = new OnahSdk();
Then create a new transaction
try {
const createResponse = await onahSdk.createTransaction(
{
currency: "NGN",
env: 'prod',
amount: 1000,
customer: {
firstName: "John",
lastName: "Doe10",
email: "john@onah.africa",
phoneNumber: "+234703000000",
address: 'My address',
city: 'Lagos',
country: 'NG',
state: 'Lagos',
zipCode: '1234'
},
merchantId: '3Kv1p6r',
metadata: {
item: 'Iphone 14 pro'
}
},
);
// handle Payment success
} catch (err) {
// handle payment failed or cancelled
}
Properties
Property | Description | Type | Required | Data type |
---|---|---|---|---|
currency | Transaction currency | NGN | NO | string |
amount | Amount to be charged | N/A | YES | number |
merchantId | The Onah Id assigned to your account | N/A | YES | string |
env | The sdk Environment | prod | NO | prod | sandbox |
metadata | An object you can send data like product name item to your dashboard | N/A | NO | object |
customer | The customer object creates a new customer on your dashboard | N/A | NO | object |
customerId | Instead of creating a new customer you can send existing customer Id | N/A | NO | string |
metadata
The
metadata
property is an optional field that allows you to add additional information about their transactions in key value pairs format. This data will also be | Property | Description | Default Value | Required | Data type | | --- | --- | --- | --- | --- | | item | A simple description / name of product which the transaction belongs to | N/A | NO | string
customer
The
customer
property is an optional field that allows you to create a new customer | Property | Description | Default Value | Required | Data type | | --- | --- | --- | --- | --- | | address | Customer Address | N/A | YES | string | | city | Customer City | N/A | YES | string | | country | Customer country | N/A | YES | string | | email | Customer email (A unique value) | N/A | YES | string | | firstName | Customer first name | N/A | YES | string | | lastName | Customer last name | N/A | YES | string | | phoneNumber | Customer phone number (A unique value) | N/A | YES | string | | state | Customer state | N/A | YES | string | | zipCode | Customer zip code | N/A | YES | string |
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago