标签:apu public new 结算 gmm sdk bsp http xftp
支付和退款都需要,这里的支付宝公钥(注意:不是应用公钥,支付宝公钥在应用公钥基础上生成的),和应用的私钥;
里面参数有几个用到支付回调里面的参数, 支付流水号,支付者信息,支付登录者信息;
public function AlipayLaunchRefund($data){ vendor(‘Alipay.Sdk.AopClient‘); vendor(‘Alipay.Sdk.SignData‘); vendor(‘Alipay.Sdk.request.AlipayTradeRefundRequest‘); $aop = new AopClient(); $aop->gatewayUrl = ‘https://openapi.alipay.com/gateway.do‘; $configs = D(‘Configs‘)->getKeys([‘alipay_app_id‘, ‘alipay_public_key‘, ‘alipay_private_key‘]); $aop->appId = $configs[‘alipay_app_id‘]; $privateKey = file_get_contents($configs[‘alipay_private_key‘]); $publicKey = file_get_contents($configs[‘alipay_public_key‘]); $aop->rsaPrivateKey = $privateKey; $aop->alipayrsaPublicKey = $publicKey; $aop->apiVersion = ‘1.0‘; $aop->signType = ‘RSA2‘; $aop->postCharset = ‘UTF-8‘; $aop->format = ‘json‘; $request = new AlipayTradeRefundRequest(); $refundInfo = [ ‘trade_no‘ => $data[‘trade_no‘], ‘out_trade_no‘ => $data[‘out_trade_no‘], ‘fund_change‘ => $data[‘fund_change‘], ‘refund_fee‘ => $data[‘price‘] / 100, ‘refund_amount‘ => $data[‘price‘] / 100, ‘refund_currency‘ => ‘CNY‘, ‘gmt_refund_pay‘ => date(‘Y-m-d H:i:s‘,time()), ‘store_name‘ => ‘***‘, ‘buyer_logon_id‘ => $data[‘buyer_logon_id‘], ‘buyer_user_id‘ => $data[‘buyer_user_id‘] ]; $bizcontent = json_encode($refundInfo,true); setlog($refundInfo,[],__METHOD__.‘__2222‘); $request->setBizContent($bizcontent); $result = $aop->execute($request); setlog($result,[],__METHOD__.‘__3333‘); $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response"; $resultCode = $result->$responseNode->code; if(!empty($resultCode) && $resultCode == 10000){ $return_data = [ ‘num‘ => 1, ‘desc‘ => ‘退款成功‘, ‘data‘ => $result->$responseNode->trade_no ]; } else { $return_data = [ ‘num‘ => -1, ‘desc‘ => $result->$responseNode->sub_msg, ]; } return $return_data; } /*** * 支付成功: * [alipay_trade_refund_response] => stdClass Object ( [code] => 10000 [msg] => Success [buyer_logon_id] => men***@163.com [buyer_user_id] => 2088302399936655 [fund_change] => Y [gmt_refund_pay] => 2019-01-28 15:57:58 [out_trade_no] => AXSD19028110031 [refund_fee] => 0.01 [send_back_fee] => 0.00 [trade_no] => 2019012822001436651021876213 ) [sign] => cd/YzFBzIrkW5m460EGbK4p6VjESCTtuD82I/aUj5YxtIGoUp75ZmwhPehHdPrSsLHvtwz4EVytA07EXftpjz7cV0pPL5gQQtM4WeVTEM1EttWK3lMzvKO9uZYJDrYrj8M5qV3zDk926A8fN8BQMKflu7SaBY7eQ/oGMMKbDDYYw9kRAFAhyFEiOBlP868LxNNA4qGJgOBU385uKO1nOqz9Fg9RlMl352ix8fT0XjXccW5VIaLaxZG3o60kFY4Ki7NhklJ4m+abnxXRfztfoBtvH+nsUuSmUBLvtkHIjaC3PZkarCNDJPoIZG06QThjO6KAzAz8j9sSunC3DiGjd8w== ) * 支付失败: ( [alipay_trade_refund_response] => stdClass Object ( [code] => 40004 [msg] => Business Failed [sub_code] => ACQ.CURRENCY_NOT_SUPPORT [sub_msg] => 商户签约结算产品不支持交易币种 [refund_fee] => 0.00 [send_back_fee] => 0.00 ) [sign] => AEgIeov88pApGGIYx+FS3/FEJ8CXAD7JjsELdo1ile9sGOuDYJqlTO0BF0hFRJU4NA+xcIGPOatINeDbMMdi4n+VcjUWOdctJc8vYZSldi3UFI6hXt5gyMQS5smDvy5Dywa8lDijBmXpV3l2nJqJWKmr5jYIb3lMkFH4ZQZFnNu6hdPb0VdnIq71pyjoYsLKWFai7gWYiBPuGuV9iPb/0dlNuL3BjoTjd/FKFp/1HFPZ3Wpn2CQ26iqDo5nXlPDQw6YzLy24SuIR7yau6P8ZHvHqXMK9G27gBqJG0Lexa2eo7iJCl05/oxisD1TuFunk4rR41UtXeUouT6Gqg9fjew== ) */
标签:apu public new 结算 gmm sdk bsp http xftp
原文地址:https://www.cnblogs.com/pansidong/p/10331252.html