st-payment-handlers v3.2.2
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:
Argument | Description |
---|---|
checkoutId | A 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 |
apiUrl | The env URL to Shoptype's backend services |
apiKey | The Shoptype API key, which has to be generated on Shoptype |
callbackFunc | The 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 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago