3.2.2 • Published 3 years ago

st-payment-handlers v3.2.2

Weekly downloads
209
License
ISC
Repository
-
Last release
3 years ago

Shoptype Payment Handlers

st-payment-handlers

This package allows for seamless integration of payment gateways in a custom checkout flow of a store (as part of Shoptype).

The following gateways are currently supported

  • Razorpay
  • Stripe
  • Authorize

Installation

This will install the latest version of the package and pull in the necessary dependencies.

npm i st-payment-handlers@latest --save

The script automatically loads necessary dependencies (JS lib files) for the payment gateway to be invoked.

Importing

ES6

import initSTPayment from 'st-payment-handlers';

Vanilla JS

<script src="{URL to bundle.js}/bundle.js" />

Usage

The appropriate payment gateway can be invoked by calling the following method:

initSTPayment(checkoutId, apiUrl, apiKey, callbackFunc)

It is an async method and returns a promise which can be awaited and the arguements required for it to function are detailed as follows:

ArgumentDescription
checkoutIdA checkout must be created from a cart, before the user is allowed to proceed to payment, this checkoutId is an identifier for the createed checkout
apiUrlThe env URL to Shoptype's backend services
apiKeyThe Shoptype API key, which has to be generated on Shoptype
callbackFuncThe callback function, which will be invoked after the payment process is complete
useAuthNetSandbox (false by default)Optional parameter, pass it as true if Authorize.NET sandbox JS has to be used

Callback function

callbackFunc = (payload) => { }

The callback function's signature must accept a payload as an argument. The initSTPayment method will invoke the callback function, when the payment process completes with appropriate response.

The payload's schema with example values is as follows:

payload: {
    status: "failed"/"success"/"closed",
    message: "Error while initiating payment"/"Payment Successful", //etc.
    transactionId: "ABC123-123" //returned only when payment goes through
}
3.2.2

3 years ago

3.2.1

3 years ago

3.0.3

3 years ago

3.2.0

3 years ago

3.1.0

3 years ago

3.0.2

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.2.1

3 years ago

2.2.0

3 years ago

2.2.2

3 years ago

2.1.7

3 years ago

2.1.6

3 years ago

2.1.4

3 years ago

2.1.5

3 years ago

2.1.3

3 years ago

2.1.2

3 years ago

2.1.1

3 years ago

2.0.2

3 years ago

2.1.0

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.3.0

3 years ago

1.2.9

3 years ago

1.2.8

3 years ago

1.2.7

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.0

3 years ago

1.2.1

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago