예제 #1
0
// check if transaction was approved
$status = $_POST["status"];
$failReason = $_POST["failReason"];
if ($status != "APPROVED") {
    echo "<br><br>";
    echo "Transaction declined!<br>";
    echo "Error: '{$failReason}'<br><br>";
    report_blocked_transaction();
    exit;
}
// check if we was preauthorizing
$x_auth = $_POST['x_auth'];
if ($x_auth == 1) {
    process_auth();
} else {
    process_payment();
}
?>
 
</body>
</html>

<?php 
//
//
// logic functions
//
//
function get_result_from_code($approval_code)
{
    $appfields = explode(':', $approval_code);
		$logger->log('txn_error: '.$SofortLibTransactionData->getError(), VI_LOG_LEVEL_ERROR);
		die();
	} else {
		ob_start();
		var_dump($output);
		$result = ob_get_clean();	
		$logger->log('output: '.$result, VI_LOG_LEVEL_DEBUG);
	}
*/
if (isset($_POST['user_variable_0'])) {
    $name = $_POST['user_variable_0'];
} else {
    die('Invalid POST data');
}
if (isset($_POST['user_variable_1'])) {
    $email = $_POST['user_variable_1'];
} else {
    die('Invalid POST data');
}
if (isset($_POST['user_variable_2'])) {
    $type = $_POST['user_variable_2'];
} else {
    die('Invalid POST data');
}
$payment_status = 'completed';
// process payment
if (true) {
    // TODO: better verification
    require_once __DIR__ . '/database-model.php';
    process_payment($payment_status, 'sofortueberweisung', $txn_id, $name, $email, $type);
}
예제 #3
0
function processing($payment_status, $params)
{
    global $paypal_email, $paypal_currency;
    $invoice_id = $params['item_number'];
    $invoice = PackageInvoice::find_by_id($invoice_id);
    switch ($payment_status) {
        case "Canceled_Reversal":
            $invoice->package_status = 'Canceled_Reversal';
            $invoice->update_package_status();
            break;
        case "Completed":
            if ($paypal_email == $params['receiver_email'] && $paypal_currency == $params['mc_currency'] && $invoice->amount == $params['mc_gross'] && $invoice->package_status != "Completed") {
                $param['payment_status'] = "Completed";
                //what is the status of the payment
                $param['amount'] = $params['mc_gross'];
                // how much was paid for this total amount for each item
                $param['currency'] = $paypal_currency;
                //what currecy they used to pay for this
                $param['receiver_id'] = $params['receiver_id'];
                // what is the id of person who is paying
                $param['payment_email'] = $params['payer_email'];
                // what email have they used to pay
                $param['txn_id'] = $params['txn_id'];
                // txt id
                $param['txn_type'] = $params['txn_type'];
                // how are they pay for this web or ext.
                $param['payer_status'] = $params['payer_status'];
                //is user verfied by the method they pay from
                $param['residence_country'] = $params['residence_country'];
                //which country does user belogn to
                //$params['origin'] = ""; //where is the payment come from
                $param['payment_method'] = "paypal";
                // what methoid of payment they used e.g. paypal, ccbill
                $param['payment_vars'] = addslashes(serialize($params));
                //get all var which are return from online site.
                $param['payment_type'] = $params['payment_type'];
                //how they pay for this
                $param['reason'] = "";
                // if they cancel then tell user why
                process_payment($invoice_id, $param);
            }
            break;
        case "Denied":
            // denied by merchant
            //$invoice->id = $invoice_id;
            $invoice->package_status = 'Denied';
            $invoice->update_package_status();
            break;
        case "Failed":
            // only happens when payment is from customers' bank account
            //$invoice->id = $invoice_id;
            $invoice->package_status = 'Failed';
            $invoice->update_package_status();
            break;
        case "Pending":
            //$invoice->id = $invoice_id;
            $invoice->package_status = 'Pending';
            $invoice->update_package_status();
            break;
        case "Refunded":
            //$invoice->id = $invoice_id;
            $invoice->package_status = 'Refunded';
            $invoice->update_package_status();
            break;
        case "Reversed":
            //$invoice->id = $invoice_id;
            $invoice->package_status = 'Reversed';
            $invoice->update_package_status();
            break;
        case "Expired":
            //$invoice->id = $invoice_id;
            $invoice->package_status = 'Expired';
            $invoice->update_package_status();
            break;
        default:
            break;
    }
}
    // check that receiver_email is your Primary PayPal email
    // check that payment_amount/payment_currency are correct
    // process the notification
    // assign posted variables to local variables
    // $item_name = $_POST['item_name'];
    // $item_number = $_POST['item_number'];
    $payment_status = $_POST['payment_status'];
    // $payment_amount = $_POST['mc_gross'];
    // $payment_currency = $_POST['mc_currency'];
    $txn_id = $_POST['txn_id'];
    // $receiver_email = $_POST['receiver_email'];
    // $payer_email = $_POST['payer_email'];
    $custom = $_POST['custom'];
    // IPN message values depend upon the type of notification sent.
    // To loop through the &_POST array and print the NV pairs to the screen:
    /*
    foreach($_POST as $key => $value) {
      echo $key." = ". $value."<br>";
    }
    */
    // process payment
    require_once __DIR__ . '/database-model.php';
    if ($payment_status == 'Completed') {
        $payment_status = 'completed';
    }
    $fields = explode('&&', $custom);
    $name = $fields[0];
    $email = $fields[1];
    $type = $fields[2];
    process_payment($payment_status, 'paypal', $txn_id, $name, $email, $type);
}
    $param['txn_type'] = "web";
    // how are they pay for this web or ext.
    $param['payer_status'] = "N/A";
    //is user verfied by the method they pay from
    $param['residence_country'] = "N/A";
    //which country does user belogn to
    //$param['origin'] = ""; //where is the payment come from
    $param['payment_method'] = "free";
    // what methoid of payment they used e.g. paypal, ccbill
    $param['payment_vars'] = "N/A";
    //get all var which are return from online site.
    $param['payment_type'] = "free";
    //how they pay for this
    $param['reason'] = "None";
    // if they cancel then tell user why
    process_payment($invoice_id, $param);
    $smarty->assign('order_number', $invoice_id);
    $smarty->assign('num_of_posts', $packageinvoice->posts_quantity);
    $smarty->assign('price', $packageinvoice->amount);
    $smarty->assign('status', "Completed");
    $smarty->assign('payment_from', $payment_from);
    $html_title = SITE_NAME . " - Thank you for your payment ";
    $smarty->assign('lang', $lang);
    $smarty->assign('message', $message);
    $smarty->assign('rendered_page', $smarty->fetch('employer/thankyou.tpl'));
} elseif ($payment_cancel != '' || isset($payment_cancel)) {
    $invoice = PackageInvoice::find_by_id($invoice_id);
    $invoice->package_status = 'Cancelled';
    //$invoice->processed_date 	= date("Y-m-d H:i:s", time() );
    $invoice->update_package_status();
    $invoice_item = new Invoice();