Complete Checkout
Getting Started | Initialise Deko Wallet | Show Finance Info | Start Checkout | Complete Checkout | Confirm Order | Test Data
7. Customer Completes Checkout
Upon successful checkout (using the selected finance product to complete a purchase), the checkout method resolves, whereas if the checkout is unsuccessful (the purchase using the selected finance product is rejected) then the method rejects.
The checkout method resolves to either a receipt object or a string. The table below shows all the specific values the checkout method can resolve to, as well as what they imply for the checkout journey.
A receipt object will be given when the customer has completed all steps for the selected finance product successfully. All steps will have been completed on the Deko Wallet page.
A 'redirected' string will be given when the user has successfully completed all necessary steps on the Deko Wallet page, though have then been redirected to a lender to complete additional steps.
A 'referred' string will be given when the user has completed all steps on the Deko Wallet page, but have been referred to the lender for manual review.
If the checkout is unsuccessful, the checkout method will not resolve, but instead will throw an error. All cases can be captured in the example below.
const checkoutValue = wallet.checkout(cac)
.then((resolvedValue) => {
switch(resolvedValue) {
case 'redirected':
// This will happen only when redirected
console.log('REDIRECTED');
break;
case 'referred':
// This will happen only when referred
console.log('REFERRED');
break;
default:
// SEE the decoded receipt JWT example in the next window
console.log('SUCCESS ====', resolvedValue);
// This will happen only on a payment success
return resolvedValue;
}
})
.catch((e) => {
console.log('FAILURE ====', e.message);
alert(`FAILURE - ${e.message}`);
// This will happen when either the customer does not meet credit lending qualification or their deposit payment card has been declined
});Updated over 1 year ago
