Configuring Salesforce Billing to Access Your PaymentGatewayAPI Class
To integrate with a payment gateway package, Salesforce Billing must know which gateway
package class contains the methods required to process a payment request and convert the
results to data that Salesforce Billing can read. The Salesforce Billing custom setting
Payment Gateway Config defines the class that Salesforce Billing calls from the gateway
package. You must also add code that installs a record of the class in
PaymentGatewayConfig.
First, create your primary gateway package class. For ease of reference, name it after your payment gateway, followed by “API.” The class must implement all three of our payment gateway interfaces. Here’s an example for CyberSource.
1global class CyberSourceAPI implements blng.PaymentGateWay, blng.PaymentGateWays, blng.PaymentGateWayStatus
2{}Next, add code that lets you install a record of the class in PaymentGatewayConfig. For this
example, we’ve titled our method
insertPaymentGatewayConfigCustomSettings.
1public void insertPaymentGatewayConfigCustomSettings()
2{
3 String gatewayName = 'CyberSource';
4 List<blng__PaymentGatewayConfig__c> listofConfiguration = new List<blng__PaymentGatewayConfig__c>();
5 blng__PaymentGatewayConfig__c gateway = new blng__PaymentGatewayConfig__c(
6 Name = gatewayName,
7 blng__ClassName__c = CyberSource.class.getName().substringBefore(gatewayName) + gatewayName + 'API');
8 listofConfiguration.add(gateway);
9
10 // get the all custom settings to check whether system has already settings or not
11 Map<String, blng__PaymentGatewayConfig__c> mapOfConfigurationValues = blng__PaymentGatewayConfig__c.getAll();
12 // if system does not have the gateway, then insert it
13 if(!mapOfConfigurationValues.containskey(gatewayName)) {
14 insert listofConfiguration;
15 }
16}