Skip to content

Latest commit

Β 

History

History
86 lines (59 loc) Β· 2.13 KB

File metadata and controls

86 lines (59 loc) Β· 2.13 KB

πŸ“¦ OnePay JavaScript SDK


Simple & Fast Payment Gateway Loader

The OnePay JavaScript SDK provides an easy and lightweight way to load and display available payment gateways in your application.


πŸ”— JavaScript SDK – Required Script

Include the SDK in your project:

<script src="https://one-pay.info/api/sdk.js"></script>

πŸš€ Usage Example

Load payment gateways using getPaymentMethods()

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.');
    }

});

πŸ“₯ Sample JSON Response

{
    "status": 1,
    "message": [
        "jawali",
        "cashpay",
        "paypal"
    ]
}

πŸ“˜ Quick Explanation

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.

πŸ›  Requirements

No additional libraries required β€” simply include the SDK script and start using it.


πŸ’‘ Notes

  • Make sure you have a valid Merchant API Key before calling the SDK.
  • A successful response includes "status": 1.
  • The message array contains the available payment gateways returned from the API.