微信支付对接一般都有现成的接入demo,实际场景中有些商家需要跟银行的系统接入进行微信支付。那这些资料就没有那么多可以参考的代码了。
东莞银行莞银通目前只有java的示例代码,但很多程序是有php编写的,本次代码实现也是项目实际开发中的实现代码。方便大家少走弯路。

主要有3个类负责实现,一个负责封装请求接口,一个签名工具类,一个业务方法类。
部分代码如下:
public function prePay($bizContent) {
if (!isset($bizContent['mercId'])) {
$bizContent['mercId'] = $this->mercId;
}
if (!isset($bizContent['appId'])) {
$bizContent['appId'] = $this->miniapp_id;
}
$params = $this->commonParams();
$token = $this->getToken();
$params['token'] = $token;
$needCipher = ['bizContent' => $bizContent];
$needCipher = json_encode($needCipher, JSON_UNESCAPED_UNICODE + JSON_UNESCAPED_SLASHES);
$ciphertext = $this->getCipherText($needCipher);
$params['ciphertext'] = $ciphertext;
ksort($params);
$paramsStr = json_encode($params, JSON_UNESCAPED_SLASHES + JSON_UNESCAPED_UNICODE);
$params['signature'] = $this->getSign($paramsStr);
$resStr = $this->httpPost($this->baseApi . '/xxxxxx', json_encode($params, JSON_UNESCAPED_SLASHES + JSON_UNESCAPED_UNICODE));
$resJson = json_decode($resStr, true);
if ($resJson['errorCode'] == '0000') {
return json_decode($this->verifyAndDecrypt($resJson), true);
} else {
throw new Exception($resJson['errorDesc']);
}
}
需要完整代码,或提供接入帮助小伙伴的可以联系我。

本文介绍了一种针对东莞银行微信支付的PHP实现方案,通过三个核心类:请求接口封装类、签名工具类及业务方法类,实现了与银行系统的顺利对接。
1263

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



