![]() |
Integration process with ANY OTHER Payment GatewayThe system has the built-in ability to allow you to integrate any Payment Gateway to allow your Customers / Sub-Resellers to pay you. Obviously every Commercial Payment Gateway has a different integration process. There is no way to build a generic module that can directly talk to any Payment Gateway. Instead, what we have done is, built a module that can pass parameters to an intermediate bridge on your server, that you can then integrate with any Payment Gateway of your choice. The logic of the flow in this integration is quite simple:
This interaction can be diagrammatically represented as follows -
Let us break down the process you need to carry out in order to complete integrating your Payment Gateway with our system. Step 1: What you will NeedYou will need the following before you begin integrating your Payment Gateway with the System:
Note
If you have downloaded any of the Payment Gateway Kits prior to 25th August, 2006, then it is recommended that you upgrade to the latest version with MD5 Checksum Algorithm, by following the two step process listed below: Step 1: Upgrade your Payment Gateway Integration Kit:
Step 2: Select the correct Checksum Algorithm within your Reseller Control Panel:
Step 2: Adding your Payment GatewayNext, you need to Add your Payment Gateway to our system. You can Add or Modify your current/preferred Payment Gateway within your Reseller account by following the steps given below:
Step 3: Preparation on your ServerOn your own server, upload the corresponding files from the integration kit you downloaded. We will use the PHP Kit as an example in this document. You will typically have the following files: paymentpage.php: This is the page that we will redirect your Customer / Sub-Reseller to. From this page, you need to collect the data we send and use the data to charge your Customer / Sub-Reseller. After you have charged the Customer / Sub-Reseller you will then redirect the Customer / Sub-Reseller to postpayment.php. postpayment.php: This page simply redirects your Customer back to our Server after you have charged him, with appropriate variables required by our Server. functions.php: This is just a functions file used by the other pages for certain calculations. Both the paymentpage.php and the postpayment.php pages contain a variable called KEY. For instance, in the above two files you will find a line as follows: $key = "eF9dmG8288OFd9pzzTeHJ3mNvR26xN"; //replace ur 32 bit secure key , Get your secure key from your Reseller Control panel You need to replace this value in both the files with the KEY we generated for you at the time of adding the Gateway. You can check it from the Settings -> Finance and Billing -> Payment Gateway -> List / Add section by clicking the Payment Gateway that you added. If at anytime you feel that you may have compromised the security of this Key, you can regenerate a new one from this section by clicking the Generate Key button. You will then have to replace the New Key in your code. Step 4: Set the Gateway URLYou will now need to set the Gateway URL which we skipped earlier while adding the Gateway. The Gateway URL is the full http:// URL that will be used to access the paymentpage.php on your server. So a typical Gateway URL would look like "http://www.yourserver.com/paymentpage.php". Visit the Settings -> Finance and Billing -> Payment Gateway -> List / Add section within your Reseller Control Panel and click the Payment Gateway you added. Click Modify and enter the Gateway URL as described above. Make sure the URL is entered complete with the "http://" or "https://" all the way up to the name of the page. DO NOT pass any Parameters to the URL. CORRECT GATEWAY URL: http://www.yourserver.com/paymentpage.php WRONG GATEWAY URLS: www.yourserver.com/paymentpage.php http://www.yourserver.com/paymentpage.php?someparam=something Step 5: Testing the Integration so farYou are now ready to test your integration and verify that it works. Follow the steps below to Test your Integration:
Additional Variables sent to the Payment PageBesides, we also pass the following details which allow you to pre-fill the Customer's / Sub-Reseller's details on the Payment Gateway page:
These variables can directly be accessed in the paymentpage.php. If all goes well, then clicking the Test PG Integration button you should see the following output on your browser in a separate window:
File:
We will stop here right now. If you get the above output in your browser window then you have perfectly followed the steps so far. If you get any of the following results instead then you can appropriately refer back to see if you have correctly set the following data:
If you do not get this output then you should revert back and check if you have properly inserted your key in the paymentpage.php file, and that the Gateway URL is properly set. Make sure you proceed ahead only after you get the above output for your specific integration kit. Let us try and understand what we have achieved so far. Basically a set of parameters are passed from our Server to your Server, along with a checksum. If you open your corresponding paymentpage.php page you will see the following code in it - if(verifyChecksum($paymenttypeid, $transid, $userid, $usertype, $transactiontype, $sellingcurrencyamount, $accountingcurrencyamount, $key, $checksum)) <strong>{ // YOUR CODE GOES HERE }</strong> else { echo "ERROR: Checksum Mismatch"; } Similar code will exist in the ASP and JSP integration kits. Your goal is to simply put your code inside the braces of the Verify Checksum. Within these braces you will put in code to register these variables in a session, or put them in your local database and then proceed ahead with charging your Customer. The VerifyChecksum function simply validates that the data you have received is valid and is sent by OUR SERVER. If the VerifyChecksum function, fails then you MUST NOT proceed with the transaction. Note
It is imperative that you test your integration so far, by clicking both the Test for Add Funds and Test for Payment buttons, before continuing to integrate your website with your Payment Gateway provider. Step 6: Charging the Customer / Sub-Reseller on your Payment GatewayYou have now successfully achieved the integration steps up to sending the Customer / Sub-Reseller to your server. You now need to charge this Customer / Sub-Reseller. At this stage you have the list of variables that were passed to you in the paymentpage.php. It is recommended that you either store these variables in some local database of yours or store them in a session, before proceeding ahead, so that you can access these variable values at the time of sending the Customer / Sub-Reseller back after charging him. Storing these is explained in the previous section. After doing so, you must charge this Customer / Sub-Reseller. In doing so, the following values are important for you:
The above amounts are the amounts you need to charge your Customer / Sub-Reseller. If your Payment Gateway Currency is the same as any of the above you may freely use one of the above values. If on the other hand the Currency your Gateway uses is different you will need to put in code to convert the amount we send to the amount you wish to charge. Once you have finished charging your Customer / Sub-Reseller you will need to then send the Customer / Sub-Reseller back to our Server along with the status of the transaction, in order to allow us to Add those Funds to his account and process any associated Orders. Step 7: Sending the Customer / Sub-Reseller back to our ServerYou have now finished the steps required to charge your Customer / Sub-Reseller. You will then send the Customer / Sub-Reseller back to our Server. You will use the redirecturl parameter that was sent to your Gateway URL for this transaction to pass the Customer / Sub-Reseller back to our server. You will pass the following parameters to the redirecturl in a POST request:
The sample code for achieving the above process successfully is shown in the postpayment.php file. You simply need to copy this code in the file in which you do your Payment Processing. This page retrieves the transid and redirecturl from the session and expects a status to be available to it in the session. A simple inspection of the code in postpayment.php will give you an idea of the right way to redirect your Customer / Sub-Reseller to our server. Explanation of sellingcurrencyamount and accountingcurrencyamount fields In the above table two important fields are the sellingcurrencyamount and accountingcurrencyamount. These fields MUST be passed, but are used only if the transactiontype is CustomerAddFund or ResellerAddFund. Additional Information
Payment Gateway Transaction types and Access Levels for your Customers / Sub-Resellers For every transaction performed through the Payment Gateway, a Receipt is created in the Customer / Sub-Reseller account. The amount of the Receipt created incase of transactiontype CustomerAddFund or ResellerAddFund is dependant on this figure. The Receipt amount will be equivalent to the figure you send us for both these values. The reason for allowing you to send us these values is to allow you to deduct any Credit Card Processing charges for Advance Payments made by your Customers / Sub-Resellers in their account. Lets take an example of an Add Funds transaction performed by your Sub-Reseller - Sub-Reseller A Your Selling Currency: USD Your Accounting Currency: INR Conversion Rate: 50 Amount to add in USD: 100 Amount to add in INR: 5000 When this Sub-Reseller leaves our system and comes to your paymentpage.php, we will send along the two amounts i.e. USD 100, INR 5000, to allow you to charge his card with an equivalent amount. After the transaction is completed, you will send the Sub-Reseller back to our system with a sellingcurrencyamount and accountingcurrencyamount figure. We will then credit THAT amount to his account. You may choose to send the same figures we sent to you, thus crediting the Sub-Reseller with the exact amount that was charged to him/her. Alternatively you may choose to deduct a certain processing amount for Credit Card Transactions and send a reduced amount. Thus you could have the below two scenarios. Scenario 1 - Values sent by your postpayment.php page sellingcurrencyamount: USD 100 accountingcurrencyamount: INR 5000 In this scenario we sent you USD 100 and INR 5000, and you sent the same figures back. We will therefore credit the Sub-Reseller with the same amount. Scenario 2 - Values sent by your postpayment.php page sellingcurrencyamount: USD 95 accountingcurrencyamount: INR 4750 In this scenario, we sent you USD 100 and INR 5000, and you sent back USD 95 and INR 4750 (deducting 5% processing charges). We will therefore credit the Sub-Reseller with USD 95, INR 4750. Completing the Integration process using the postpayment.php page We have a special built-in test mechanism for testing the interaction between the postpayment.php on your Server and our Server. The steps below assume you have finished all previous instructions until this step. Follow the steps below to test your integration further:
This should result in a page as follows - File: paymentpage.php Checksum Verification ........ Verified List of Variables Received as follows paymenttypeid: 202 transid: 1120 userid: 1 usertype: Customer transactiontype: CustomerAddFund invoiceids: debitnoteids: description: sellingcurrencyamount: 5 accountingcurrencyamount: 10 redirecturl: http://controlpanel.1shotweb.com/servlet/TestCustomPaymentAuthCompletedServlet address1 = 213 Main St. company = My Solutions address2 = null zip = 17541 name = Customer Name city = NYC telNoCc = 1 country = US telNo = 45784126 emailAddr = customer@domain.com address3 = null state = NY faxNoCc = null faxNo = null checksum: 8cd2a658d2de2c995fc790b66a508ec3 Clicking any of the above button submits to the same page where the value of status is set in the session and then you are redirected to postpayment.php, and you should see the below display - File: postpayment.php redirecturl: http://controlpanel.1shotweb.com/servlet/TestCustomPaymentAuthCompletedServlet List of Variables to send back transid: 1120 status: Y rkey: 32423 checksum: 8cd2a658d2de2c995fc790b66a508ec3 Clicking this button will redirect you to our Server and you should see the following display on our Server - Checksum Verification ........ Verified List of Variables Received as follows transid: 1120 status: Y rkey: 32423 checksum: 8cd2a658d2de2c995fc790b66a508ec3 If you see the above display this means that your integration is complete. You simply now need to modify the files and put in your own code to charge your Customer / Sub-Reseller. If you get any of the following results instead then you can appropriately refer back to see if you have correctly set the following data:
If you do not get this output then you should revert back and check if you have properly inserted your key in the postpayment.php file. Make sure you proceed ahead only after you get the above output for your specific integration kit. Step 8: Finishing StepsWe have completed the process of Sending a Customer / Sub-Reseller to your Server and then receiving the Customer / Sub-Reseller back. You now need to modify up the files on your server to process the transaction. The process that you will follow is:
Step 9: Final TestingAttempt a live transaction from one of your Customer / Sub-Reseller accounts to verify everything is working fine. Make sure you try all types of Transactions - Add Funds, Payment of an Invoice, Payment of multiple Invoices/Debit Notes, etc. Note
The SuperSite contains information about the various Payment options you offer to your Customers and also presents these options at the time of purchasing Products and Services. This data is downloaded to your SuperSite from your Control Panel and cached (stored) on the SuperSite Server. Hence, you would need to refresh the cache of your SuperSite once you have completed the above process. You can accomplish this from within your Control Panel itself by clicking Tools -> Reload SuperSite and PartnerSite Cache -> SuperSite Payment Preferences. Additional Information
Step 10: Managing your TransactionsEvery live transaction attempted through your Payment Gateway is recorded by the system. You can list all Transactions and search through them using the List Transactions and Search Transactions buttons in your Payment Gateway toolbar. The following fields are important with respect to each Transaction:
There may be occasions when your Customer / Sub-Reseller will be redirected to your Gateway but never comes back to our Server because of loss of connectivity or other issues. In this circumstance our System will not know whether the Transaction was Successful or Failed. You will have to tell that to the System yourselves. This can be easily achieved by Searching Transactions from the Payment Gateway toolbar and clicking AuthStarted transactions. This will allow you to list all transactions which are yet processing. From here you can state whether they were Successful or Failed. Incase of a successful transaction the System will add those funds to your Customer / Sub-Reseller and process any related Orders. Incase of failed transactions the System will simply mark the transaction as failed. Additional Information
|

