Skip to main content

Payment Authorization

Overview​

A payment authorization results in a hold on funds on future payment. Authorizations are for payment methods with credit card type only.

Prerequisite Resources​

There are multiple prerequisite resources depending on the call method that must be created before requesting a payment authorization.

           Object           Definition
AccountSalesforce standard Account object.
Chargent OrderChargent Orders are central objects to payments lifecycle management.
Payment MethodPayment Methods are instruments that may be used to make or take payment.
Payment GatewayPayment 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 authorization. A payment gateway must exist for all create payment authorization methods.

PrerequisitesInputOutput
Chargent Order, Payment Method (Assigned)chargentOrderIDChargent Transaction
Chargent OrderchargentOrderID, paymentGatewayIdPayment Method Tokenization, Chargent Transaction
Chargent Order, Payment MethodchargentOrderID, paymentMethodId, paymentGatewayIdChargent Transaction
Chargent Order, Payment MethodchargentOrderID, paymentMethodIdChargent Transaction
AccountaccountId, paymentGatewayIdChargent Order, Payment Method Tokenization, Chargent Transaction
Account, Payment MethodaccountId, paymentMethodId, paymentGatewayIdChargent Order, Chargent Transaction

Transaction Fields​

Learn more about Chargent Transaction Fields.

Create Payment Authorization​

Resource URL​

HTTP RequestURL
POST/services/apexrest/ChargentBase/payments/authorizations

chargentOrderId​

Request​

JSON Example
{
"amount": 200.00, // optional
"chargentOrderId": "{{orderId}}"
}

Response​

JSON Example
{
"paymentMethod": {
"tokens": [
{
"token": "{{token}}",
"id": "{{tokenId}}",
"gatewayId": "{{gatewayId}}"
}
],
"status": "Created",
"id": "{{paymentMethodId}}"
},
"logs": [
{
"interactionStatus": "APPROVED",
"id": "{{logId}}",
"gatewayResultCode": "100",
"gatewayId": "{{gatewayId}}",
"createdDate": "2023-12-06T20:26:54.000Z"
}
],
"gatewayResponse": {
"gatewayResultCodeDescription": "ACCEPT",
"gatewayResultCode": "100",
"gatewayMessage": "ACCEPT",
"gatewayDate": "2023-12-06T20:26:54.248Z",
"gatewayAvsCode": "X",
"gatewayAuthorizationCode": "{{authCode}}"
},
"paymentAuthorization": {
"status": "Approved",
"requestDate": "2023-12-06T20:26:54.248Z",
"paymentAuthorizationNumber": "{{authCode}}",
"id": "{{transactionId}}",
"effectiveDate": "2023-12-06T20:26:54.248Z",
"chargentOrderId": "{{orderId}}",
"amount": 200.0
}
}

chargentOrderId, paymentGatewayId​

Request​

JSON Example
{
"amount": 300.00, // optional
"chargentOrderId": "{{orderId}}",
"paymentGatewayId": "{{gatewayId}}",
"paymentMethod": {
"address": { // optional
"city": "San Francisco",
"companyName": "AppFrontier",
"country": "USA",
"postalcode": "94105",
"state": "California",
"street": "415 Mission Street"
},
"cardPaymentMethod": {
"cardHolderFirstName": "Chargent",
"cardHolderLastName": "Authorization Test",
"cardNumber": "{{cardNumber}}",
"cardType": "{{cardType}}",
"cvv": "{{cvv}}",
"expiryMonth": "{{expiryMonth}}",
"expiryYear": "{{expiryYear}}"
}
},
"email": "{{$randomEmail}}", // optional
"phone": "{{$randomPhoneNumber}}" // optional
}

Response​

