提现处理

This commit is contained in:
wanyongkang
2020-10-21 20:24:13 +08:00
parent 18f7cc38ea
commit ff3ad053bb
8 changed files with 255 additions and 38 deletions

View File

@@ -2,7 +2,7 @@
/*
* @Author: 万永康
* @Date: 2020-10-11 12:32:50
* @LastEditTime: 2020-10-14 19:31:04
* @LastEditTime: 2020-10-21 17:25:25
* @LastEditors: kangkang
* @Description: In User Settings Edit
* @FilePath: /phptest/alipay/Alipay.php
@@ -10,7 +10,7 @@
namespace alipay;
require_once APP_PATH . 'alipay/aop/AopClient.php';
require_once APP_PATH . 'alipay/aop/AopCertClient.php';
require_once APP_PATH . 'alipay/aop/AopCertification.php';
require_once APP_PATH . 'alipay/aop/request/AlipayTradeQueryRequest.php';
require_once APP_PATH . 'alipay/aop/request/AlipayTradePagePayRequest.php';
@@ -26,14 +26,6 @@ require_once APP_PATH . 'alipay/aop/request/AlipayFundTransUniTransferRequest.ph
class Alipay
{
//配置内容
protected static $config = [];
public function __construct()
{
self::$config = require_once APP_PATH . 'config/config.php';
}
/**
*
* web 付款
@@ -50,12 +42,12 @@ class Alipay
*/
public static function pay($param)
{
global $config;
$aop = new \AopClient();
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
$aop->appId = self::$config['alipay']['app_id'];
$aop->rsaPrivateKey = self::$config['alipay']['private_key'];
$aop->alipayrsaPublicKey = self::$config['alipay']['public_key'];
$aop->appId = $config['alipay']['app_id'];
$aop->rsaPrivateKey = $config['alipay']['private_key'];
$aop->alipayrsaPublicKey = $config['alipay']['public_key'];
$aop->apiVersion = '1.0';
$aop->signType = 'RSA2';
$aop->postCharset = 'utf-8';
@@ -77,39 +69,47 @@ class Alipay
* 'out_biz_no'=>'201806300001',
* 'trans_amount' => '0.01',
* 'product_code' => 'TRANS_ACCOUNT_NO_PWD',
* 'payee_info' => {
* 'payee_info' => [
* 'identity' => '208812*****41234',
* 'identity_type' => 'ALIPAY_LOGON_ID',
* 'name' => 'peter'
* },
* ],
* 'remark' => '提现-单笔转帐'
* ]
* @return {type}
* @return {type}
*/
public static function transfer()
public static function transfer($param)
{
$aop = new \AopClient();
global $config;
$aop = new \AopCertClient();
$appCertPath = $config['alipay']['app_crt'];
$alipayCertPath = $config['alipay']['public_crt'];
$rootCertPath = $config['alipay']['root_crt'];
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
$aop->appId = self::$config['alipay']['app_id'];
$aop->rsaPrivateKey = self::$config['alipay']['private_key'];
$aop->alipayrsaPublicKey = self::$config['alipay']['public_key'];
$aop->appId = $config['alipay']['app_id'];
$aop->rsaPrivateKey = $config['alipay']['private_key'];
$aop->alipayrsaPublicKey = $aop->getPublicKey($alipayCertPath);//调用getPublicKey从支付宝公钥证书中提取公钥
$aop->apiVersion = '1.0';
$aop->signType = 'RSA2';
$aop->postCharset = 'utf-8';
$aop->format = 'json';
$aop->postCharset='utf-8';
$aop->format='json';
$aop->isCheckAlipayPublicCert = true;//是否校验自动下载的支付宝公钥证书,如果开启校验要保证支付宝根证书在有效期内
$aop->appCertSN = $aop->getCertSN($appCertPath);//调用getCertSN获取证书序列号
$aop->alipayRootCertSN = $aop->getRootCertSN($rootCertPath);//调用getRootCertSN获取支付宝根证书序列号
$request = new \AlipayFundTransUniTransferRequest();
$param = json_encode($param);
$request->setBizContent($param);
$result = $aop->execute ( $request);
$result = $aop->execute($request);
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
$resultCode = $result->$responseNode->code;
if(!empty($resultCode)&&$resultCode == 10000){
return true;
if (!empty($resultCode) && $resultCode == 10000) {
return $result;
} else {
return false;
}

View File

@@ -106,7 +106,7 @@ class AopCertClient
for ($i = 0; $i < count($array) - 1; $i++) {
$ssl[$i] = openssl_x509_parse($array[$i] . "-----END CERTIFICATE-----");
if(strpos($ssl[$i]['serialNumber'],'0x') === 0){
$ssl[$i]['serialNumber'] = $this->hex2dec($ssl[$i]['serialNumber']);
$ssl[$i]['serialNumber'] = $this->hex2dec($ssl[$i]['serialNumberHex']);
}
if ($ssl[$i]['signatureTypeLN'] == "sha1WithRSAEncryption" || $ssl[$i]['signatureTypeLN'] == "sha256WithRSAEncryption") {
if ($SN == null) {
@@ -132,7 +132,8 @@ class AopCertClient
for ($i = 1; $i <= $len; $i++) {
$dec = bcadd($dec, bcmul(strval(hexdec($hex[$i - 1])), bcpow('16', strval($len - $i))));
}
return round($dec,0);
// return round($dec,0);
return $dec;
}
/**