Exemplo n.º 1
0
/**
 * 微信支付回调接口
 * 1. 模式1,扫码支付回调,这是通知的内容是支付成功与否,会传入transaction_id out_trade_no
 * 2. 模式2,这是通知的内容是用户是否成功扫码了,会传入product_id,openid
 */
chdir(dirname(__FILE__));
//把工作目录切换到文件所在目录
include_once dirname(__FILE__) . '/__config__.php';
$data = @$GLOBALS["HTTP_RAW_POST_DATA"];
YDWXHook::do_hook(YDWXHook::YDWX_LOG, $data);
$msg = new YDWXPaiedNotifyResponse($data);
if ($msg->isSuccess()) {
    if ($msg->product_id) {
        $PayingMsg = new YDWXPayingNotifyResponse($data);
        $result = new YDWXPayNotifyRequest();
        try {
            $arg = YDWXHook::do_hook(YDWXHook::QRCODE_PAY_NOTIFY_SUCCESS, $PayingMsg);
            $arg->openid = $PayingMsg->openid;
            $msg = ydwx_pay_unifiedorder($arg);
            $result_code = "SUCCESS";
            $err_code_des = "OK";
            $result->prepay_id = $msg->prepay_id;
        } catch (YDWXException $e) {
            $result_code = "FAIL";
            $err_code_des = $e->getMessage();
        }
        $result->result_code = $result_code;
        $result->err_code_des = $err_code_des;
        $result->sign();
        echo $result->toXMLString();
Exemplo n.º 2
0
Arquivo: pay.php Projeto: qujian/ydwx
 public function valid()
 {
     parent::valid();
     if ($this->trade_type == "JSAPI") {
         $this->spbill_create_ip = $_SERVER['REMOTE_ADDR'];
     } else {
         if ($this->trade_type == "NATIVE") {
             $this->spbill_create_ip = $_SERVER['SERVER_ADDR'];
         }
     }
     if ($this->trade_type == "JSAPI" && !$this->openid) {
         throw new YDWXException("JSAPI支付时openid不能为空");
     } else {
         if ($this->trade_type == "NATIVE" && !$this->product_id) {
             throw new YDWXException("NATIVE支付时product_id不能为空");
         }
     }
 }