JSON Example
{
"paymentMethod": {
"tokens": [
{
"token": "{{token}}",
"id": "{{tokenId}}",
"gatewayId": "{{gatewayId}}"
}
],
"status": "Created",
"id": "{{paymentMethodId}}"
},
"logs": [
{
"interactionStatus": "APPROVED",
"id": "{{logId}}",
"gatewayResultCode": "100",
"gatewayId": "{{gatewayId}}",
"createdDate": "2023-12-06T20:33:57.000Z"
}
],
"gatewayResponse": {
"gatewayToken": "{{token}}",
"gatewayResultCodeDescription": "ACCEPT",
"gatewayResultCode": "100",
"gatewayMessage": "ACCEPT",
"gatewayDate": "2023-12-06T20:33:58.007Z",
"gatewayAvsCode": "X",
"gatewayAuthorizationCode": "{{authCode}}"
},
"paymentAuthorization": {
"status": "Approved",
"requestDate": "2023-12-06T20:33:58.007Z",
"paymentAuthorizationNumber": "{{authCode}}",
"id": "{{transactionId}}",
"effectiveDate": "2023-12-06T20:33:58.007Z",
"chargentOrderId": "{{chargentOrderId}}",
"amount": 300.0
}
}

chargentOrderId, paymentMethodId, paymentGatewayId​

Request​

JSON Example
{
"amount": 400.00, // optional
"chargentOrderId": "{{orderId}}",
"paymentMethod": {
"id": "{{paymentMethodId}}"
},
"paymentGatewayId": "{{gatewayId}}"
}

Response​

JSON Example
{
"paymentMethod": {
"tokens": [
{
"token": "{{token}}",
"id": "{{tokenId}}",
"gatewayId": "{{gatewayId}}"
}
],
"status": "Applied",
"id": "{{paymentMethodId}}"
},
"logs": [
{
"interactionStatus": "APPROVED",
"id": "{{logId}}",
"gatewayResultCode": "200",
"gatewayId": "{{gatewayId}}",
"createdDate": "2023-12-06T21:24:26.000Z"
}
],
"gatewayResponse": {
"gatewayToken": "{{token}}",
"gatewayResultCodeDescription": "",
"gatewayResultCode": "200",
"gatewayMessage": "",
"gatewayDate": "2023-12-06T21:24:26.391Z",
"gatewayAuthorizationCode": ""
},
"paymentAuthorization": {
"status": "Approved",
"requestDate": "2023-12-06T21:24:26.391Z",
"paymentAuthorizationNumber": "",
"id": "{{transactionId}}",
"effectiveDate": "2023-12-06T21:24:26.391Z",
"chargentOrderId": "{{chargentOrderId}}",
"amount": 400.0
}
}

chargentOrderId, paymentMethodId​

Request​

JSON Example
{
"amount": 500.00, // optional
"chargentOrderId": "{{orderId}}",
"paymentMethod": {
"id": "{{paymentMethodId}}"
}
}

Response​

JSON Example
{
"paymentMethod": {
"tokens": [
{
"token": "{{token}}",
"id": "{{tokenId}}",
"gatewayId": "{{gatewayId}}"
}
],
"status": "Applied",
"id": "{{paymentMethodId}}"
},
"logs": [
{
"interactionStatus": "APPROVED",
"id": "{{logId}}",
"gatewayResultCode": "200",
"gatewayId": "{{gatewayId}}",
"createdDate": "2023-12-06T21:28:15.000Z"
}
],
"gatewayResponse": {
"gatewayToken": "{{tokenId}}",
"gatewayResultCodeDescription": "",
"gatewayResultCode": "200",
"gatewayMessage": "",
"gatewayDate": "2023-12-06T21:28:15.389Z",
"gatewayAuthorizationCode": ""
},
"paymentAuthorization": {
"status": "Approved",
"requestDate": "2023-12-06T21:28:15.389Z",
"paymentAuthorizationNumber": "",
"id": "{{transactionId}}",
"effectiveDate": "2023-12-06T21:28:15.389Z",
"chargentOrderId": "{{orderId}}",
"amount": 500.0
}
}

accountId, paymentGatewayId​

Request​

