支付宝无密退款接口

匿名 (未验证) 提交于 2019-12-03 00:34:01

首先官方下载demo:

接口说明文档:查看文档

开放平台上传商户公钥,公私钥生成工具:支付宝密钥生成器

一定要采用RSA2签名!!!

$aop = new AopClient (); 
$aop->gatewayUrl = ‘https://openapi.alipay.com/gateway.do‘;
$aop->appId = ‘your app_id‘; $aop->rsaPrivateKey = ‘请填写开发者私钥去头去尾去回车,一行字符串‘;
$aop->alipayrsaPublicKey=‘请填写支付宝公钥,一行字符串‘;
$aop->apiVersion = ‘1.0‘;
$aop->signType = ‘RSA2‘;
$aop->postCharset=‘utf-8‘;
$aop->format=‘json‘;
$request = new AlipayTradeRefundRequest ();
$request->setBizContent("{" .
"\"out_trade_no\":\"{$order_info[‘order_sn‘]}\"," .

"\"refund_amount\":{$order_info[‘order_price‘]}," .
"\"refund_reason\":\"正常退款\"," .
"\"out_request_no\":\"{$out_refund_no}\"" .
"}");

$result = $aop->execute ( $request);
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response"; 
$resultCode = $result->$responseNode->code;

if(!empty($resultCode)&&$resultCode == 10000){
  //处理逻辑 todo
  echo "成功";
}

else {
  echo "失败";
}


原文:https://www.cnblogs.com/yuanlai/p/9223962.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!