Skip to content

Commit

Permalink
Merge pull request #61 from thejoshualewis/master
Browse files Browse the repository at this point in the history
IPN Table updates
  • Loading branch information
thejoshualewis authored Jul 17, 2019
2 parents 36a4d34 + 41bddbe commit 4972220
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 41 deletions.
46 changes: 12 additions & 34 deletions modules/gateways/bitpaycheckout.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* BitPay Checkout 3.0.1.2
* BitPay Checkout 3.0.1.3
*
* Within the module itself, all functions must be prefixed with the module
* filename, followed by an underscore, and then the function name. For this
Expand Down Expand Up @@ -54,7 +54,7 @@ function bitpaycheckout_MetaData()
{
return array(
'DisplayName' => 'BitPay_Checkout_WHCMS',
'APIVersion' => '3.0.1.0', // Use API Version 1.1
'APIVersion' => '3.0.1.3', // Use API Version 1.1
'DisableLocalCreditCardInput' => false,
'TokenisedStorage' => false,
);
Expand Down Expand Up @@ -108,43 +108,14 @@ function bitpaycheckout_config()
'Default' => '',
'Description' => 'Your <b>production</b> merchant token. <a href = "https://www.bitpay.com/dashboard/merchant/api-tokens" target = "_blank">Create one here</a> and <b>uncheck</b> `Require Authentication`.',
),
/*
'bitpay_checkout_risk' => array(
'FriendlyName' => 'Risk Mitigation',
'Type' => 'dropdown',
'Options' => 'Default,High,Medium,Low',
'Description' => '
<ul>
<li> <b>High</b>: The merchant takes the risk to dispatch orders where the payment has not yet been confirmed by BitPay.</li>
<li> <b>Medium</b>: The merchant decides to dispatch orders where the BitPay invoice has been set to “confirmed” by BitPay (for instance, with a Bitcoin payment, this is equivalent to 1 block confirmation). This is the default option and best trade off in terms of consumer experience versus security.</li>
<li> <b>Low</b>: The merchant decides to dispatch orders where the BitPay invoice has been set to “complete” by BitPay (for instance, with a Bitcoin payment, this is equivalent to 6 block confirmation). This is the most secure option but it requires the consumer to wait about 1 hour to get the order confirmation.
(note: this parameter is also called “transaction speed” in our system)</li>
<li> <b>Default</b>: This will use the default setting in your Dashboard (<b><i>medium</i></b>)</li>
</ul>',
),

'bitpay_checkout_dateformat' => array(
'FriendlyName' => 'Date Format',
'Type' => 'dropdown',
'Options' => 'Y-m-d,d-m-Y',
'Description' => 'By default, the date will be formatted as Y-m-d (2019-05-31). d-m-Y will format to (05-31-2019)',
),
*/
'bitpay_checkout_endpoint' => array(
'FriendlyName' => 'Endpoint',
'Type' => 'dropdown',
'Options' => 'Test,Production',
'Description' => 'Select <b>Test</b> for testing the plugin, <b>Production</b> when you are ready to go live.<br>',
),
/*
'bitpay_checkout_logging' => array(
'FriendlyName' => 'Error Logging',
'Type' => 'radio',
'Options' => 'Yes, No',
'Description' => 'If <b>Yes</b>, BitPay will log the invoice data (Invoice ID, API endpoint, etc) to your server\'s error log.<br>',
),
*/


);
}
Expand Down Expand Up @@ -232,8 +203,8 @@ function bitpaycheckout_link($config_params)
if ($dir == '/') {
$dir = '';
}
$protocol = stripos($_SERVER['SERVER_PROTOCOL'], 'https') === true ? 'https://' : 'http://';

#$protocol = stripos($_SERVER['SERVER_PROTOCOL'], 'https') === true ? 'https://' : 'http://';
$protocol = 'https://';
$callback_url = $protocol . $_SERVER['SERVER_NAME'] . $dir . '/modules/gateways/bitpaycheckout/bitpaycheckout_callback.php';
$params->extension_version = bitpaycheckout_MetaData();
$params->extension_version = $params->extension_version['DisplayName'] . '_' . $params->extension_version['APIVersion'];
Expand Down Expand Up @@ -302,6 +273,13 @@ function bitpaycheckout_link($config_params)
<script type='text/javascript'>
function showModal(invoiceData) {
$post_url = '<?php echo $callback_url; ?>'
$idx = $post_url.indexOf('https')

if($idx == -1 && location.protocol == 'https:'){
$post_url = $post_url.replace('http','https')
}


$encodedData = invoiceData
invoiceData = atob(invoiceData);

Expand Down
4 changes: 2 additions & 2 deletions modules/gateways/bitpaycheckout/bitpaycheckout_callback.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* BitPay Checkout Callback 3.0.1.2
* BitPay Checkout Callback 3.0.1.3
*
* This file demonstrates how a payment gateway callback should be
* handled within WHMCS.
Expand Down Expand Up @@ -112,7 +112,7 @@
$pending_lbl = 'Payment Pending';

$table = "tblinvoices";
$update = array("status" => $pending_lbl);
$update = array("status" => $pending_lbl,'datepaid' => date("Y-m-d H:i:s"));
$where = array("id" => $all_data->data->orderId, "paymentmethod" => "bitpaycheckout");
update_query($table, $update, $where);

Expand Down
9 changes: 4 additions & 5 deletions modules/gateways/bitpaycheckout/bitpaycheckout_ipn.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* BitPay Checkout IPN 3.0.1.2
* BitPay Checkout IPN 3.0.1.3
*
* This file demonstrates how a payment gateway callback should be
* handled within WHMCS.
Expand Down Expand Up @@ -40,7 +40,6 @@

$price = $data['price'];

$data['id'];
#first see if the ipn matches
#get the user id first
$table = "_bitpay_checkout_transactions";
Expand All @@ -57,7 +56,7 @@
case 'invoice_confirmed':

$table = "tblinvoices";
$update = array("status" => 'Paid');
$update = array("status" => 'Paid','datepaid' => date("Y-m-d H:i:s"));
$where = array("id" => $orderid, "paymentmethod" => "bitpaycheckout");
update_query($table, $update, $where);

Expand All @@ -73,7 +72,7 @@
#processing - put in Payment Pending
case 'invoice_paidInFull':
$table = "tblinvoices";
$update = array("status" => 'Payment Pending');
$update = array("status" => 'Payment Pending','datepaid' => date("Y-m-d H:i:s"));
$where = array("id" => $orderid, "paymentmethod" => "bitpaycheckout");
update_query($table, $update, $where);

Expand Down Expand Up @@ -128,7 +127,7 @@

#update the tblinvoices to show Refunded
$table = "tblinvoices";
$update = array("status" => 'Refunded');
$update = array("status" => 'Refunded','datepaid' => date("Y-m-d H:i:s"));
$where = array("id" => $orderid, "paymentmethod" => "bitpaycheckout");
update_query($table, $update, $where);

Expand Down

0 comments on commit 4972220

Please sign in to comment.