JSON Example
{
"accountId": "{{accountId}}",
"amount": 600.00,
"comments": "Authorization for $600.00",
"paymentGatewayId": "{{gatewayId}}",
"paymentMethod": {
"address": { // optional
"city": "San Francisco",
"companyName": "AppFrontier",
"country": "USA",
"postalcode": "94105",
"state": "California",
"street": "415 Mission Street"
},
"cardPaymentMethod": {
"cardHolderFirstName": "Chargent",
"cardHolderLastName": "Authorization Test",
"cardNumber": "{{cardNumber}}",
"cardType": "{{cardType}}",
"cvv": "{{cvv}}",
"expiryMonth": "{{expiryMonth}}",
"expiryYear": "{{expiryYear}}"
}
},
"email": "{{$randomEmail}}", // optional
"phone": "{{$randomPhoneNumber}}" // optional
}

Response​

JSON Example
{
"paymentMethod": {
"tokens": [
{
"token": "{{token}}",
"id": "{{tokenId}}",
"gatewayId": "{{gatewayId}}"
}
],
"status": "Created",
"id": "{{paymentMethodId}}",
"accountId": "{{accountId}}"
},
"logs": [
{
"interactionStatus": "APPROVED",
"id": "{{logId}}",
"gatewayResultCode": "200",
"gatewayId": "{{gatewayId}}",
"createdDate": "2023-12-07T01:38:28.000Z"
}
],
"gatewayResponse": {
"gatewayToken": "{{token}}",
"gatewayResultCodeDescription": "",
"gatewayResultCode": "200",
"gatewayMessage": "",
"gatewayDate": "2023-12-07T01:38:28.294Z",
"gatewayAuthorizationCode": ""
},
"paymentAuthorization": {
"status": "Approved",
"requestDate": "2023-12-07T01:38:28.294Z",
"paymentAuthorizationNumber": "",
"id": "{{transactionId}}",
"effectiveDate": "2023-12-07T01:38:28.294Z",
"chargentOrderId": "{{orderId}}",
"amount": 600.0,
"accountId": "{{accountId}}"
}
}

accountId, paymentMethodId, paymentGatewayId​

Request​

JSON Example
{
"accountId": "{{accountId}}",
"amount": 700.00,
"comments": "Authorization for $700.00.",
"paymentMethod": {
"id": "{{paymentMethodId}}"
},
"paymentGatewayId": "{{gatewayId}}"
}

Response​

JSON Example
{
"paymentMethod": {
"tokens": [
{
"token": "{{token}}",
"id": "{{tokenId}}",
"gatewayId": "{{gatewayId}}"
}
],
"status": "Applied",
"id": "{{paymentMethodId}}",
"accountId": "{{accountId}}"
},
"logs": [
{
"interactionStatus": "APPROVED",
"id": "{{logId}}",
"gatewayResultCode": "200",
"gatewayId": "{{gatewayId}}",
"createdDate": "2023-12-07T01:33:08.000Z"
}
],
"gatewayResponse": {
"gatewayToken": "{{token}}",
"gatewayResultCodeDescription": "",
"gatewayResultCode": "200",
"gatewayMessage": "",
"gatewayDate": "2023-12-07T01:33:09.160Z",
"gatewayAuthorizationCode": ""
},
"paymentAuthorization": {
"status": "Approved",
"requestDate": "2023-12-07T01:33:09.160Z",
"paymentAuthorizationNumber": "",
"id": "{{transactionId}}",
"effectiveDate": "2023-12-07T01:33:09.160Z",
"chargentOrderId": "{{orderId}}",
"amount": 700.0,
"accountId": "{{accountId}}"
}
}

JSForce Example​

Node.js Example
function createAuthorization(conn, chargentOrderId, paymentMethodId, gatewayId) {

const relativeUrl = "/services/apexrest/ChargentBase/payments/authorizations"

var authorization = {
amount: "400.00",
chargentOrderId: chargentOrderId,
paymentMethod: {
"id": paymentMethodId
},
paymentGatewayId: gatewayId
}

return new Promise((resolve, reject) => {
conn.request({
method: 'POST',
url: relativeUrl,
body: JSON.stringify(authorization),
headers: { 'Content-Type': 'application/json' }
}, function(error, result) {
if (error) {
reject(error)
} else {
resolve(result)
}
})
})
}

module.exports = createAuthorization

Learn More​

Learn more about Payment Authorizations.