Skip to content

Commit

Permalink
added Declined state
Browse files Browse the repository at this point in the history
  • Loading branch information
thejoshualewis committed Aug 16, 2021
1 parent 37af9e6 commit a5f8705
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
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.1.1.0
* BitPay Checkout 4.0.1
*
* 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_WHMCS',
'APIVersion' => '3.1.1.0', // Use API Version 1.1
'APIVersion' => '4.0.1', // Use API Version 1.1
'DisableLocalCreditCardInput' => false,
'TokenisedStorage' => false,
);
Expand Down
4 changes: 2 additions & 2 deletions modules/gateways/bitpaycheckout/bitpaycheckout.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* BitPay Checkout 3.1.1.0
* BitPay Checkout 4.0.1
*
* 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_WHMCS',
'APIVersion' => '3.1.1.0', // Use API Version 1.1
'APIVersion' => '4.0.1', // 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.1.1.0
* BitPay Checkout Callback 4.0.1
*
* This file demonstrates how a payment gateway callback should be
* handled within WHMCS.
Expand Down
16 changes: 7 additions & 9 deletions modules/gateways/bitpaycheckout/bitpaycheckout_ipn.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* BitPay Checkout IPN 3.1.1.0
* BitPay Checkout IPN 4.0.1
*
* This file demonstrates how a payment gateway callback should be
* handled within WHMCS.
Expand Down Expand Up @@ -38,6 +38,7 @@ function checkInvoiceStatus($url){

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

file_put_contents($file,"===========INCOMING IPN=========================",FILE_APPEND);
file_put_contents($file,date('d.m.Y H:i:s'),FILE_APPEND);
Expand Down Expand Up @@ -68,14 +69,12 @@ function checkInvoiceStatus($url){
$result = select_query($table, $fields, $where);
$rowdata = mysql_fetch_array($result);
$btn_id = $rowdata['transaction_id'];
$status_arr = ['confirmed','complete'];

if($btn_id):
switch ($event['name']) {
#complete, update invoice table to Paid
case 'invoice_completed':
case 'invoice_confirmed':

if(in_array($order_status,$status_arr) && $order_status == "complete"):

$table = "tblinvoices";
$update = array("status" => 'Paid','datepaid' => date("Y-m-d H:i:s"));
Expand All @@ -84,7 +83,7 @@ function checkInvoiceStatus($url){
update_query($table, $update, $where);
}
catch (Exception $e ){
file_put_contents($file,$e,FILE_APPEND);
file_put_contents($err,$e,FILE_APPEND);
}

#update the bitpay_invoice table
Expand All @@ -94,7 +93,7 @@ function checkInvoiceStatus($url){
try{
update_query($table, $update, $where);
}catch (Exception $e ){
file_put_contents($file,$e,FILE_APPEND);
file_put_contents($err,$e,FILE_APPEND);
}

addInvoicePayment(
Expand All @@ -104,9 +103,6 @@ function checkInvoiceStatus($url){
0,
'bitpaycheckout'
);
endif;


break;

#processing - put in Payment Pending
Expand All @@ -133,6 +129,8 @@ function checkInvoiceStatus($url){

#confirmation error - put in Unpaid
case 'invoice_failedToConfirm':
case 'invoice_declined':

$table = "tblinvoices";
$update = array("status" => 'Unpaid');
$where = array("id" => $orderid, "paymentmethod" => "bitpaycheckout");
Expand Down

0 comments on commit a5f8705

Please sign in to comment.