当前位置:网站首页>Alipay certificate mode payment interface
Alipay certificate mode payment interface
2022-06-30 14:10:00 【Zhiqiu·】
// Alipay mobile phone website payment
function ali_payweb() {
$params = $this->request->param();
require_once Env::get('ROOT_PATH')."vendor/ali/aop/AopCertClient.php";
require_once Env::get('ROOT_PATH')."vendor/ali/aop/request/AlipayTradeWapPayRequest.php";
$aop = new \AopCertClient();
$appCertPath = getcwd() ."appCertPublicKey_.crt";//" Application certificate path ( Make sure the certificate file is readable ), for example :/home/admin/cert/appCertPublicKey.crt";
$alipayCertPath = getcwd() ."alipayCertPublicKey_RSA2_.crt";//" Alipay public key certificate path ( Make sure the certificate file is readable ), for example :/home/admin/cert/alipayCertPublicKey_RSA2.crt";
$rootCertPath = getcwd() ."alipayRootCert_.crt";//" Alipay certificate path ( Make sure the certificate file is readable ), for example :/home/admin/cert/alipayRootCert.crt";
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
$aop->appId = '';
$aop->method = 'alipay.trade.wap.pay';
$aop->rsaPrivateKey = '';
$aop->alipayrsaPublicKey = $aop->getPublicKey($alipayCertPath);// call getPublicKey Extract public key from Alipay public key certificate
$aop->return_url = 'www.baidu.com';
$aop->notify_url = 'www.baidu.com';
$aop->apiVersion = '1.0';
$aop->signType = 'RSA2';
$aop->postCharset='utf-8';
$aop->format='json';
$aop->isCheckAlipayPublicCert = true;// Verify automatic download of Alipay public key certificate , If the check is opened, Alipay certificate must be guaranteed within the validity period.
$aop->appCertSN = $aop->getCertSN($appCertPath);// call getCertSN Get certificate serial number
$aop->alipayRootCertSN = $aop->getRootCertSN($rootCertPath);// call getRootCertSN Get Alipay certificate serial number.
$request = new \AlipayTradeWapPayRequest();
$out_trade_no = '202108170101'.rand(10,99);
$total_amount = 0.01;
$subject = ' Test product ';
$product_code ='QUICK_WAP_WAY';
$time_expire = '2022-08-01 22:00:00';
$request->setNotifyUrl('');
$request->setReturnUrl('');
$request->setBizContent("{" .
" \"out_trade_no\":\"$out_trade_no\"," .
" \"total_amount\":$total_amount," .//
" \"product_code\":\"QUICK_WAP_WAY\"," .
" \"time_expire\":\"$time_expire\"," .
" \"subject\":\"$subject\"" .
"}");
$result = $aop->pageExecute($request);
echo $result;
}
// Alipay pays face to face - Payment code
function alipay_card(){
$params = $this->request->param();
if(empty($params['auth_code'])){
die(' Lack of parameter ');
}
$rsaPrivateKey = $alipayrsaPublicKey = '11';
$auth_code = $params['auth_code'];
$out_trade_no = '202108170101'.rand(10,99);
$total_amount = 0.01;
$subject = ' Test product ';
$product_code ='QUICK_WAP_WAY';
require_once Env::get('ROOT_PATH')."vendor/ali/aop/AopCertClient.php";
require_once Env::get('ROOT_PATH')."vendor/ali/aop/request/AlipayTradePayRequest.php";
$aop = new \AopCertClient();
$appCertPath = getcwd() ."appCertPublicKey_.crt";//" Application certificate path ( Make sure the certificate file is readable ), for example :/home/admin/cert/appCertPublicKey.crt";
$alipayCertPath = getcwd() ."alipayCertPublicKey_RSA2_.crt";//" Alipay public key certificate path ( Make sure the certificate file is readable ), for example :/home/admin/cert/alipayCertPublicKey_RSA2.crt";
$rootCertPath = getcwd() ."alipayRootCert_.crt";//" Alipay certificate path ( Make sure the certificate file is readable ), for example :/home/admin/cert/alipayRootCert.crt";
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
$aop->appId = '';
$aop->method = 'alipay.trade.wap.pay';
$aop->rsaPrivateKey = '';
$aop->alipayrsaPublicKey = $aop->getPublicKey($alipayCertPath);// call getPublicKey Extract public key from Alipay public key certificate
$aop->apiVersion = '1.0';
$aop->signType = 'RSA2';
$aop->postCharset='utf-8';
$aop->format='json';
$aop->isCheckAlipayPublicCert = true;// Verify automatic download of Alipay public key certificate , If the check is opened, Alipay certificate must be guaranteed within the validity period.
$aop->appCertSN = $aop->getCertSN($appCertPath);// call getCertSN Get certificate serial number
$aop->alipayRootCertSN = $aop->getRootCertSN($rootCertPath);// call getRootCertSN Get Alipay certificate serial number.
$request = new \AlipayTradePayRequest();
$request->setBizContent("{" .
" \"out_trade_no\":\"$out_trade_no\"," .
" \"total_amount\":$total_amount," .
" \"scene\":\"bar_code\"," .
" \"auth_code\":\"$auth_code\"," .
" \"subject\":\"$subject\"" .
"}");
$result = $aop->execute($request);
dump($result);
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
$resultCode = $result->$responseNode->code;
dump($resultCode);
if(!empty($resultCode)&&$resultCode == 10000){
echo " success ";
} else {
echo " Failure ";
}
}
// Alipay cash - Transfer to Alipay account
function ali_transfer() {
$params = $this->request->param();
if(empty($params['mobile'])){
return json_encode(array('code'=>201,'msg'=>' The lack of mobile Parameters '));
}
if(empty($params['name'])){
return json_encode(array('code'=>201,'msg'=>' The lack of name Parameters '));
}
$mobile = $params['mobile'];
$name = $params['name'];
$pay = new Pay();
require_once Env::get('ROOT_PATH')."vendor/ali/aop/AopCertClient.php";
require_once Env::get('ROOT_PATH')."vendor/ali/aop/request/AlipayFundTransUniTransferRequest.php";
$aop = new \AopCertClient();
$appCertPath = getcwd() ."appCertPublicKey_.crt";//" Application certificate path ( Make sure the certificate file is readable ), for example :/home/admin/cert/appCertPublicKey.crt";
$alipayCertPath = getcwd() ."alipayCertPublicKey_RSA2_.crt";//" Alipay public key certificate path ( Make sure the certificate file is readable ), for example :/home/admin/cert/alipayCertPublicKey_RSA2.crt";
$rootCertPath = getcwd() ."alipayRootCert_.crt";//" Alipay certificate path ( Make sure the certificate file is readable ), for example :/home/admin/cert/alipayRootCert.crt";
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
$aop->appId = '';
$aop->rsaPrivateKey = '';
$aop->alipayrsaPublicKey = $aop->getPublicKey($alipayCertPath);// call getPublicKey Extract public key from Alipay public key certificate
$aop->apiVersion = '1.0';
$aop->signType = 'RSA2';
$aop->postCharset='utf-8';
$aop->format='json';
$aop->isCheckAlipayPublicCert = true;// Verify automatic download of Alipay public key certificate , If the check is opened, Alipay certificate must be guaranteed within the validity period.
$aop->appCertSN = $aop->getCertSN($appCertPath);// call getCertSN Get certificate serial number
$aop->alipayRootCertSN = $aop->getRootCertSN($rootCertPath);// call getRootCertSN Get Alipay certificate serial number.
$request = new \AlipayFundTransUniTransferRequest();
$out_biz_no = date("YmdHis").rand(100,999);
$trans_amount = 0.1;//TRANS_ACCOUNT_NO_PWD Product value range [0.1,100000000]
$order_title = ' Future noodle restaurant - Withdrawal ';
$request->setBizContent("{" .
" \"out_biz_no\":\"$out_biz_no\"," .
" \"trans_amount\":$trans_amount," .// Total order amount , The unit is yuan , Accurate to two decimal places ,
" \"product_code\":\"TRANS_ACCOUNT_NO_PWD\"," . // A single unclassified transfer to Alipay account is fixed TRANS_ACCOUNT_NO_PWD Product value range [0.1,100000000]
" \"biz_scene\":\"DIRECT_TRANSFER\"," .
" \"order_title\":\"$order_title\"," .
" \"payee_info\":{" .
" \"identity\":\"$mobile\"," .// Alipay login number , Support email and mobile number format
" \"identity_type\":\"ALIPAY_LOGON_ID\"," .
" \"name\":\"$name\"" .// Participant's real name , If it is not empty , Checksum Alipay account name consistency . When identity_type=ALIPAY_LOGON_ID when , This field is required .
" }," .
" \"remark\":\"\"," .
" \"business_params\":\"{\\\"sub_biz_scene\\\":\\\"REDPACKET\\\"}\"" .
"}");
$result = $aop->execute($request);
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
$resultCode = $result->$responseNode->code;
dump($resultCode);
$message = $result->$responseNode->msg;
dump($message);
if (!empty($resultCode) && $resultCode == 10000) {
//return array('code'=>200,'msg'=>' Withdrawal succeeded ');
} else {
$message = $result->$responseNode->sub_msg;// Refund failed with results
dump($message);
//return array('code'=>221,'msg'=>' Withdrawal failed ('.$message.")");
}
}
边栏推荐
- 【科研数据处理】[基础]类别变量频数分析图表、数值变量分布图表与正态性检验(包含对数正态)
- ot initialized – call ‘refresh’ before invoking lifecycle methods via the context: Root WebApplicati
- There is no utf8 option for creating tables in Navicat database.
- In the digital age, XDR (extended detection and response) has unlimited possibilities
- visualstudio 和sql
- numpy 创建空数组 data = np.empty(shape=[1, 64,64,3])
- This editor will open source soon!
- 重磅:国产IDE发布,由阿里研发,完全开源!
- 步骤详解 | 助您轻松提交 Google Play 数据安全表单
- PHP reverses scenarios based on code and skillfully uses debug_ backtrace()
猜你喜欢
Heavyweight: the domestic ide was released, developed by Alibaba, and is completely open source!
Pytoch viewing model parameter quantity and calculation quantity
Jetpack compose for perfect screen fit
Wuenda 2022 machine learning special course evaluation is coming!
用Unity实现Flat Shading
Apache Doris comparison optimization Encyclopedia
单元测试效率优化:为什么要对程序进行测试?测试有什么好处?
半导体动态杂谈
Configuration of headquarters dual computer hot standby and branch infrastructure for firewall Foundation
Intelligent operation and maintenance: visual management system based on BIM Technology
随机推荐
【系统分析师之路】第五章 复盘软件工程(软件过程改进)
Deep understanding Net (2) kernel mode 2 Kernel mode construct semaphone
【Redis 系列】redis 学习十六,redis 字典(map) 及其核心编码结构
There is no utf8 option for creating tables in Navicat database.
Shell programming overview
How to take the first step in digital transformation
MySQL back to table query optimization
Google Earth Engine(GEE)——将字符串的转化为数字并且应用于时间搜索( ee.Date.fromYMD)
Go language func function
Race of golang
Unity animator parameter
Unity Animator 参数
[Title brushing] heater
幸运哈希竞猜系统开发(源码部署)趣投哈希游戏玩法开发(案例需求)
SQL attendance statistics monthly report
More than 20 years after Hong Kong's return, Tupu digital twin Hong Kong Zhuhai Macao Bridge has shocked
I want to ask how to open an account at China Merchants Securities? Is it safe to open a stock account through the link
"As a service", the inevitable choice of enterprise digital transformation
Prometheus 2.29.0 new features
数据库表为什么写不进数据了