Skip to content

chargeafter-rnd/sdk

Repository files navigation

ChargeAfter payment SDK


Installing

npm install --save @chargeafter/payment-sdk

Getting Started

import { prequalify, checkout } from "@chargeafter/payment-sdk";

// open modal to obtain available credit
prequalify({
    config: {
        env: {
            name?: "production" | "sandbox", // defaults to "production"
            apiKey: "<your api key>",
        }
    },
    ...
}).then((result: CompletionApplyData)  => {
    // Fires when apply flow finished
}).catch((ex: { code: String, message: string, data: CompletionApplyData }) => {
    // Fires when apply flow finishes un-successfully
});

// open modal to perform full checkout
checkout({
    config: {
        env: {
            name?: "production" | "sandbox", // defaults to "production"
            apiKey: "<your api key>",
        }
    },
    cartDetails: ...
    ...
}).then((result: CompletionCheckoutData)  => {
    // Fires when apply flow finished
}).catch((ex: { code: String, message: string, data: CompletionCheckoutData }) => {
    // Fires when apply flow finishes un-successfully
});;

Check Docs for detailed callback interface for apply and checkout