0.20.0 • Published 2 years ago

payzorsdk v0.20.0

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

Sure! Here are the instructions with Markdown tags:

Payzor SDK

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

Installation

You can install the Payzor SDK via npm:

Copy code

npm install payzor-sdk

Usage

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

javascriptCopy code

import Payzor from 'payzor-sdk';  

const payzor = new Payzor('your-api-key');

Once you have a Payzor 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 Payzor from 'payzor-sdk';  

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

interface PayzorCustomerInfo { 
    email: string;
} 

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

interface PayzorOptions {
    apiKey: string;
    product: PayzorProductInfo;
    meta?: Record<string, any>;
    customer: PayzorCustomerInfo;
    customizations?: PayzorCustomizations;
}

const payzor = new Payzor('your-api-key');  
const options: PayzorOptions = {
    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',
    },
};

payzor
    .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 Payzor 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.20.0

2 years ago

0.19.0

2 years ago

0.18.0

2 years ago

0.17.0

2 years ago

0.16.0

2 years ago

0.15.0

2 years ago

0.14.0

2 years ago

0.13.0

2 years ago

0.12.0

2 years ago

0.11.0

2 years ago

0.1.0

2 years ago