Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

Creating a PaymentGateway Interface

The PaymentGateway interface contains several basic transaction methods that the PaymentGatewayAPI class implements to handle gateway requests. The methods allow PaymentGatewayAPI to create a credit card token, process a payment charge, void a payment, authorize a payment, and refund a payment.
Create a credit card token
Map<String, TransactionResult> generateToken(Map<String, TransactionParameter> mapOfTransactionParameterById,PaymentGatewayParameter paymentGatewayParameter);
Process a payment charge
Map<String, TransactionResult> chargeTransaction(Map<String, TransactionParameter> mapOfTransactionParameterById,PaymentGatewayParameter paymentGatewayParameter);
Void a payment
Map<String, TransactionResult> voidTransaction(Map<String, TransactionParameter> mapOfTransactionParameterById,PaymentGatewayParameter paymentGatewayParameter);
Authorize a payment
Map<String, TransactionResult> authorizeTransaction(Map<String, TransactionParameter> mapOfTransactionParameterById,PaymentGatewayParameter paymentGatewayParameter);
Refund a payment
Map<String, TransactionResult> refundTransaction(Map<String, TransactionParameter> mapOfTransactionParameterById,PaymentGatewayParameter paymentGatewayParameter);

So, if you want your gateway package to process a chargeTransaction sent from Salesforce Billing, the package must implement chargeTransaction within a PaymentGatewayAPI class. Let’s see how this configuration looks in a sample CyberSource implementation.

Example

1global class CyberSourceAPI implements blng.PaymentGateWay
2{
3    global static Map<String, blng.TransactionResult> generateToken(Map<String, blng.TransactionParameter> mapOfTransactionParameterById) 
4    {
5        return service().generateToken(mapOfTransactionParameterById);
6    }
7
8    global static Map<String, blng.TransactionResult> authorizeTransaction(Map<String, blng.TransactionParameter> mapOfTransactionParameterById) 
9    {
10        return service().authorizeTransaction(mapOfTransactionParameterById);
11    }
12     
13    global static Map<String, blng.TransactionResult> chargeTransaction(Map<String, blng.TransactionParameter> mapOfTransactionParameterById) 
14    {
15        return service().chargeTransaction(mapOfTransactionParameterById);
16    }
17  
18    global static Map<String, blng.TransactionResult> voidTransaction(Map<String, blng.TransactionParameter> mapOfTransactionParameterById) 
19    {
20        return service().voidTransaction(mapOfTransactionParameterById);
21    }
22
23    global static Map<String, blng.TransactionResult> refundTransaction(Map<String, blng.TransactionParameter> mapOfTransactionParameterById) 
24    {
25        return service().refundTransaction(mapOfTransactionParameterById);
26    }
27}