<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Allinpay extends CI_Controller {

    public function __construct() {
        parent::__construct();
        //$this->output->enable_profiler(TRUE);
        $this->load->model('Paypal_model');
    }

    //收款记录列表
    public function index() {
        $this->permission->is_admin(true);
    }

    //接收付款通知的消息
    public function note() {
        $pn_txn_id = date('YmdHis', time());

        $pn_invoice = $this->input->post('invoice');
        if (empty($pn_invoice)) {
            $pn_invoice = '';
        }

        $pn_custom = $this->input->post('custom');
        if (empty($pn_custom)) {
            $pn_custom = '';
        }

        $pn_item_number = $this->input->post('item_number');
        if (empty($pn_item_number)) {
            $pn_item_number = '';
        }

        $pn_item_name = $this->input->post('item_name');
        if (empty($pn_item_name)) {
            $pn_item_name = '';
        }

        $pn_mc_gross = '';
        $pn_mc_currency = '';
        $pn_payment_status = '';
        $pn_payment_date = '';
        $pn_payer_email = '';
        $pn_memo = json_encode($_POST);
        if (!empty($pn_txn_id)) {
            //把PDT时间转成GMT时间
            $pn_payment_date = gmdate('Y-m-d H:i:s', strtotime($pn_payment_date));
            //$this->Paypal_model->save_paypal_note($pn_txn_id, $pn_invoice, $pn_custom, $pn_mc_gross, $pn_item_name, $pn_item_number, $pn_mc_currency, $pn_payment_status, $pn_payer_email, $pn_payment_date, $pn_memo);
            echo 'ok';
        } else {
            echo 'no';
        }
    }

    //识别订单号
    //发送消息给对应的外联
    //添加付款操作
    public function dsdsdsd() {
        
    }

}
