Payment Sale
Overview
A payment sale will result in a bank account debit for payment methods with bank account type, and a credit card authorization and capture for payment methods with credit card type.
Prerequisite Resources
There are multiple prerequisite resources depending on the call method that must be created before requesting a payment sale.
| Object | Definition |
|---|---|
| Account | Salesforce standard Account object. |
| Chargent Order | Chargent Orders are central objects to payments lifecycle management. |
| Payment Method | Payment Methods are instruments that may be used to make or take payment. |
| Payment Gateway | Payment Gateways track all the configuration settings that Chargent will use to proccess the payments and send requests to the gateway. |
Create Methods
There are multiple methods available using input data to create a payment sale. A payment gateway must exist for all create payment sale methods.
| Prerequisites | Input | Output |
|---|---|---|
| Chargent Order, Payment Method (Assigned) | chargentOrderID | Chargent Transaction |
| Chargent Order | chargentOrderID, paymentGatewayId | Payment Method Tokenization, Chargent Transaction |
| Chargent Order, Payment Method | chargentOrderID, paymentMethodId, paymentGatewayId | Chargent Transaction |
| Chargent Order, Payment Method | chargentOrderID, paymentMethodId | Chargent Transaction |
| Account | accountId, paymentGatewayId | Payment Method Tokenization, Chargent Transaction |
| Account, Payment Method | accountId, paymentMethodId, paymentGatewayId | Chargent Transaction |
Transaction Fields
Learn more about Chargent Transaction Fields.
Create Payment Sale
chargentOrderId
Apex Example
try {
ChargentOrders__ChargentOrder__c lastChargentOrder = [SELECT Id, ChargentOrders__Account__c, ChargentOrders__Payment_Method_Default__c FROM ChargentOrders__ChargentOrder__c WHERE ChargentOrders__Payment_Descriptor__c LIKE 'Chargent Test%' ORDER BY CreatedDate DESC LIMIT 1];
try {
Map<String, Object> paymentSaleMap = new Map<String, Object>();
paymentSaleMap.put('chargentOrderId', lastChargentOrder.Id);
paymentSaleMap.put('amount', 800.00); //optional
paymentSaleMap.put('currencyIsoCode', 'USD'); //optional
paymentSaleMap.put('comments', 'Chargent Test Payment Sale orderId'); //optional
Map<String, Object> actionsMap = new Map<String, Object>();
actionsMap.put('data', paymentSaleMap);
actionsMap.put('action', 'Sale');
actionsMap.put('feature', 'APEX');
String actionResponse = ChargentBase.ActionService.getService().performAction(JSON.serialize(actionsMap));
Map<String, Object> actionResponseMap = (Map<String, Object>) JSON.deserializeUntyped(actionResponse);
// process response
if (actionResponseMap.get('operationSuccess') == false) {
// Failure
try {
System.debug('Payment Sale create error.');
// unpack the message
List<Object> operationResponsesList = (List<Object>) actionResponseMap.get('operationResponsesList');
Map<String, Object> operationResponseItem = (Map<String, Object>) operationResponsesList.get(0);
// debug chargent error
Map<String, Object> errorItem = (Map<String, Object>) operationResponseItem.get('errorItem');
String chargentErrorType = (String) errorItem.get('errorType');
System.debug('Chargent Error Type: ' + chargentErrorType);
String chargentErrorMessage = (String) errorItem.get('message');
System.debug('Chargent Error Message: ' + chargentErrorMessage);
// debug gateway error
Map<String, Object> gatewayResponseMap = (Map<String, Object>) operationResponseItem.get('gatewayResponseMap');
Map<String, Object> gateway = (Map<String, Object>) gatewayResponseMap.get('unique');
Map<String, Object> calloutResponse = (Map<String, Object>) gateway.get('webOutPut');
String gatewayStatus = (String) calloutResponse.get('Status');
System.debug('Gateway Status: ' + gatewayStatus);
String gatewayMessage = (String) calloutResponse.get('Message');
System.debug('Gateway Message: ' + gatewayMessage);
String gatewayReasonCode = (String) calloutResponse.get('ReasonCode');
System.debug('Gateway Code: ' + gatewayReasonCode);
} catch (Exception e) {
System.debug('Error unpacking Action Service response: ' + e.getMessage());
}
} else {
// Success
System.debug('Payment Sale created successfully.');
}
} catch (Exception e) {
System.debug('Error creating Payment Sale: ' + e.getMessage());
}
} catch (Exception e) {
System.debug('Error getting Chargent Order: ' + e.getMessage());
}
chargentOrderId, paymentGatewayId
Apex Example
try {
ChargentBase__Gateway__c paymentGateway = [SELECT Id FROM ChargentBase__Gateway__c WHERE Name = 'Stripe Test' LIMIT 1];
try {
ChargentOrders__ChargentOrder__c lastChargentOrder = [SELECT Id, ChargentOrders__Account__c, ChargentOrders__Payment_Method_Default__c FROM ChargentOrders__ChargentOrder__c WHERE ChargentOrders__Payment_Descriptor__c LIKE 'Chargent Test%' ORDER BY CreatedDate DESC LIMIT 1];
try {
// initialize variables
String phone = '{{$randomPhoneNumber}}';
String email = '{{$randomeEmail}}';
String cardNumber = '{{cardNumber}}';
String cardType = '{{cardType}}';
String cvv = '{{cvv}}';
String expiryMonth = String.valueOf(Date.today().month());
String expiryYear = String.valueOf(Date.today().year() + 3);
// credit card payment data
Map<String,Object> cardPaymentMethodMap = new Map<String, Object>();
cardPaymentMethodMap.put('cardType', cardType);
cardPaymentMethodMap.put('cardNumber', cardNumber);
cardPaymentMethodMap.put('expiryMonth', expiryMonth);
cardPaymentMethodMap.put('expiryYear', expiryYear);
cardPaymentMethodMap.put('cvv', cvv);
cardPaymentMethodMap.put('cardHolderName', 'Chargent Test');
cardPaymentMethodMap.put('cardHolderFirstName', 'Chargent');
cardPaymentMethodMap.put('cardHolderLastName', 'Test');
// billing address
Map<String,Object> addressMap = new Map<String, Object>();
addressMap.put('street', '123 Street St');
addressMap.put('state', 'California');
addressMap.put('city', 'San Francisco');
addressMap.put('postalcode', '94105');
addressMap.put('country', 'US');
addressMap.put('companyName', 'Chargent Test');
// payment method tokenization
Map<String,Object> paymentRequestMap = new Map<String, Object>();
paymentRequestMap.put('cardPaymentMethod', cardPaymentMethodMap);
paymentRequestMap.put('address', addressMap);
Map<String, Object> paymentSaleMap = new Map<String, Object>();
paymentSaleMap.put('chargentOrderId', lastChargentOrder.Id);
paymentSaleMap.put('paymentGatewayId', paymentGateway.Id);
paymentSaleMap.put('paymentMethod', paymentRequestMap);
paymentSaleMap.put('amount', 900.00); //optional
paymentSaleMap.put('currencyIsoCode', 'USD'); //optional
paymentSaleMap.put('comments', 'Chargent Test Payment Sale orderId gatewayId'); //optional
paymentSaleMap.put('phone', phone); // optional
paymentSaleMap.put('email', email); // optional
Map<String, Object> actionsMap = new Map<String, Object>();
actionsMap.put('data', paymentSaleMap);
actionsMap.put('action', 'Sale');
actionsMap.put('feature', 'APEX');
String actionResponse = ChargentBase.ActionService.getService().performAction(JSON.serialize(actionsMap));
Map<String, Object> actionResponseMap = (Map<String, Object>) JSON.deserializeUntyped(actionResponse);
// process response
if (actionResponseMap.get('operationSuccess') == false) {
// Failure
try {
System.debug('Payment Sale create error.');
// unpack the message
List<Object> operationResponsesList = (List<Object>) actionResponseMap.get('operationResponsesList');
Map<String, Object> operationResponseItem = (Map<String, Object>) operationResponsesList.get(0);
// debug chargent error
Map<String, Object> errorItem = (Map<String, Object>) operationResponseItem.get('errorItem');
String chargentErrorType = (String) errorItem.get('errorType');
System.debug('Chargent Error Type: ' + chargentErrorType);
String chargentErrorMessage = (String) errorItem.get('message');
System.debug('Chargent Error Message: ' + chargentErrorMessage);
// debug gateway error
Map<String, Object> gatewayResponseMap = (Map<String, Object>) operationResponseItem.get('gatewayResponseMap');
Map<String, Object> gateway = (Map<String, Object>) gatewayResponseMap.get('unique');
Map<String, Object> calloutResponse = (Map<String, Object>) gateway.get('webOutPut');
String gatewayStatus = (String) calloutResponse.get('Status');
System.debug('Gateway Status: ' + gatewayStatus);
String gatewayMessage = (String) calloutResponse.get('Message');
System.debug('Gateway Message: ' + gatewayMessage);
String gatewayReasonCode = (String) calloutResponse.get('ReasonCode');
System.debug('Gateway Code: ' + gatewayReasonCode);
} catch (Exception e) {
System.debug('Error unpacking Action Service response: ' + e.getMessage());
}
} else {
// Success
System.debug('Payment Sale created successfully.');
}
} catch (Exception e) {
System.debug('Error creating Payment Sale: ' + e.getMessage());
}
} catch (Exception e) {
System.debug('Error getting Chargent Order: ' + e.getMessage());
}
} catch (Exception e) {
System.debug('Error getting Payment Gateways: ' + e.getMessage());
}
chargentOrderId, paymentMethodId, paymentGatewayId
Apex Example
try {
ChargentBase__Gateway__c paymentGateway = [SELECT Id FROM ChargentBase__Gateway__c WHERE Name = 'Stripe Test' LIMIT 1];
try {
// Get the last payment method
ChargentBase__Payment_Method__c lastPaymentMethod = [SELECT Id FROM ChargentBase__Payment_Method__c WHERE ChargentBase__Name_on_Account__c = 'Chargent Test' ORDER BY CreatedDate DESC LIMIT 1];
try {
ChargentOrders__ChargentOrder__c lastChargentOrder = [SELECT Id, ChargentOrders__Account__c, ChargentOrders__Payment_Method_Default__c FROM ChargentOrders__ChargentOrder__c WHERE ChargentOrders__Payment_Descriptor__c LIKE 'Chargent Test%' ORDER BY CreatedDate DESC LIMIT 1];
try {
System.debug('Payment Sale create error.');
Map<String, Object> paymentSaleMap = new Map<String, Object>();
paymentSaleMap.put('paymentGatewayId', paymentGateway.Id);
paymentSaleMap.put('chargentOrderId', lastChargentOrder.Id);
paymentSaleMap.put('amount', 1000.00); // optional
paymentSaleMap.put('currencyIsoCode', 'USD'); //optional
paymentSaleMap.put('comments', 'Chargent Test Payment Sale orderId paymentMethodId gatewayId'); //optional
Map<String, Object> paymentMethodMap = new Map<String, Object>();
paymentMethodMap.put('id', lastPaymentMethod.Id);
paymentSaleMap.put('paymentMethod', paymentMethodMap);
Map<String, Object> actionsMap = new Map<String, Object>();
actionsMap.put('data', paymentSaleMap);
actionsMap.put('action', 'Sale');
actionsMap.put('feature', 'APEX');
String actionResponse = ChargentBase.ActionService.getService().performAction(JSON.serialize(actionsMap));
Map<String, Object> actionResponseMap = (Map<String, Object>) JSON.deserializeUntyped(actionResponse);
// process response
if (actionResponseMap.get('operationSuccess') == false) {
// Failure
try {
System.debug('Payment Sale create error.');
// unpack the message
List<Object> operationResponsesList = (List<Object>) actionResponseMap.get('operationResponsesList');
Map<String, Object> operationResponseItem = (Map<String, Object>) operationResponsesList.get(0);
// debug chargent error
Map<String, Object> errorItem = (Map<String, Object>) operationResponseItem.get('errorItem');
String chargentErrorType = (String) errorItem.get('errorType');
System.debug('Chargent Error Type: ' + chargentErrorType);
String chargentErrorMessage = (String) errorItem.get('message');
System.debug('Chargent Error Message: ' + chargentErrorMessage);
// debug gateway error
Map<String, Object> gatewayResponseMap = (Map<String, Object>) operationResponseItem.get('gatewayResponseMap');
Map<String, Object> gateway = (Map<String, Object>) gatewayResponseMap.get('unique');
Map<String, Object> calloutResponse = (Map<String, Object>) gateway.get('webOutPut');
String gatewayStatus = (String) calloutResponse.get('Status');
System.debug('Gateway Status: ' + gatewayStatus);
String gatewayMessage = (String) calloutResponse.get('Message');
System.debug('Gateway Message: ' + gatewayMessage);
String gatewayReasonCode = (String) calloutResponse.get('ReasonCode');
System.debug('Gateway Code: ' + gatewayReasonCode);
} catch (Exception e) {
System.debug('Error unpacking Action Service response: ' + e.getMessage());
}
} else {
// Success
System.debug('Payment Sale created successfully.');
}
} catch (Exception e) {
System.debug('Error creating Payment Sale: ' + e.getMessage());
}
} catch (Exception e) {
System.debug('Error getting Chargent Order: ' + e.getMessage());
}
} catch (Exception e) {
System.debug('Error getting Payment Method: ' + e.getMessage());
}
} catch (Exception e) {
System.debug('Error getting Payment Gateways: ' + e.getMessage());
}
chargentOrderId, paymentMethodId
Apex Example
try {
// Get the last payment method
ChargentBase__Payment_Method__c lastPaymentMethod = [SELECT Id FROM ChargentBase__Payment_Method__c WHERE ChargentBase__Name_on_Account__c = 'Chargent Test' ORDER BY CreatedDate DESC LIMIT 1];
try {
ChargentOrders__ChargentOrder__c lastChargentOrder = [SELECT Id, ChargentOrders__Account__c, ChargentOrders__Payment_Method_Default__c FROM ChargentOrders__ChargentOrder__c WHERE ChargentOrders__Payment_Descriptor__c LIKE 'Chargent Test%' ORDER BY CreatedDate DESC LIMIT 1];
try {
Map<String, Object> paymentSaleMap = new Map<String, Object>();
paymentSaleMap.put('chargentOrderId', lastChargentOrder.Id);
paymentSaleMap.put('amount', 1100.00); //optional
paymentSaleMap.put('currencyIsoCode', 'USD'); //optional
paymentSaleMap.put('comments', 'Chargent Test Payment Sale orderId paymentMethodId'); //optional
Map<String, Object> paymentMethodMap = new Map<String, Object>();
paymentMethodMap.put('id', lastPaymentMethod.Id);
paymentSaleMap.put('paymentMethod', paymentMethodMap);
Map<String, Object> actionsMap = new Map<String, Object>();
actionsMap.put('data', paymentSaleMap);
actionsMap.put('action', 'Sale');
actionsMap.put('feature', 'APEX');
String actionResponse = ChargentBase.ActionService.getService().performAction(JSON.serialize(actionsMap));
Map<String, Object> actionResponseMap = (Map<String, Object>) JSON.deserializeUntyped(actionResponse);
// process response
if (actionResponseMap.get('operationSuccess') == false) {
// Failure
try {
System.debug('Payment Sale create error.');
// unpack the message
List<Object> operationResponsesList = (List<Object>) actionResponseMap.get('operationResponsesList');
Map<String, Object> operationResponseItem = (Map<String, Object>) operationResponsesList.get(0);
// debug chargent error
Map<String, Object> errorItem = (Map<String, Object>) operationResponseItem.get('errorItem');
String chargentErrorType = (String) errorItem.get('errorType');
System.debug('Chargent Error Type: ' + chargentErrorType);
String chargentErrorMessage = (String) errorItem.get('message');
System.debug('Chargent Error Message: ' + chargentErrorMessage);
// debug gateway error
Map<String, Object> gatewayResponseMap = (Map<String, Object>) operationResponseItem.get('gatewayResponseMap');
Map<String, Object> gateway = (Map<String, Object>) gatewayResponseMap.get('unique');
Map<String, Object> calloutResponse = (Map<String, Object>) gateway.get('webOutPut');
String gatewayStatus = (String) calloutResponse.get('Status');
System.debug('Gateway Status: ' + gatewayStatus);
String gatewayMessage = (String) calloutResponse.get('Message');
System.debug('Gateway Message: ' + gatewayMessage);
String gatewayReasonCode = (String) calloutResponse.get('ReasonCode');
System.debug('Gateway Code: ' + gatewayReasonCode);
} catch (Exception e) {
System.debug('Error unpacking Action Service response: ' + e.getMessage());
}
} else {
// Success
System.debug('Payment Sale created successfully.');
}
} catch (Exception e) {
System.debug('Error creating Payment Sale: ' + e.getMessage());
}
} catch (Exception e) {
System.debug('Error getting Chargent Order: ' + e.getMessage());
}
} catch (Exception e) {
System.debug('Error getting Payment Method: ' + e.getMessage());
}
accountId, paymentGatewayId
Apex Example
try {
ChargentBase__Gateway__c paymentGateway = [SELECT Id FROM ChargentBase__Gateway__c WHERE Name = 'Stripe Test' LIMIT 1];
try {
ChargentOrders__ChargentOrder__c lastChargentOrder = [SELECT Id, ChargentOrders__Account__c, ChargentOrders__Payment_Method_Default__c FROM ChargentOrders__ChargentOrder__c WHERE ChargentOrders__Payment_Descriptor__c LIKE 'Chargent Test%' ORDER BY CreatedDate DESC LIMIT 1];
try {
// initialize variables
String phone = '{{$randomPhoneNumber}}';
String email = '{{$randomeEmail}}';
String cardNumber = '{{cardNumber}}';
String cardType = '{{cardType}}';
String cvv = '{{cvv}}';
String expiryMonth = String.valueOf(Date.today().month());
String expiryYear = String.valueOf(Date.today().year() + 3);
// credit card payment data
Map<String,Object> cardPaymentMethodMap = new Map<String, Object>();
cardPaymentMethodMap.put('cardType', cardType);
cardPaymentMethodMap.put('cardNumber', cardNumber);
cardPaymentMethodMap.put('expiryMonth', expiryMonth);
cardPaymentMethodMap.put('expiryYear', expiryYear);
cardPaymentMethodMap.put('cvv', cvv);
cardPaymentMethodMap.put('cardHolderName', 'Chargent Test');
cardPaymentMethodMap.put('cardHolderFirstName', 'Chargent');
cardPaymentMethodMap.put('cardHolderLastName', 'Test');
// billing address
Map<String,Object> addressMap = new Map<String, Object>();
addressMap.put('street', '123 Street St');
addressMap.put('state', 'California');
addressMap.put('city', 'San Francisco');
addressMap.put('postalcode', '94105');
addressMap.put('country', 'US');
addressMap.put('companyName', 'Chargent Test');
// payment method tokenization
Map<String,Object> paymentRequestMap = new Map<String, Object>();
paymentRequestMap.put('cardPaymentMethod', cardPaymentMethodMap);
paymentRequestMap.put('address', addressMap);
Map<String, Object> paymentSaleMap = new Map<String, Object>();
paymentSaleMap.put('accountId', lastChargentOrder.ChargentOrders__Account__c);
paymentSaleMap.put('paymentGatewayId', paymentGateway.Id);
paymentSaleMap.put('paymentMethod', paymentRequestMap);
paymentSaleMap.put('amount', 1200.00); //optional
paymentSaleMap.put('currencyIsoCode', 'USD'); //optional
paymentSaleMap.put('comments', 'Chargent Test Payment Sale accountId gatewayId'); //optional
paymentSaleMap.put('phone', phone); // optional
paymentSaleMap.put('email', email); // optional
Map<String, Object> actionsMap = new Map<String, Object>();
actionsMap.put('data', paymentSaleMap);
actionsMap.put('action', 'Sale');
actionsMap.put('feature', 'APEX');
String actionResponse = ChargentBase.ActionService.getService().performAction(JSON.serialize(actionsMap));
Map<String, Object> actionResponseMap = (Map<String, Object>) JSON.deserializeUntyped(actionResponse);
// process response
if (actionResponseMap.get('operationSuccess') == false) {
// Failure
try {
System.debug('Payment Sale create error.');
// unpack the message
List<Object> operationResponsesList = (List<Object>) actionResponseMap.get('operationResponsesList');
Map<String, Object> operationResponseItem = (Map<String, Object>) operationResponsesList.get(0);
// debug chargent error
Map<String, Object> errorItem = (Map<String, Object>) operationResponseItem.get('errorItem');
String chargentErrorType = (String) errorItem.get('errorType');
System.debug('Chargent Error Type: ' + chargentErrorType);
String chargentErrorMessage = (String) errorItem.get('message');
System.debug('Chargent Error Message: ' + chargentErrorMessage);
// debug gateway error
Map<String, Object> gatewayResponseMap = (Map<String, Object>) operationResponseItem.get('gatewayResponseMap');
Map<String, Object> gateway = (Map<String, Object>) gatewayResponseMap.get('unique');
Map<String, Object> calloutResponse = (Map<String, Object>) gateway.get('webOutPut');
String gatewayStatus = (String) calloutResponse.get('Status');
System.debug('Gateway Status: ' + gatewayStatus);
String gatewayMessage = (String) calloutResponse.get('Message');
System.debug('Gateway Message: ' + gatewayMessage);
String gatewayReasonCode = (String) calloutResponse.get('ReasonCode');
System.debug('Gateway Code: ' + gatewayReasonCode);
} catch (Exception e) {
System.debug('Error unpacking Action Service response: ' + e.getMessage());
}
} else {
// Success
System.debug('Payment Sale created successfully.');
}
} catch (Exception e) {
System.debug('Error creating Payment Sale: ' + e.getMessage());
}
} catch (Exception e) {
System.debug('Error getting Chargent Order: ' + e.getMessage());
}
} catch (Exception e) {
System.debug('Error getting Payment Gateways: ' + e.getMessage());
}
accountId, paymentMethodId, paymentGatewayId
Apex Example
try {
ChargentBase__Gateway__c paymentGateway = [SELECT Id FROM ChargentBase__Gateway__c WHERE Name = 'Stripe Test' LIMIT 1];
try {
// Get the last payment method
ChargentBase__Payment_Method__c lastPaymentMethod = [SELECT Id FROM ChargentBase__Payment_Method__c WHERE ChargentBase__Name_on_Account__c = 'Chargent Test' ORDER BY CreatedDate DESC LIMIT 1];
try {
ChargentOrders__ChargentOrder__c lastChargentOrder = [SELECT Id, ChargentOrders__Account__c, ChargentOrders__Payment_Method_Default__c FROM ChargentOrders__ChargentOrder__c WHERE ChargentOrders__Payment_Descriptor__c LIKE 'Chargent Test%' ORDER BY CreatedDate DESC LIMIT 1];
try {
Map<String, Object> paymentSaleMap = new Map<String, Object>();
paymentSaleMap.put('accountId', lastChargentOrder.ChargentOrders__Account__c);
paymentSaleMap.put('paymentGatewayId', paymentGateway.Id);
paymentSaleMap.put('amount', 1300.00);
paymentSaleMap.put('currencyIsoCode', 'USD');
paymentSaleMap.put('comments', 'Chargent Test Payment Sale accountId paymentMethodId gatewayId');
Map<String, Object> paymentMethodMap = new Map<String, Object>();
paymentMethodMap.put('id', lastPaymentMethod.Id);
paymentSaleMap.put('paymentMethod', paymentMethodMap);
Map<String, Object> actionsMap = new Map<String, Object>();
actionsMap.put('data', paymentSaleMap);
actionsMap.put('action', 'Sale');
actionsMap.put('feature', 'APEX');
String actionResponse = ChargentBase.ActionService.getService().performAction(JSON.serialize(actionsMap));
Map<String, Object> actionResponseMap = (Map<String, Object>) JSON.deserializeUntyped(actionResponse);
// process response
if (actionResponseMap.get('operationSuccess') == false) {
// Failure
try {
System.debug('Payment Sale create error.');
// unpack the message
List<Object> operationResponsesList = (List<Object>) actionResponseMap.get('operationResponsesList');
Map<String, Object> operationResponseItem = (Map<String, Object>) operationResponsesList.get(0);
// debug chargent error
Map<String, Object> errorItem = (Map<String, Object>) operationResponseItem.get('errorItem');
String chargentErrorType = (String) errorItem.get('errorType');
System.debug('Chargent Error Type: ' + chargentErrorType);
String chargentErrorMessage = (String) errorItem.get('message');
System.debug('Chargent Error Message: ' + chargentErrorMessage);
// debug gateway error
Map<String, Object> gatewayResponseMap = (Map<String, Object>) operationResponseItem.get('gatewayResponseMap');
Map<String, Object> gateway = (Map<String, Object>) gatewayResponseMap.get('unique');
Map<String, Object> calloutResponse = (Map<String, Object>) gateway.get('webOutPut');
String gatewayStatus = (String) calloutResponse.get('Status');
System.debug('Gateway Status: ' + gatewayStatus);
String gatewayMessage = (String) calloutResponse.get('Message');
System.debug('Gateway Message: ' + gatewayMessage);
String gatewayReasonCode = (String) calloutResponse.get('ReasonCode');
System.debug('Gateway Code: ' + gatewayReasonCode);
} catch (Exception e) {
System.debug('Error unpacking Action Service response: ' + e.getMessage());
}
} else {
// Success
System.debug('Payment Sale created successfully.');
}
} catch (Exception e) {
System.debug('Error creating Payment Sale: ' + e.getMessage());
}
} catch (Exception e) {
System.debug('Error getting Chargent Order: ' + e.getMessage());
}
} catch (Exception e) {
System.debug('Error getting Payment Method: ' + e.getMessage());
}
} catch (Exception e) {
System.debug('Error getting Payment Gateways: ' + e.getMessage());
}