Heim >Backend-Entwicklung >PHP-Tutorial >Bezahlung per WeChat-App

Bezahlung per WeChat-App

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-29 09:11:031219Durchsuche

Dokument
Hinweis: WeChat-Zahlungen auf der offenen Plattform und WeChat-Zahlungen auf dem offiziellen Konto sind unterschiedlich. Nachdem der Zahlungsantrag für die öffentliche Plattform und die offene Plattform abgeschlossen ist, gibt es entsprechende Händlerplattformkonten

<code>function wechat($appid,$mchid,$appkey,$cert_path,$key_path,$order_id,$openid,$amount,$desc){
    $arr = [
            'mch_appid'=>$appid,//注意区分公众号和app商户号不同
            'mchid'=>$mchid,
            'nonce_str'=>str_random(32),//随机数
            'partner_trade_no'=>$order_id,//自己定义一个不重复订单号
            'openid'=>$openid,//微信openid 通过微信授权登录获取
            'check_name'=>'NO_CHECK',
            'amount'=>$amount*100,//注意这里传给微信的单位是分
            'desc'=>$desc,
            'spbill_create_ip'=>\Request::getClientIp(),
            'sign'=>'',
        ];
        ksort($arr);
        $sign="";
        foreach ($arr as $key => $value) {
            if($value && $key!="sign" && $key!="key"){
                $sign.=$key."=".$value."&";
            }
        }
        $sign.="key=".$appkey;//商户后台自定义的
        $arr['sign'] = strtoupper(md5($sign));
        $xml = "<xml>";
        foreach ($arr as $key=>$val)
        {
                if (is_numeric($val))
             {
                $xml.="<".$key.">".$val."</".$key.">"; 

             }
             else
                $xml.="<".$key."><![CDATA[".$val."]]></".$key.">";  
        }
        $xml.="</xml>";
       
        $ch = curl_init();
        //超时时间
        curl_setopt($ch,CURLOPT_TIMEOUT,60);
        curl_setopt($ch,CURLOPT_URL,'https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers');
        curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
        curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,false);
        //默认格式为PEM
        curl_setopt($ch,CURLOPT_SSLCERTTYPE,'PEM');
        curl_setopt($ch,CURLOPT_SSLCERT,$cert_path);//注意区分公众号和app商户号的证书不同,需要到pay.weixin.qq.com后台下载
        curl_setopt($ch,CURLOPT_SSLKEYTYPE,'PEM');
        curl_setopt($ch,CURLOPT_SSLKEY,$key_path);
        curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
        curl_setopt($ch,CURLOPT_POST, 1);
        curl_setopt($ch,CURLOPT_POSTFIELDS,$xml);
        $data = curl_exec($ch);
        $data = json_decode(json_encode(simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
        curl_close($ch);
        return $data;//$data['return_code'] == 'SUCCESS' && $data['result_code'] == 'SUCCESS' 支付成功
    }
    }</code>

Anhang:
https://youqingkui.me/note/e57abb2a-3997-47f1-b9fe-ac94740130ce
Python-Version der WeChat-Zahlung
http://bblove.me/2015 /10/25/ weixin-app-pay-v3-0/
WeChat APP-Zahlungsserver-PHP-SDK-Entwicklungs-Tutorial
https://github.com/fanhefan/wechat_app_pay
WeChat Red Envelope API-Schnittstelle
http://jeffchen.sinaapp.com/
http://tao.logdown.com/posts/195357-micro- payments-app-integration

Das Obige hat die WeChat-App-Zahlung eingeführt, einschließlich Github-Inhalten. Ich hoffe, dass es für Freunde hilfreich ist, die sich für PHP-Tutorials interessieren.

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn