Skip to content

onepay-ye/OnePay-JavaScript-SDK

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 

Repository files navigation

πŸ“¦ 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.

About

JavaScript Web SDK

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published