The OnePay JavaScript SDK provides an easy and lightweight way to load and display available payment gateways in your application.
Include the SDK in your project:
<script src="https://one-pay.info/api/sdk.js"></script>document.getElementById('loadPaymentMethods').addEventListener('click', function() {
if (window.OnePayLib) {
// Initialize the SDK using your Merchant API key
// Paste here your merchant account id from one pay
window.OnePayLib.initialize('<merchant id>');
// Fetch available payment methods
window.OnePayLib.getPaymentMethods()
.then(methods => {
console.log('Payment Methods:', methods);
})
.catch(error => {
console.error('Error loading payment methods:', error);
});
} else {
console.error('OnePay SDK is not loaded.');
}
});{
"status": 1,
"message": [
"jawali",
"cashpay",
"paypal"
]
}| Item | Description |
|---|---|
OnePayLib.initialize(MERCHANT KEY) |
Activates the SDK using your MERCHANT API key. |
OnePayLib.getPaymentMethods() |
Returns the list of available payment gateways. |
window.OnePayLib |
Ensures the SDK has been loaded before calling methods. |
No additional libraries required β simply include the SDK script and start using it.
- Make sure you have a valid Merchant API Key before calling the SDK.
- A successful response includes
"status": 1. - The
messagearray contains the available payment gateways returned from the API.