Skip to content

Commit

Permalink
Merge pull request #68 from thejoshualewis/master
Browse files Browse the repository at this point in the history
ipn updates
  • Loading branch information
thejoshualewis authored Sep 17, 2020
2 parents ef377f7 + 95b90b7 commit e2863e4
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@
composer.lock
composer.phar
.DS_Store
modules/gateways/bitpaycheckout/bitpay.txt
4 changes: 2 additions & 2 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.6
* BitPay Checkout 3.0.1.7
*
* 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.6', // Use API Version 1.1
'APIVersion' => '3.0.1.7', // Use API Version 1.1
'DisableLocalCreditCardInput' => false,
'TokenisedStorage' => false,
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* BitPay Checkout Callback 3.0.1.6
* BitPay Checkout Callback 3.0.1.7
*
* This file demonstrates how a payment gateway callback should be
* handled within WHMCS.
Expand Down
19 changes: 18 additions & 1 deletion 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.6
* BitPay Checkout IPN 3.0.1.7
*
* This file demonstrates how a payment gateway callback should be
* handled within WHMCS.
Expand All @@ -22,6 +22,16 @@
require_once '../../../includes/gatewayfunctions.php';
require_once '../../../includes/invoicefunctions.php';

function checkInvoiceStatus($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}

$all_data = json_decode(file_get_contents("php://input"), true);
$file = 'bitpay.txt';

Expand All @@ -41,6 +51,13 @@

$price = $data['price'];

$url_check = str_replace("invoice?id=","invoices/",$data['url']);
$invoiceStatus = json_decode(checkInvoiceStatus($url_check));
if($order_status != $invoiceStatus->data->status):
#ipn doesnt match data, stop
die();
endif;

#first see if the ipn matches
#get the user id first
$table = "_bitpay_checkout_transactions";
Expand Down

0 comments on commit e2863e4

Please sign in to comment.