0.927.0 • Published 2 years ago

payzorxsdk v0.927.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Sure! Here are the instructions with Markdown tags:

Payzorx SDK

This is the SDK for integrating Payzorx payments into your ecommerce site.

Installation

You can install the Payzorx SDK via npm:

Copy code

npm install Payzorx-sdk

Usage

To use the Payzorx SDK, you need to first create a Payzorx instance with your API key:

javascriptCopy code

import Payzorx from 'Payzorx-sdk';  

const Payzorx = new Payzorx('your-api-key');

Once you have a Payzorx instance, you can use the pay method to initiate a payment. The pay method accepts an options object with information about the product to be purchased, the customer making the purchase, and any customizations to the payment screen:

import Payzorx from 'Payzorx-sdk';  

interface PayzorxProductInfo {
    amount: number;
    currency: string;
    name: string;
    description: string; 
}  

interface PayzorxCustomerInfo { 
    email: string;
} 

interface PayzorxCustomizations {
    title?: string;
    description?: string;
    logo?: string;
}

interface PayzorxOptions {
    apiKey: string;
    product: PayzorxProductInfo;
    meta?: Record<string, any>;
    customer: PayzorxCustomerInfo;
    customizations?: PayzorxCustomizations;
}

const Payzorx = new Payzorx('your-api-key');  
const options: PayzorxOptions = {
    apiKey: 'XXXX....',
    product: {
        amount: 10,
        currency: 'USD',
        name: 'T-shirt',
        description: 'Comfortable cotton t-shirt',
    },   
    meta: {},
    customer: {
        email: 'cornelius@gmail.com',
    },
    customizations: {
        title: 'My store',     
        description: 'Payment for items in cart',
        logo: 'https://assets.piedpiper.com/logo.png',
    },
};

Payzorx
    .pay(options)
    .then((result) => {
        // Payment succeeded, handle the result   
    }).catch((error) => {
        // Payment failed, handle the error
    });
}

The pay method returns a Promise that resolves when the payment is complete, with information about the payment result. If the payment fails, the Promise will be rejected with an error.

Note that the pay method opens a new window to the Payzorx checkout page, where the user can complete the payment. Once the payment is complete, the checkout page will close automatically, and the Promise will be resolved or rejected.

License

This SDK is released under the MIT License.

0.927.0

2 years ago

0.926.0

2 years ago

0.925.0

2 years ago

0.924.0

2 years ago

0.923.0

2 years ago

0.922.0

2 years ago

0.921.0

2 years ago

0.91.0

2 years ago

0.9.0

2 years ago

0.8.0

2 years ago

0.7.0

2 years ago

0.5.0

2 years ago

0.4.0

2 years ago

0.3.0

2 years ago

0.1.0

2 years ago