alexnpmtest1 v1.0.65
WhenThenSDK
WhenThen payment checkout Module
This is a JavaScript module that can be used to include payment checkout tracking code in a website or app that uses React, Angular, Vue for its front-end codebase.
Installation
With npm:
npm install whenThen --save
With yarn:
yarn add whenThen
Usage
With npm
Initializing WhenThen :
import WhenThen from 'whenThen';
WhenThen.init({
id: "whenThenPublicId"
});
Demo Code
For a working demo examples clone this repo and check the implementation to the framework you are interested in. Demo requires you to have your own WhenThen public ID.
API
WhenThen.init(WhenThenPublicId, options)
WhenThen must be initialized using this function before any checkout events emitted.
Example
WhenThen.init("1111111", {
mockRequestData: true,
});
Value | Notes |
---|---|
whenThenPublicId | String . Required. WhenThen public ID like a1dsD*1kL3 . |
options.mockRequestData | Boolean . Optional. If set to true , payload data for checkout events will be mocked. |
WhenThen.startCheckout(fieldsObject)
Will save emitted payment checkout data.
Example
WhenThen.startCheckout({
trackingId: "88e5b224-1319-4040-9e43-c843372acfe1",
amount: {
rawAmount: 111,
currency: 'USD'
}
});
Value | Notes |
---|---|
trackingId | String . Required. requires to track checkout event in your db. |
amount | Object . Required. Data will be shown in WhenThen payment checkout details |
amount.rawAmount | Number . Payment value |
amount.currency | String . Payment currency one of 'USD', 'EUR' |
WhenThen.updateCheckout(fieldsObject)
Will save emitted payment checkout data.
Example
WhenThen.updateCheckout({
guestCheckout: true,
amount: {
rawAmount: 111,
currency: 'USD'
},
paymentIntent: {
attempted: true,
outcome: 'SUCCESS',
paymentInstrument: 'CARD'
},
shipping: {
attempted: true
},
delivery: {
attempted: true
}
});
Value | Notes |
---|---|
amount | Object . Optional. Data will be shown in WhenThen payment |
checkout details | |
amount.rawAmount | Number . Payment value in unit amounts |
amount.currency | String . Payment currency |
paymentIntent | Object . Optional. Send if payment process started |
paymentIntent.paymentInstrument | String . Payment method e.g. CARD ,STRIPE etc. |
paymentIntent.outcome | String . Payment result one of |
'SUCCESSFUL', 'REFUSED', 'DECLINED', 'ERROR', 'CANCELLED' | |
paymentIntent.attempted | Boolean . Payment if payment attempt started |
WhenThen.completeCheckout()
Will complete payment checkout process.
Example
WhenThen.completeCheckout();
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago