Pesapal.com

Forum

Welcome, Guest
Username
Password:
 

whmcs payment gateway code
(1 viewing) (1) Guest
Welcome to the Pesapal integration forum!

This forum discusses everything about Pesapal integration on your web site. Having any problems? This is the right place to post a question and we are sure you will get an answer
  • Page:
  • 1

TOPIC: whmcs payment gateway code

whmcs payment gateway code 4 years, 7 months ago #387

  • extrait
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
Hello

Please help in integrating pesapal payment gateway with WHMCS
Here is my WHMCS module template



<?php

function template_config() {
$configarray = array(
"FriendlyName" => array("Type" => "System", "Value"=>"My Custom Module"),
"username" => array("FriendlyName" => "Login ID", "Type" => "text", "Size" =>
"20", ),
"transmethod" => array("FriendlyName" => "Transaction Method", "Type" =>
"dropdown", "Options" => "Option1,Value2,Method3", ),
"instructions" => array("FriendlyName" => "Payment Instructions", "Type" =>
"textarea", "Rows" => "5", "Description" => "Do this then do that etc...", ),
"testmode" => array("FriendlyName" => "Test Mode", "Type" => "yesno",
"Description" => "Tick this to test", ),
);
return $configarray;
}

function template_link($params) {

# Gateway Specific Variables
$gatewayusername = $params['username'];
$gatewaytestmode = $params['testmode'];

# Invoice Variables
$invoiceid = $params['invoiceid'];
$description = $params["description"];
$amount = $params['amount']; # Format: ##.##
$currency = $params['currency']; # Currency Code

# Client Variables
$firstname = $params['clientdetails']['firstname'];
$lastname = $params['clientdetails']['lastname'];
$email = $params['clientdetails']['email'];
$address1 = $params['clientdetails']['address1'];
$address2 = $params['clientdetails']['address2'];
$city = $params['clientdetails']['city'];
$state = $params['clientdetails']['state'];
$postcode = $params['clientdetails']['postcode'];
$country = $params['clientdetails']['country'];
$phone = $params['clientdetails']['phonenumber'];

# System Variables
$companyname = $params['companyname'];
$systemurl = $params['systemurl'];
$currency = $params['currency'];

# Enter your code submit to the gateway...

$code = '<form method="www.domain.com/submit">
<input type="hidden" name="username" value="'.$gatewayusername.'" />
<input type="hidden" name="testmode" value="'.$gatewaytestmode.'" />
<input type="hidden" name="description" value="'.$description.'" />
<input type="hidden" name="invoiceid" value="'.$invoiceid.'" />
<input type="hidden" name="amount" value="'.$amount.'" />
<input type="submit" value="Pay Now" />
</form>';

return $code;
}

function template_capture($params) {

# Gateway Specific Variables
$gatewayusername = $params['username'];
$gatewaytestmode = $params['testmode'];

# Invoice Variables
$invoiceid = $params['invoiceid'];
$amount = $params['amount']; # Format: ##.##
$currency = $params['currency']; # Currency Code

# Client Variables
$firstname = $params['clientdetails']['firstname'];
$lastname = $params['clientdetails']['lastname'];
$email = $params['clientdetails']['email'];
$address1 = $params['clientdetails']['address1'];
$address2 = $params['clientdetails']['address2'];
$city = $params['clientdetails']['city'];
$state = $params['clientdetails']['state'];
$postcode = $params['clientdetails']['postcode'];
$country = $params['clientdetails']['country'];
$phone = $params['clientdetails']['phonenumber'];

# Card Details
$cardtype = $params['cardtype'];
$cardnumber = $params['cardnum'];
$cardexpiry = $params['cardexp']; # Format: MMYY
$cardstart = $params['cardstart']; # Format: MMYY
$cardissuenum = $params['cardissuenum'];

# Perform Transaction Here & Generate $results Array, eg:
$results = array();
$results["status"] = "success";
$results["transid"] = "12345";

# Return Results
if ($results["status"]=="success") {
return
array("status"=>"success","transid"=>$results["transid"],"rawdata"=>$results);
} elseif ($gatewayresult=="declined") {
return array("status"=>"declined","rawdata"=>$results);
} else {
return array("status"=>"error","rawdata"=>$results);
}

}

function template_refund($params) {

# Gateway Specific Variables
$gatewayusername = $params['username'];
$gatewaytestmode = $params['testmode'];

# Invoice Variables
$transid = $params['transid']; # Transaction ID of Original Payment
$amount = $params['amount']; # Format: ##.##
$currency = $params['currency']; # Currency Code

# Client Variables
$firstname = $params['clientdetails']['firstname'];
$lastname = $params['clientdetails']['lastname'];
$email = $params['clientdetails']['email'];
$address1 = $params['clientdetails']['address1'];
$address2 = $params['clientdetails']['address2'];
$city = $params['clientdetails']['city'];
$state = $params['clientdetails']['state'];
$postcode = $params['clientdetails']['postcode'];
$country = $params['clientdetails']['country'];
$phone = $params['clientdetails']['phonenumber'];

# Card Details
$cardtype = $params['cardtype'];
$cardnumber = $params['cardnum'];
$cardexpiry = $params['cardexp']; # Format: MMYY
$cardstart = $params['cardstart']; # Format: MMYY
$cardissuenum = $params['cardissuenum'];

# Perform Refund Here & Generate $results Array, eg:
$results = array();
$results["status"] = "success";
$results["transid"] = "12345";

# Return Results
if ($results["status"]=="success") {
return
array("status"=>"success","transid"=>$results["transid"],"rawdata"=>$results);
} elseif ($gatewayresult=="declined") {
return array("status"=>"declined","rawdata"=>$results);
} else {
return array("status"=>"error","rawdata"=>$results);
}

}

?>

Re: whmcs payment gateway code 3 weeks, 3 days ago #2236

  • markm
  • OFFLINE
  • Administrator
  • Posts: 68
  • Page:
  • 1