Skip to content

Commit

Permalink
IPN updates
Browse files Browse the repository at this point in the history
  • Loading branch information
thejoshualewis committed Jun 8, 2021
1 parent 3a1a4a4 commit d3fb179
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions modules/gateways/bitpaycheckout/bitpaycheckout_ipn.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

/**
* BitPay Checkout IPN 3.1.0.0
*
Expand Down Expand Up @@ -49,19 +48,13 @@ function checkInvoiceStatus($url){
$order_status = $data['status'];
$order_invoice = $data['id'];
$endpoint = $gatewayParams['bitpay_checkout_endpoint'];

if($endpoint == "Test"):
$url_check = 'https://test.bitpay.com/invoices/'.$order_invoice;
else:
$url_check = 'https://www.bitpay.com/invoices/'.$order_invoice;
endif;
$invoiceStatus = json_decode(checkInvoiceStatus($url_check));

if($order_status != $invoiceStatus->data->status):
#ipn doesnt match data, stop
die();
endif;

$event = $all_data['event'];
$orderid = $invoiceStatus->data->orderId;
$price = $invoiceStatus->data->price;
Expand All @@ -75,10 +68,14 @@ 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':

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 Down Expand Up @@ -107,6 +104,8 @@ function checkInvoiceStatus($url){
0,
'bitpaycheckout'
);
endif;


break;

Expand Down

0 comments on commit d3fb179

Please sign in to comment.