支付寶無密退款接口

 

首先官方下載demo:macos

接口說明文檔:查看文檔json

開放平臺上傳商戶公鑰,公私鑰生成工具:支付寶密鑰生成器api

 

必定要採用RSA2簽名!!!app

$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 "失敗"; }
相關文章
相關標籤/搜索