-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathstatus.php
More file actions
35 lines (23 loc) · 934 Bytes
/
status.php
File metadata and controls
35 lines (23 loc) · 934 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
require_once 'lib/PayBearOrder.php';
require_once 'lib/PayBearTxn.php';
$payBearOrder = new PayBearOrder();
$payment_txn = new PayBearTxn();
$order_id = $_GET['order_id'];
if (empty($order_id)) return;
$payment = $payBearOrder->findByOrderId($order_id);
if (empty($payment)) return;
$confirmations = $payment_txn->getTxnConfirmations($order_id);
$maxConfirmations = $payment->max_confirmations;
$coinsPaid = $payment_txn->getTotalPaid($order_id);
$coinsTotalConfirmed = $payment_txn->getTotalConfirmed($order_id, $maxConfirmations);
$orderAmount = $payment->amount;
$data = array();
if ($coinsTotalConfirmed >= $orderAmount) {
$data['success'] = true;
} else {
$data['success'] = false;
}
if (is_numeric($confirmations)) $data['confirmations'] = $confirmations;
$data['coinsPaid'] = $coinsPaid;
echo json_encode($data); //return this data to PayBear form