Newer Version Available

This content describes an older version of this product. View Latest

Payments Class

Authorize a payment, capture an authorized payment, and refund an authorized payment.

Namespace

ConnectApi

Payments Methods

These methods are for Payments. All methods are static.

authorize(authorizePayment)

Authorize a payment.

API Version

51.0

Requires Chatter

No

Signature

global static ConnectApi.AuthorizationResponse authorize(ConnectApi.AuthorizationRequest authorizePayment)

Parameters

authorizePayment
Type: ConnectApi.AuthorizationRequest
Represents a payment authorization.

postAuth(postAuthorizePayment)

Confirms that the merchant is ready to capture payment of an existing pre-authorized transaction.

API Version

54.0

Requires Chatter

No

Signature

global static ConnectApi.PostAuthorizationResponse postAuth(ConnectApi.PostAuthRequest postAuthorizePayment)

Parameters

postAuthorizePayment
Type: ConnectApi.PostAuthRequest
Information about the payment, payment method, and payment gateway from the original payment authorization.

reverseAuthorization(AuthReversalInput, authorizationId)

Reverses a payment authorization.

API Version

51.0

Requires Chatter

No

Signature

global static ConnectApi.AuthorizationReversalResponse reverseAuthorization(ConnectApi.AuthorizationReversalRequest AuthReversalInput, String authorizationId)

Parameters

AuthReversalInput
Type: ConnectApi.AuthorizationReversalRequest
Input information for the payment authorization reversal.
authorizationId
Type: String
The ID of the payment authorization to be reversed.

capture(AuthCaptureInput, authorizationId)

Capture an authorized payment.

To access Payments methods, you need these permissions.

  • Salesforce Order Management License
  • PaymentsAPIUser user permission. This permission is available with the Salesforce Order Management License. Your Salesforce admin assigns it to your profile.

API Version

50.0

Requires Chatter

No

Signature

global static ConnectApi.CaptureResponse capture(ConnectApi.CaptureRequest AuthCaptureInput, String authorizationId)

Parameters

AuthCaptureInput
Type: ConnectApi.CaptureRequest
A ConnectApi.CaptureRequest object with information about the payment capture.
authorizationId
Type: String
ID of the payment authorization. Required.

Return Value

Type: ConnectApi.CaptureResponse

refund(ReferencedRefundInput, paymentId)

Refund an authorized payment.

To access Payments methods, you need these permissions.

  • Salesforce Order Management License
  • PaymentsAPIUser user permission. This permission is available with the Salesforce Order Management License. Your Salesforce admin assigns it to your profile.

API Version

50.0

Requires Chatter

No

Signature

global static ConnectApi.ReferencedRefundResponse refund(ConnectApi.ReferencedRefundRequest ReferencedRefundInput, String paymentId)

Parameters

ReferencedRefundInput
Type: ConnectApi.ReferencedRefundRequest
A ConnectApi.ReferencedRefundRequest object with information about the refund.
paymentId
Type: String
ID of the payment to be refunded. Required.

sale(sale)

Captures a payment without any prior authorization and creates a payment entity. The payment sale transaction is a combination of an Authorize transaction and Capture transaction. This payment sale method allows merchants to request that the funds are transferred to the merchant account in a single command, with no further action (such as charging a credit card) from the merchant.

API Version

54.0

Requires Chatter

No

Signature

global static ConnectApi.SaleResponse sale(ConnectApi.SaleRequest sale)

Parameters

sale
Type: ConnectApi.SaleRequest
Payment sale input class.

Return Value

Type: ConnectApi.SaleResponse

tokenizePaymentMethod(tokenizePaymentMethodInput)

Method to take the input parameters of the payment method you want to tokenize and then pass them to the payment gateway's tokenization service. The results of the tokenization request are returned as a response from the payment gateway.

API Version

52.0

Requires Chatter

No

Signature

global static ConnectApi.PaymentMethodTokenizationResponse tokenizePaymentMethod(ConnectApi.PaymentMethodTokenizationRequest tokenizePaymentMethodInput)

Parameters

tokenizePaymentMethodInput
Type: ConnectApi.PaymentMethodTokenizationRequest
Information about the payment method to be tokenized.

Usage

Accepts input parameters representing a payment method and passes them in a tokenization request to the payment gateway. The results of the tokenization request are returned as a response from the payment gateway. If the tokenization was successful, the response contains the tokenized value and details about the tokenization process. Otherwise, the response contains an error message and details about the error.

Example

1ConnectApi.PaymentMethodTokenizationRequest request = new ConnectApi.PaymentMethodTokenizationRequest();
2request.paymentGatewayId = ‘0b0xx0000001Ja5AAE’;
3ConnectApi.CardPaymentMethodRequest cpmRequest = new ConnectApi.CardPaymentMethodRequest();
4cpmRequest.cardHolderName = ‘Jo Manager’;
5cpmRequest.expiryMonth = 11;
6cpmRequest.expiryYear = 2222;
7cpmRequest.cardNumber = ‘4111111111111111’;
8cpmRequest.cvv = ‘111’;
9cpmRequest.cardCategory = ConnectApi.CardCategory.CreditCard;
10cpmRequest.cardType = ConnectApi.CardType.Visa.name();
11request.cardPaymentMethod = cpmRequest;
12ConnectApi.PaymentMethodTokenizationResponse response = ConnectApi.Payments.tokenizePaymentMethod(request);