Skip to main content

Chargent Order Unlinked Refund


An unlinked refund transaction may be used to apply a refund to a credit card without a prior transaction.



  1. The payment gateway must support credit card unlinked refunds without a prior transaction.
  2. The Gateway Setup Wizard advanced settings must be used to connfigure the payment gateway.
  3. A Chargent Order must be created with the Charge Amount field set to the amount to refund to the credit card.
  4. A Payment Method with credit card type must be related to the Chargent Order.


There are multiple prerequisite resources that must be created before requesting an unlinked refund.

           Object           Definition
Chargent OrderChargent Orders are central objects to payments lifecycle management.
Payment MethodPayment Methods are instruments that may be used to make or take payment.


PreconditionExpected Result
Create One-Time Chargent OrderA Chargent Order is created for a one-time payment.
Create Payment Method Tokenization A Payment Method Tokenization is created with a credit card type.
Assign Payment Method to Chargent Order A Payment Method with a credit card type is assigned to a Chargent Order.

Create Chargent Order Unlinked Refund

Apex Example
try {
// Get the last Chargent Order to use
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];
Id lastChargentOrderId = lastChargentOrder.Id;

try {
Map<String, Object> paymentRefundMap = new Map<String, Object>();
paymentRefundMap.put('ObjectId', lastChargentOrderId);
paymentRefundMap.put('CustomTransactionType', 'PartialRefund');
paymentRefundMap.put('CustomOperation', 'UnlinkedRefund');
paymentRefundMap.put('Amount', 50.00);

Map<String, Object> actionsMap = new Map<String, Object>();
actionsMap.put('data', paymentRefundMap);
actionsMap.put('action', 'Refund');
actionsMap.put('feature', 'APEX');
String actionResponse = ChargentBase.ActionService.getService().performAction(JSON.serialize(actionsMap));
Map<String, Object> actionResponseMap = (Map<String, Object>) JSON.deserializeUntyped(actionResponse);

// process request
if (actionResponseMap.get('operationSuccess') == false) {
// Failure
System.debug('Chargent Order Unlinked Refund create error.');
} else {
// Success
System.debug('Chargent Order Unlinked Refund created successfully.');
} catch (Exception e) {
System.debug('Error creating Unlinked Payment Refund: ' + e.getMessage());
} catch (Exception e) {
System.debug('Error getting Chargent Order: ' + e.getMessage());

Learn More

Learn more about Unlinked Refunds.