Native支付是商户系统按微信支付协议生成支付二维码,用户再用微信“扫一扫”完成支付的模式。该模式适用于PC网站支付、实体店单品或订单支付、媒体广告支付等场景。
支付类:
<?php
/**
* Created by PhpStorm.
* User: 827169570@qq.com
* Date: 2020/10/16
* Time: 23:01
*/
namespace app\v1\controller;
use app\common\controller\Checking;
use think\Controller;
use think\Exception;
class Wxnative extends Controller
{
const APPID='';
const MCHID='';
const KEY='';
const NOTIFYURL='';//支付成功异步回调地址
//微信支付参数
/**
* 微信支付-发起订单.
*
* @param float $totalFee 收款总费用 单位元
* @param string $outTradeNo 唯一的订单号
* @param string $orderName 订单名称
* @param string $notifyUrl 支付结果通知url 不要有问号
* @param string $timestamp 订单发起时间
*
* @return array
*/
public function wxNativePay($totalFee, $outTradeNo, $body= '充值'){
header('Content-type:text/html; Charset=utf-8');
//
// $totalFee=0.01; $outTradeNo=time();$orderName = '充值';
//获取微信支付参数
//订单发起时间
$timestamp = time();
$unified = array(
'appid' => self::APPID,
'attach' => 'pay',
'body' => $body,
'mch_id' => self::MCHID,
'nonce_str' => $this->createNonceStr(),
'notify_url' => self::NOTIFYURL,
'out_trade_no' => $outTradeNo,
'spbill_create_ip' => $this->get_client_ip(),

本文详细介绍了微信Native支付模式的工作原理和技术实现细节,包括生成支付二维码的过程、支付参数的构造及签名验证方法,并展示了如何处理支付成功后的回调通知。
最低0.47元/天 解锁文章
2013

被折叠的 条评论
为什么被折叠?



