Newer Version Available
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}