Newer Version Available

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

YourGatewayAPI

YourGatewayAPI is a base class that connects the Salesforce Billing package to your payment gateway package. All user gateway API classes will be different based on your needs. However, we've provided a template that you can use to help create your own.
Available in:

YourGatewayAPI references the following public classes.
1global class YourGatewayAPI implements blng.PaymentGateWay, blng.PaymentGateWays, blng.PaymentGateWayStatus
2{
3    // ============================================================================
4    // CONSTANT 
5    // ============================================================================
6    
7    // ============================================================================
8    // STATIC VARIABLES
9    // ============================================================================
10    
11    // Attribute to implement singleton pattern for YourGatewayName  class
12    private static YourGatewayName YourGatewayNameInstance;
13    
14     // ============================================================================
15    // VARIABLES
16    // ============================================================================
17
18    // Attribute to implement singleton pattern for AuthorizeDotNet class
19    private static final String GENERATE_TOKEN = 'generateToken';
20    private static final String AUTHORIZE_TRANSACTION = 'authorizeTransaction';
21    private static final String CHARGE_TRANSACTION = 'chargeTransaction';
22    private static final String VOID_TRANSACTION = 'voidTransaction';
23    private static final String REFUND_TRANSACTION = 'refundTransaction'; 
24    private static final String CAPTURE_TRANSACTION = 'captureTransaction';
25    private static final String VOID_REFUND_TRANSACTION = 'voidRefundTransaction';
26    private static final String VOID_TOKEN_TRANSACTION = 'voidTokenTransaction';
27    private static final String GET_PAYMENT_STATUS = 'getPaymentStatus';
28    private static final String GET_REFUND_STATUS = 'getRefundStatus';
29    private static final String NON_REFERRED_REFUND = 'nonReferredRefund';
30    private static final String PROCESS_PAYMENTS = 'processPayments';
31    
32    // ============================================================================
33    // Methods
34    // ============================================================================
35    /**
36    * @name service
37    * @description service method to create an only instance of TransactionService class
38    *              if serviceInstance is NULL then only create a new instance otherwise 
39    *              return the existing one
40    * @param   NA 
41    * @return TransactionService instance
42    * @exception
43    * @author 
44    * @created 
45    * @remark 
46    * @change
47    */   
48    @TestVisible
49    private static YourGatewayName service()
50    {
51        if (NULL == YourGatewayNameInstance)
52        {
53            YourGatewayNameInstance = YourGatewayName.getInstance();
54        }
55        return YourGatewayNameInstance;
56    }
57
58    /**
59    * @name processPayments
60    * @description Method to generate Token
61    * @param 
62    * @return
63    * @exception
64    * @author 
65    * @created 2016-11-03
66    * @remark 
67    * @change
68    */   
69    global static Map<String, blng.TransactionResult> processPayments(Map<String, blng.TransactionParameter> mapOfTransactionParameterById, blng.PaymentGatewayParameter paymentGatewayParameter)
70    {
71        if(paymentGatewayParameter.getTransactionType() == GENERATE_TOKEN)
72        {
73            return generateToken(mapOfTransactionParameterById);
74        }
75        else if(paymentGatewayParameter.getTransactionType() == AUTHORIZE_TRANSACTION)
76        {
77            return authorizeTransaction(mapOfTransactionParameterById);
78        }
79        else if(paymentGatewayParameter.getTransactionType() == CHARGE_TRANSACTION)
80        {
81            return chargeTransaction(mapOfTransactionParameterById);
82        }
83        else if(paymentGatewayParameter.getTransactionType() == VOID_TRANSACTION)
84        {
85            return voidTransaction(mapOfTransactionParameterById);
86        }
87        else if(paymentGatewayParameter.getTransactionType() == REFUND_TRANSACTION)
88        {
89            return refundTransaction(mapOfTransactionParameterById);
90        }
91        else if(paymentGatewayParameter.getTransactionType() == CAPTURE_TRANSACTION)
92        {
93            return captureTransaction(mapOfTransactionParameterById);
94        }
95        else if(paymentGatewayParameter.getTransactionType() == VOID_REFUND_TRANSACTION)
96        {
97            return voidRefundTransaction(mapOfTransactionParameterById);
98        }
99        else if(paymentGatewayParameter.getTransactionType() == VOID_TOKEN_TRANSACTION)
100        {
101            return voidTokenTransaction(mapOfTransactionParameterById);
102        }
103        else if(paymentGatewayParameter.getTransactionType() == GET_PAYMENT_STATUS)
104        {
105            return getPaymentStatus(mapOfTransactionParameterById);
106        }
107        else if(paymentGatewayParameter.getTransactionType() == GET_REFUND_STATUS)
108        {
109            return getRefundStatus(mapOfTransactionParameterById);
110        }
111        else if(paymentGatewayParameter.getTransactionType() == NON_REFERRED_REFUND)
112        {
113            return nonReferredRefund(mapOfTransactionParameterById);
114        }
115
116        return NULL;
117    }
118    
119    /**
120    * @name generateToken
121    * @description Method to generate Token for a Payment Method
122    * @param Map[Key => String [unique Id],Value => TransactionParameter]
123    * @return Map[Key => String [unique Id],Value => TransactionResult]
124    * @exception 
125    * @author 
126    * @created 
127    * @remark 
128    * @change
129    */    
130    global static Map<String, blng.TransactionResult> generateToken(Map<String, blng.TransactionParameter> mapOfTransactionParameterById) 
131    {
132        return service().generateToken(mapOfTransactionParameterById);
133    }
134
135    /**
136    * @name voidTokenTransaction
137    * @description Method to void Token for a Payment method Token
138    * @param Map[Key => String [unique Id],Value => TransactionParameter]
139    * @return Map[Key => String [unique Id],Value => TransactionResult]
140    * @exception
141    * @author 
142    * @created
143    * @remark
144    * @change
145    */    
146    global static Map<String, blng.TransactionResult> voidTokenTransaction(Map<String, blng.TransactionParameter> mapOfTransactionParameterById) 
147    {
148        return service().voidTokenTransaction(mapOfTransactionParameterById);
149    }
150
151
152    /**
153    * @name authorizeTransaction
154    * @description Method to Authorize a payment for a Invoice
155    * @param Map[Key => String [unique Id],Value => TransactionParameter]
156    * @return Map[Key => String [unique Id],Value => TransactionResult]
157    * @exception
158    * @author
159    * @created
160    * @remark 
161    * @change
162    */  
163    global static Map<String, blng.TransactionResult> authorizeTransaction(Map<String, blng.TransactionParameter> mapOfTransactionParameterById) 
164    {
165        return service().authorizeTransaction(mapOfTransactionParameterById);
166    }
167
168    /**
169    * @name chargeTransaction
170    * @description Method to Charge a payment for a Invoice
171    * @param Map[Key => String [unique Id],Value => TransactionParameter]
172    * @return Map[Key => String [unique Id],Value => TransactionResult]
173    * @exception
174    * @author  
175    * @created 
176    * @remark 
177    * @change 
178    */      
179    global static Map<String, blng.TransactionResult> chargeTransaction(Map<String, blng.TransactionParameter> mapOfTransactionParameterById) 
180    {
181        return service().chargeTransaction(mapOfTransactionParameterById);
182    }
183
184    /**
185    * @name captureTransaction
186    * @description Method to capture a payment for a Authorize Transaction
187    * @param Map[Key => String [unique Id],Value => TransactionParameter]
188    * @return Map[Key => String [unique Id],Value => TransactionResult]
189    * @exception 
190    * @author
191    * @created
192    * @remark 
193    * @change
194    */      
195    global static Map<String, blng.TransactionResult> captureTransaction(Map<String, blng.TransactionParameter> mapOfTransactionParameterById) 
196    {
197        return service().captureTransaction(mapOfTransactionParameterById);
198    }
199
200
201    /**
202    * @name voidTransaction
203    * @description Method to Void a payment for a Invoice
204    * @param Map[Key => String [unique Id],Value => TransactionParameter]
205    * @return Map[Key => String [unique Id],Value => TransactionResult]
206    * @exception
207    * @author
208    * @created
209    * @remark 
210    * @change 
211    */      
212    global static Map<String, blng.TransactionResult> voidTransaction(Map<String, blng.TransactionParameter> mapOfTransactionParameterById) 
213    {
214        return service().voidTransaction(mapOfTransactionParameterById);
215    }
216
217    /**
218    * @name refundTransaction
219    * @description Method to Refund a payment for a payment Transaction
220    * @param Map[Key => String [unique Id],Value => TransactionParameter]
221    * @return Map[Key => String [unique Id],Value => TransactionResult]
222    * @exception
223    * @author
224    * @created
225    * @remark
226    * @change
227    */ 
228    global static Map<String, blng.TransactionResult> refundTransaction(Map<String, blng.TransactionParameter> mapOfTransactionParameterById) 
229    {
230        return service().refundTransaction(mapOfTransactionParameterById);
231    }
232
233    /**
234    * @name nonReferencedRefund
235    * @description Method to non Referenced Refund a payment for a Invoice
236    * @param Map[Key => String [unique Id],Value => TransactionParameter]
237    * @return Map[Key => String [unique Id],Value => TransactionParameter]
238    * @exception
239    * @author
240    * @created
241    * @remark
242    * @change
243    */ 
244    global static Map<String, blng.TransactionResult> nonReferredRefund(Map<String, blng.TransactionParameter> mapOfTransactionParameterById) 
245    {
246        return service().nonReferencedRefund(mapOfTransactionParameterById);
247    }
248
249    /**
250    * @name voidRefundTransaction
251    * @description Method to Void refund for a Refund Transaction
252    * @param Map[Key => String [unique Id],Value => TransactionParameter]
253    * @return Map[Key => String [unique Id],Value => TransactionResult]
254    * @exception
255    * @author
256    * @created
257    * @remark 
258    * @change
259    */      
260    global static Map<String, blng.TransactionResult> voidRefundTransaction(Map<String, blng.TransactionParameter> mapOfTransactionParameterById) 
261    {
262        return service().voidRefundTransaction(mapOfTransactionParameterById);
263    }
264    
265    /**
266    * @name getPaymentStatus
267    * @description Method to get payment status for a Payment Transaction
268    * @param Map[Key => String [unique Id],Value => TransactionParameter]
269    * @return Map[Key => String [unique Id],Value => TransactionResult]
270    * @exception
271    * @author
272    * @created
273    * @remark 
274    * @change
275    */      
276    global static Map<String, blng.TransactionResult> getPaymentStatus(Map<String, blng.TransactionParameter> mapOfTransactionParameterById) 
277    {
278        return service().getPaymentStatus(mapOfTransactionParameterById);
279    }
280    
281    /**
282    * @name getRefundStatus
283    * @description Method to get refund status for a Refund Transaction
284    * @param Map[Key => String [unique Id],Value => TransactionParameter]
285    * @return Map[Key => String [unique Id],Value => TransactionResult]
286    * @exception
287    * @author
288    * @created
289    * @remark 
290    * @change
291    */      
292    global static Map<String, blng.TransactionResult> getRefundStatus(Map<String, blng.TransactionParameter> mapOfTransactionParameterById) 
293    {
294         return service().getPaymentStatus(mapOfTransactionParameterById);
295    }
296     /**
297     * @name populateGatewayStatus
298     * @description Method that populates the GatewayStatus enum on the TransactionResult,
299     * given return codes that are already set in the TransactionResults
300     * @param transactionResult
301     */
302    global static void populateGatewayStatus(blng.TransactionResult transactionResult)
303    {
304        service().populateGatewayStatus(transactionResult);
305    }
306}