示例#1
0
<?php

//Include the common file
require_once '../../common.php';
//Initialize object
$paypal = new Paypal();
//Validate ipn
$paypal->validate_ipn($_POST);
//Check ipn transaction
if (!$paypal->is_verified()) {
    $paypal->log_response();
    die;
}
//Switch action
switch ($paypal->get_payment_status()) {
    case 'Pending':
        $paypal->log_payment("Pending Payment");
        break;
    case 'Completed':
        $paypal->log_payment("Completed Payment");
        $values = array('order_status_description_id' => '2');
        $where = array('order_id' => $paypal->get_order_id());
        $db->where($where);
        $db->update(config_item('cart', 'table_orders'), $values);
        foreach ($db->query("SELECT order_digital_good_id, number_days FROM " . config_item('cart', 'table_order_digital_goods') . " WHERE order_id = '" . $paypal->get_order_id() . "'") as $row) {
            if ($row['number_days'] > 0) {
                $values = array('date_expiration' => time() + $row['number_days'] * 3600 * 24);
            } else {
                $values = array('date_expiration' => 0);
            }
            $where = array('order_id' => $paypal->get_order_id(), 'order_digital_good_id' => $row['order_digital_good_id']);