This plugin requires curl support be enabled on your web server. If the script does not function properly, and you are receiving errors about curl, please contact the support staff of your hosting company. If you have access to edit your own php.ini file, then you may be able to do this yourself by uncommenting the following line in that file:
extension=php_curl.dll
If uncommenting or adding that line to your php.ini does not resolve the issue, you may need to contact your hosting support staff to see if they support curl or how they might go about adding curl support to your account.
1. Begin by downloading the GoToBilling PHP Plugin. (Download Here)
2. Unzip and copy the plugin files to a location on your web site. If you have a central repository for reusable libraries, you may want to copy the class.gotobilling.php file to that location, or you may just want to include it in a subdirectory under the site or page that you will be using this plugin with. Whichever you choose, note the location.
3. Create a new PHP page or open an existing one, and add the following line at the top:
<?php
include 'class.gotobilling.php';
?>
Note that you will want to include the path to your file in this line. So, for instance if I placed this in an "includes" folder which is a subdirectory of the page I'm working on, it would be:
<?php
include 'includes/class.gotobilling.php';
?>
4. Next, decide when the transaction processing action will take place, and begin to insert the following code in that location. First, we will create a new GoToBilling object:
<?php
$auth = new GotoBilling();
?>
5. Set the appropriate parameters for your transaction, for example, you are required to send your Merchand ID and Pin:
<?php
$auth->setMerchantId = MY_MERCHANT_ID;
$auth->setMerchantPin = MY_MERCHANT_PIN;
?>
6. Once you've set all the parameters for the transaction, submit it:
<?php
$auth->process();
?>
7. Verify whether the transaction succeeded by checking the Status:
<?php
switch ($auth->getStatus()) {
case "G":
echo "Approved";
break;
case "R":
echo "Received";
break;
case "D":
echo "Declined";
break;
case "C":
echo "Cancelled";
break;
case "T":
echo "Timeout";
break;
}
?>
A full demo example with debugging and code documentation is included in the plugin package that can be downloaded above.
Note: Once you are ready to test your integration, please contact GoToBilling to set up a test account for certification with your application. |