Example #1
0
if ($_REQUEST['action'] == 'refund') {
    $t_id = $_REQUEST['transaction_id'];
    #$sql = "SELECT * from jb_txn, orders, users where jb_txn.invoice_id=orders.invoice_id AND orders.user_id=users.ID and jb_txn.transaction_id=$t_id";
    $sql = "SELECT * from jb_txn where transaction_id='" . jb_escape_sql($t_id) . "'";
    $result = JB_mysql_query($sql) or die(mysql_error());
    $row = mysql_fetch_array($result, MYSQL_ASSOC);
    if ($row['status'] != 'Completed') {
        // check that there's no other refund...
        $sql = "SELECT * FROM jb_txn where txn_id='" . jb_escape_sql($row['txn_id']) . "' AND type='CREDIT' ";
        $r = JB_mysql_query($sql) or die(mysql_error());
        if (mysql_num_rows($r) == 0) {
            // do the refund
            if ($row['product_type'] == 'P') {
                JB_reverse_package_invoice($row['invoice_id'], 'refund');
            } elseif ($row['product_type'] == 'S') {
                JB_reverse_subscription_invoice($row['invoice_id'], 'refund');
            } elseif ($row['product_type'] == 'M') {
                JB_reverse_membership_invoice($row['invoice_id'], 'refund');
            }
            JB_credit_transaction($row['invoice_id'], $row['amount'], $row['currency'], $row['txn_id'], 'Refund', 'Admin', $row['product_type']);
            $JBMarkup->ok_msg('Refund completed.');
        } else {
            echo "<b>Error: A refund was already found on this system for this order..</b><br>";
        }
    } else {
        //echo $row['status'];
        echo "<b>Error: The system can only refund orders that are completed, please cancel the order first</b><br>";
    }
    // can only refund completed orders..
}
// calculate the balance
Example #2
0
                            // reason_code : 'buyer_complaint', 'chargeback', 'guarantee', 'refund', 'other'
                        } elseif ($product_type == 'S') {
                            JB_reverse_subscription_invoice($invoice_id, $reason_code);
                        } elseif ($product_type == 'M') {
                            JB_reverse_membership_invoice($invoice_id, $reason_code);
                        }
                        JBPLUG_do_callback('pay_trn_verification_reversed', $invoice_id, $product_type);
                        JB_credit_transaction($invoice_id, $mc_gross, $mc_currency, $txn_id, $reason_code, 'PayPal', $product_type);
                        pp_log_entry('refunded reason: ' . $reason_code);
                        break;
                    case "Reversed":
                        if ($product_type == 'P') {
                            JB_reverse_package_invoice($invoice_id, $reason_code);
                            // reason_code : 'buyer_complaint', 'chargeback', 'guarantee', 'refund', 'other'
                        } elseif ($product_type == 'S') {
                            JB_reverse_subscription_invoice($invoice_id, $reason_code);
                        } elseif ($product_type == 'M') {
                            JB_reverse_membership_invoice($invoice_id, $reason_code);
                        }
                        JBPLUG_do_callback('pay_trn_verification_reversed', $invoice_id, $product_type);
                        JB_credit_transaction($invoice_id, $mc_gross, $mc_currency, $txn_id, $reason_code, 'PayPal', $product_type);
                        break;
                    default:
                        break;
                }
            }
        } else {
            JBPLUG_do_callback('pay_trn_verification_failed', $invoice_id, $product_type);
        }
    }
}