Ejemplo n.º 1
0
 /**
  * 生成动态NATIVE方式的微信订单
  * @param array $options 参数数组
  * @return array
  */
 public function createDynamicNativeOrder($options)
 {
     $resArr = ['code' => 0];
     $goods_name = mb_strlen($options['goods_name']) > 32 ? mb_substr($options['goods_name'], 0, 32) : $options['goods_name'];
     //使用统一支付接口
     $unifiedOrderModel = new WxPayUnifiedOrder($this->wx_config);
     //设置必填参数
     $unifiedOrderModel->setParameter("body", $goods_name);
     //商品描述
     $unifiedOrderModel->setParameter("out_trade_no", $options['order_sn']);
     //商户订单号
     $unifiedOrderModel->setParameter("attach", $options['attach']);
     //附加数据
     $unifiedOrderModel->setParameter("total_fee", $options['amount'] . "");
     //总金额
     $unifiedOrderModel->setParameter("notify_url", $options['notify_url']);
     //通知地址
     $unifiedOrderModel->setParameter("trade_type", "NATIVE");
     //交易类型
     //获取统一支付接口结果
     $unifiedOrderResult = $unifiedOrderModel->getResult();
     $resArr['data'] = $unifiedOrderResult;
     return $resArr;
 }