Documentation Index Fetch the complete documentation index at: https://developers.orchestrasolutions.com/llms.txt
Use this file to discover all available pages before exploring further.
This page is part of the Payments Library Guides . Prefer direct API calls instead? See REST API Guides .
Prerequisites: Complete the Library Setup first.
All payment methods return results through the same callback function. This page covers how to parse results, check for success, and handle different payment types.
Parsing Results
Use parseResultToken() to decode the result token:
function handleResult ( result ) {
// User cancelled
if ( ! result ) {
console . log ( 'Payment cancelled' );
return ;
}
const [ data , success ] = engine . parseResultToken ( result . token );
console . log ( 'Payment result:' , data );
}
The method returns a tuple:
data - The parsed result object
success - Boolean indicating if the token was decoded (not whether payment succeeded)
Checking Payment Success
Always check clientSuccess first:
if ( ! data . clientSuccess ) {
console . error ( 'Payment failed:' , data . clientErrorMessage );
return ;
}
// Payment succeeded - check result type
Result Types
Results vary based on the payment method used:
PSP Results (CardPay, Apple Pay, Google Pay)
Card-based payments return results through upgChargeResults:
if ( data . upgChargeResults ) {
const charge = data . upgChargeResults ;
if ( charge . operationResultCode === 'Success' ) {
console . log ( 'Payment approved' );
console . log ( 'Gateway:' , charge . gatewayName );
console . log ( 'Reference:' , charge . gatewayReference );
console . log ( 'Auth code:' , charge . authorizationCode );
console . log ( 'Amount:' , charge . amount , charge . currency );
} else {
console . log ( 'Payment declined:' , charge . operationResultDescription );
}
}
Available fields:
Field Description gatewayNameName of the payment gateway gatewayReferenceGateway’s transaction reference authorizationCodeAuthorization code from issuer amountCharged amount currencyCurrency code operationResultCodeSuccess, Rejected, ErroroperationResultDescriptionHuman-readable result message gatewayResultDescriptionMessage from the gateway
Direct Results (PayPal, BankPay, UPI)
Redirect-based payments return results through directChargeResults:
if ( data . directChargeResults ) {
if ( data . directChargeResults . success ) {
console . log ( 'Payment successful' );
} else {
console . log ( 'Payment failed:' , data . directChargeResults . message );
}
}
Tokenization Results
When using TOKENIZE or CHARGE_AND_TOKENIZE, card details are returned in tokenAndMaskedCardModel:
if ( data . tokenAndMaskedCardModel ) {
const tokenData = data . tokenAndMaskedCardModel ;
console . log ( 'Token:' , tokenData . token );
console . log ( 'Card type:' , tokenData . bankCard . type );
console . log ( 'Masked number:' , tokenData . bankCard . number );
console . log ( 'Expires:' , tokenData . bankCard . expirationMonth + '/' + tokenData . bankCard . expirationYear );
console . log ( 'Name:' , tokenData . bankCard . nameOnCard );
}
Complete Example
async function handleResult ( result ) {
// User cancelled
if ( ! result ) {
showMessage ( 'Payment cancelled' , 'info' );
return ;
}
const [ data ] = engine . parseResultToken ( result . token );
// Check overall success
if ( ! data . clientSuccess ) {
showMessage ( 'Payment failed: ' + data . clientErrorMessage , 'error' );
return ;
}
// Handle PSP results (CardPay, Apple Pay, Google Pay)
if ( data . upgChargeResults ) {
if ( data . upgChargeResults . operationResultCode === 'Success' ) {
showMessage ( 'Payment successful! Reference: ' + data . upgChargeResults . gatewayReference , 'success' );
} else {
showMessage ( 'Payment declined: ' + data . upgChargeResults . operationResultDescription , 'error' );
}
}
// Handle direct results (PayPal, BankPay, UPI)
if ( data . directChargeResults ) {
if ( data . directChargeResults . success ) {
showMessage ( 'Payment successful!' , 'success' );
} else {
showMessage ( 'Payment failed: ' + data . directChargeResults . message , 'error' );
}
}
// Server-side validation (recommended)
await validateWithServer ( result . token );
}
Server-Side Validation
Always validate results on your server before fulfilling orders:
// Client-side
async function validateWithServer ( resultToken ) {
const response = await fetch ( '/api/validate-payment' , {
method: 'POST' ,
headers: { 'Content-Type' : 'application/json' },
body: JSON . stringify ({ resultToken })
});
const validation = await response . json ();
console . log ( 'Server validation:' , validation );
}
// Server-side (Node.js)
app . post ( '/api/validate-payment' , async ( req , res ) => {
const { resultToken } = req . body ;
const response = await fetch ( 'https://api.orchestrasolutions.com/EWalletOperations/validateResults' , {
method: 'POST' ,
headers: {
'X-Api-Key' : process . env . ORCHESTRA_API_KEY ,
'Content-Type' : 'application/json'
},
body: JSON . stringify ( resultToken )
});
const validationResult = await response . json ();
if ( validationResult . clientSuccess ) {
// Payment confirmed - fulfill the order
res . json ({ success: true });
} else {
res . json ({ success: false , error: validationResult . clientErrorMessage });
}
});
Getting Selected Payment Method
Use getSelectedProviderName() to know which payment method the customer used:
function handleResult ( result ) {
const provider = engine . getSelectedProviderName ();
console . log ( 'Customer paid with:' , provider );
// "CardPay", "ApplePay", "GooglePay", "PayPal", "BankPay", or "UPI"
}
Library Reference Full API reference
Complete Example End-to-end integration
Start Session API Create a session token
Validate Results API Server-side validation endpoint