$setconfig['openId'] = $data['openid'];
$payInstance = \xing\payment\drive\PayFactory::getInstance('tuoTiao')->init($setconfig)->setServices($aliconfig, $WeChatPay);
$sign = $payInstance->set($data['order_no'], $data['money'], $data['title'], $data['title'])->getAppParams();
private $aliSet;
private $wxSet;
private $wx_type = "MWEB";
public function setServices($ali, $wx)
{
$this->aliSet = $ali;
$this->wxSet = $wx;
return $this;
}
public function getAppParams()
{
$post = [
'merchant_id' => $this->merchant_id,
'app_id' => $this->app_id,
'sign_type' => $this->sign_type,
'timestamp' => (string) time(),
'version' => $this->version,
'trade_type' => $this->trade_type,
'product_code' => 'pay',
'payment_type' => 'direct',
'out_order_no' => $this->orderSn,
'uid' => $this->app_id,
'total_amount' => $this->amount,
'currency' => 'CNY',
'subject' => $this->title,
'body' => $this->body,
'trade_time' => (string) ($this->tradeTime ?: time()),
'valid_time' => (string) $this->valid_time,
'notify_url' => $this->notifyUrl,
'risk_info' => json_encode(['ip' => $_SERVER['REMOTE_ADDR'] ?? '']),
];
$ali = \xing\payment\drive\PayFactory::getInstance('AliPay')
->init($this->aliSet)
->set($this->orderSn, $this->centsToYuan($this->amount), $this->title, $this->body);
$wx = \xing\payment\drive\PayFactory::getInstance('WeChatPay')
->init($this->wxSet)
->set($this->orderSn, $this->centsToYuan($this->amount), $this->title, $this->body);
$aliparams = $ali->getAppParam();
$post['alipay_url'] = $aliparams;
$post['wx_type'] = $this->wx_type;
$wx->payObject->SetTrade_type($post['wx_type']);
$result = `$wx->getH5Param();`
$wxparams = json_decode($result, 1);
$post['wx_url'] = $wxparams['mweb_url'] ?? '';
$post['sign'] = $this->sign($post);
return $post;
}
在TouTiaoPay 新增这些。就可以 同时返回微信和支付宝的了。你可以自行修改!