Skip to content
This repository was archived by the owner on Aug 11, 2023. It is now read-only.

Commit 49c2828

Browse files
Merge pull request #1 from RBAtkins0n/master
1.0.0
2 parents 2466c80 + d2e5044 commit 49c2828

File tree

4 files changed

+274
-1
lines changed

4 files changed

+274
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# PaySubs_WHMCS
22
## DPO PayGate PaySubs (VCS) WHMCS plugin v1.0.0 for WHMCS v7.4.6
33

4-
This is the DPO PayGate PaySubs (VCS) plugin for WHMCS. Please feel free to contact the DPO PayGate support team at support@paygate.co.za should you require any assistance.
4+
This is the DPO PayGate PaySubs1 (VCS) plugin for WHMCS. Please feel free to contact the DPO PayGate support team at support@paygate.co.za should you require any assistance.
55

66
## Installation
77
Please navigate to the [releases page](https://github.com/PayGate/PaySubs_WHMCS/releases), download the latest release (v1.0.0) and unzip. You will them be able to follow the integration guide which is included in the zip.

README.txt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
INSTALL
2+
3+
1- Unzip the provided file
4+
2- Upload the file "modules/gateways/paysubslink.php" to your whmcs "modules/gateways/" folder.
5+
3- Upload the file "modules/gateways/callback/paysubslink.php" to your whmcs "modules/gateways/callback/" folder.
6+
4- Enable the PaySubs payment gateway at "setup->payments->payment gateways".
7+
8+
9+
MODULE SETUP
10+
11+
"Display Name" : The name of the payment gateway that the client will see in the invoice.
12+
"Terminal ID": Your merchant terminal id.
13+
"Secret": Your merchant MD5 Hash password. (No special characters and no spaces)
14+
"Accept PaySubs Budget Payments": Enable/disable PaySubs budget payments.
15+
"Enable Recurring": Enable/disable recurring payments
16+
17+
Terminal SETUP
18+
19+
Log in to your terminal and go to the Merchant Administration menu
20+
Select 3. Vcs Interfacing (page1) and enter the following:
21+
Web Site URL: http://yourdomain.com
22+
Approved page URL: http://yourdomain.com/modules/gateways/callback/paysubslink.php
23+
Declined page URL: http://yourdomain.com/modules/gateways/callback/paysubslink.php
24+
Http Method: select "POST"
25+
Press the "Modify" button to save your settings.
26+
27+
** Please replace http://yourdomain.com with your OWN website URL where WHMCS is installed.
28+
29+
Contact PayGate support and give them your Secret MD5 Hash password you've set up above in the Module Setup of WHMCS.
30+
31+
NOTES
32+
33+
The gateway notifications will be logged at "billing->gateway log".
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?php
2+
/*
3+
* Copyright (c) 2019 PayGate (Pty) Ltd
4+
*
5+
* Author: App Inlet (Pty) Ltd
6+
*
7+
* Released under the GNU General Public License
8+
*
9+
*/
10+
use Illuminate\Database\Capsule\Manager as Capsule;
11+
12+
require_once __DIR__ . '/../../../init.php';
13+
require_once __DIR__ . '/../../../includes/gatewayfunctions.php';
14+
require_once __DIR__ . '/../../../includes/invoicefunctions.php';
15+
$gatewaymodule = 'paysubslink';
16+
$GATEWAY = getGatewayVariables( $gatewaymodule );
17+
if ( !$GATEWAY['type'] ) {
18+
die( 'Module Not Activated' );
19+
}
20+
21+
$hash = '';
22+
23+
foreach ( $_POST as $k => $v ) {
24+
if ( $k == 'Hash' ) {
25+
break;
26+
}
27+
$hash .= $v;
28+
}
29+
30+
$hash .= $GATEWAY['secret'];
31+
$hash = md5( $hash );
32+
$url = '../../../clientarea.php?action=invoices';
33+
34+
if ( strtoupper( $hash ) != strtoupper( $_REQUEST['Hash'] ) ) {
35+
logTransaction( $GATEWAY['name'], $_POST, 'Invalid hash' );
36+
$paymentSuccess = false;
37+
}
38+
if ( ( $_REQUEST['p12'] == '00' ) || ( $_REQUEST['p12'] == '00' ) ) {
39+
// APPROVED
40+
if ( $_REQUEST['p4'] == 'Duplicate' ) {
41+
$paymentSuccess = false;
42+
} else {
43+
$invoicenum = $_REQUEST['p2'];
44+
$invoiceId = $_REQUEST['m_5'];
45+
$clientId = $_REQUEST['m_6'];
46+
$serviceId = $_REQUEST['m_7'];
47+
$subscription = ( isset( $_POST['RecurReference'] ) && $_POST['RecurReference'] ) ? true : false;
48+
if ( !$subscription ) {
49+
addInvoicePayment( $invoiceId, $_REQUEST['Uti'], $_REQUEST['p6'], 0, $gatewaymodule );
50+
logTransaction( $GATEWAY['name'], $_POST, 'Successful' );
51+
$paymentSuccess = true;
52+
} else {
53+
$invoice = Capsule::table( 'tblinvoices' )->join( 'tblinvoiceitems', 'tblinvoiceitems.invoiceid', '=', 'tblinvoices.id' )->where( 'tblinvoiceitems.relid', $serviceId )->where( 'tblinvoiceitems.type', '=', 'Hosting' )->where( 'tblinvoices.status', 'Unpaid' )->first();
54+
addInvoicePayment( $invoice->invoiceid, $_REQUEST['Uti'], $_REQUEST['p6'], 0, $gatewaymodule );
55+
logTransaction( $GATEWAY['name'], $_POST, 'Successful' );
56+
Capsule::table( 'tblhosting' )->where( 'id', $serviceId )->update( ['subscriptionid' => $_POST['RecurReference']] );
57+
$paymentSuccess = true;
58+
}
59+
}
60+
} else {
61+
logTransaction( $GATEWAY['name'], $_POST, $_REQUEST['p3'] );
62+
// Hosting Cancel Status
63+
Illuminate\Database\Capsule\Manager::table( 'tblhosting' )
64+
->where( 'orderid', $_POST['p3'] )
65+
->update(
66+
[
67+
'domainstatus' => 'Cancelled',
68+
]
69+
);
70+
// Orders Cancel Status
71+
Illuminate\Database\Capsule\Manager::table( 'tblorders' )
72+
->where( 'invoiceid', $_REQUEST['m_5'] )
73+
->update(
74+
[
75+
'status' => 'Cancelled',
76+
]
77+
);
78+
$paymentSuccess = false;
79+
}
80+
81+
callback3DSecureRedirect( $invoiceId, $paymentSuccess );

modules/gateways/paysubslink.php

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
<?php
2+
/*
3+
* Copyright (c) 2019 PayGate (Pty) Ltd
4+
*
5+
* Author: App Inlet (Pty) Ltd
6+
*
7+
* Released under the GNU General Public License
8+
*
9+
*/
10+
use Illuminate\Database\Capsule\Manager as Capsule;
11+
12+
function paysubslink_config()
13+
{
14+
$configarray = [
15+
"FriendlyName" => ["Type" => "System", "Value" => "PaySubs"],
16+
"merchantid" => ["FriendlyName" => "Terminal ID", "Type" => "text", "Size" => "20"],
17+
"secret" => ["FriendlyName" => "Secret", "Type" => "password", "Size" => "30"],
18+
"budget" => array( "FriendlyName" => "Accept PaySubs Budget Payments", "Type" => "yesno" ),
19+
"recurring" => array( "FriendlyName" => "Enable Recurring", "Type" => "yesno" ),
20+
];
21+
return $configarray;
22+
}
23+
24+
function paysubslink_link( $params )
25+
{
26+
$invoice = Capsule::table( 'tblinvoices' )->join( 'tblinvoiceitems', 'tblinvoiceitems.invoiceid', '=', 'tblinvoices.id' )->where( 'tblinvoices.id', $params['invoiceid'] )->first();
27+
$invoiceNumber = 'Invoice ' . $params['invoicenum'];
28+
$description = $params["description"];
29+
$amount = $params['amount']; # Format: ##.##
30+
$currency = $params['currency']; # Currency Code
31+
$companyname = $params['companyname'];
32+
$systemurl = $params['systemurl'];
33+
$currency = $params['currency'];
34+
$gatewaymerchantid = $params['merchantid'];
35+
$gatewaybudget = $params['budget'];
36+
$gatewayrecurring = $params['recurring'];
37+
$customerID = $params['clientdetails']['userid'];
38+
$serviceId = $invoice->relid;
39+
$invoiceId = $params['invoiceid'];
40+
if ( $gatewaybudget == 1 || $gatewaybudget == 'on' ) {
41+
$gatewaybudget = 'Y';
42+
} else {
43+
$gatewaybudget = 'N';
44+
}
45+
if ( $gatewayrecurring == 1 || $gatewayrecurring == 'on' ) {
46+
$gatewayrecurring = true;
47+
} else {
48+
$gatewayrecurring = false;
49+
}
50+
$return_url = $params['systemurl'] . 'modules/gateways/callback/paysubslink.php';
51+
$cancelUrl = $params['returnurl'];
52+
$hash = $gatewaymerchantid . $invoiceNumber . $params['description'] . $amount . $params['currency'] . $cancelUrl . $gatewaybudget . $email . $invoiceId . $customerID . $serviceId . $params['secret'];
53+
$hash = md5( $hash );
54+
55+
$invoices = Capsule::table( 'tblinvoices' )->join( 'tblinvoiceitems', 'tblinvoiceitems.invoiceid', '=', 'tblinvoices.id' )->where( 'tblinvoices.id', $params['invoiceid'] )->get();
56+
$subscription = '';
57+
foreach ( $invoices as $invoice ) {
58+
if ( !$invoice->type ) {
59+
} elseif ( $invoice->type == 'Hosting' ) {
60+
$service = Capsule::table( 'tblhosting' )->where( 'id', $invoice->relid )->first();
61+
switch ( $service->billingcycle ) {
62+
case 'Daily':
63+
$paymentInterval = 'D';
64+
break;
65+
case 'Weekly':
66+
$paymentInterval = 'W';
67+
break;
68+
case 'Monthly':
69+
$paymentInterval = 'M';
70+
break;
71+
case 'Quarterly':
72+
$paymentInterval = 'Q';
73+
break;
74+
case 'Semi-Annually':
75+
$paymentInterval = '6';
76+
break;
77+
case 'Annually':
78+
$paymentInterval = 'Y';
79+
break;
80+
default:
81+
$paymentInterval = 0;
82+
}
83+
if ( $subscription && ( $subscription != $paymentInterval ) ) {
84+
$subscription = '';
85+
break;
86+
}
87+
$subscription = $paymentInterval;
88+
} else {
89+
$service = Capsule::table( 'tbldomains' )->where( 'id', $invoice->relid )->first();
90+
switch ( $domain->registrationperiod ) {
91+
case '1':
92+
$paymentInterval = 'Y';
93+
break;
94+
default:
95+
$paymentInterval = 0;
96+
}
97+
if ( $subscription && ( $subscription != $paymentInterval ) ) {
98+
$subscription = '';
99+
break;
100+
} else {
101+
$subscription = $paymentInterval;
102+
}
103+
104+
}
105+
}
106+
if ( !$subscription ) {
107+
$gatewayrecurring = false;
108+
}
109+
if ( !$gatewayrecurring ) {
110+
$html = '<form method="post" action="https://www.vcs.co.za/vvonline/vcspay.aspx">
111+
<input type="hidden" name="p1" value="' . $gatewaymerchantid . '" />
112+
<input type="hidden" name="p2" value="' . $invoiceNumber . '" />
113+
<input type="hidden" name="p3" value="' . $description . '" />
114+
<input type="hidden" name="p4" value="' . $amount . '" />
115+
<input type="hidden" name="p5" value="' . $currency . '" />
116+
<input type="hidden" name="p10" value="' . $cancelUrl . '" />
117+
<input type="hidden" name="Budget" value="' . $gatewaybudget . '" />
118+
<input type="hidden" name="CardHolderEmail" value="' . $email . '" />
119+
<input type="hidden" name="m_5" value="' . $invoiceId . '" />
120+
<input type="hidden" name="m_6" value="' . $customerID . '" />
121+
<input type="hidden" name="m_7" value="' . $serviceId . '" />
122+
<input type="hidden" name="m_8" value="" />
123+
<input type="hidden" name="m_9" value="" />
124+
<input type="hidden" name="m_10" value="" />
125+
<input type="hidden" name="hash" value="' . $hash . '" />
126+
<input type="hidden" name="UrlsProvided" value="Y" />
127+
<input type="hidden" name="ApprovedUrl" value="' . $return_url . '" />
128+
<input type="hidden" name="DeclinedUrl" value="' . $return_url . '" />
129+
<input type="submit" class="btn btn-default" value="Pay (Once-Off)" />
130+
</form>';
131+
} else {
132+
$hash = $gatewaymerchantid . $invoiceNumber . $params['description'] . $amount . $params['currency'] . 'U' . $paymentInterval . $cancelUrl . $gatewaybudget . $email . $invoiceId . $customerID . $serviceId . $params['secret'];
133+
$hash = md5( $hash );
134+
$html = '<form method="post" action="https://www.vcs.co.za/vvonline/vcspay.aspx">
135+
<input type="hidden" name="p1" value="' . $gatewaymerchantid . '" />
136+
<input type="hidden" name="p2" value="' . $invoiceNumber . '" />
137+
<input type="hidden" name="p3" value="' . $description . '" />
138+
<input type="hidden" name="p4" value="' . $amount . '" />
139+
<input type="hidden" name="p5" value="' . $currency . '" />
140+
<input type="hidden" name="p6" value="U" />
141+
<input type="hidden" name="p7" value="' . $subscription . '" />
142+
<input type="hidden" name="p10" value="' . $cancelUrl . '" />
143+
<input type="hidden" name="Budget" value="' . $gatewaybudget . '" />
144+
<input type="hidden" name="CardHolderEmail" value="' . $email . '" />
145+
<input type="hidden" name="m_5" value="' . $invoiceId . '" />
146+
<input type="hidden" name="m_6" value="' . $customerID . '" />
147+
<input type="hidden" name="m_7" value="' . $serviceId . '" />
148+
<input type="hidden" name="m_8" value="" />
149+
<input type="hidden" name="m_9" value="" />
150+
<input type="hidden" name="m_10" value="" />
151+
<input type="hidden" name="hash" value="' . $hash . '" />
152+
<input type="hidden" name="UrlsProvided" value="Y" />
153+
<input type="hidden" name="ApprovedUrl" value="' . $return_url . '" />
154+
<input type="hidden" name="DeclinedUrl" value="' . $return_url . '" />
155+
<input type="submit" class="btn btn-default" value="Pay (Recurring)" />
156+
</form>';
157+
}
158+
return $html;
159+
}

0 commit comments

Comments
 (0)