Selaa lähdekoodia

update

master
DengBiao 10 kuukautta sitten
vanhempi
commit
81365fa121
3 muutettua tiedostoa jossa 48 lisäystä ja 0 poistoa
  1. +1
    -0
      src/applet/app/config/loader.php
  2. +21
    -0
      src/applet/app/controllers/Alipay/PayController.php
  3. +26
    -0
      src/common/Service/Pay/AlipayService.php

+ 1
- 0
src/applet/app/config/loader.php Näytä tiedosto

@@ -14,6 +14,7 @@ $loader->registerFiles([
// DIR_VENDOR . 'alipay-sdk-php-all-master/aop/AopEncrypt.php',
DIR_VENDOR . 'alipay-sdk-php-all-master/aop/request/AlipayCommerceEducateFacefeatureGroupkeyQueryRequest.php',
DIR_VENDOR . 'alipay-sdk-php-all-master/aop/request/AlipayTradeRefundRequest.php',
DIR_VENDOR . 'alipay-sdk-php-all-master/aop/request/AlipayTradeFastpayRefundQueryRequest.php',
DIR_VENDOR . 'alipay-sdk-php-all-master/aop/request/AlipayTradeCreateRequest.php',
DIR_VENDOR . 'alipay-sdk-php-all-master/aop/request/AlipayTradeQueryRequest.php',
DIR_VENDOR . 'alipay-sdk-php-all-master/aop/request/AlipayFundTransPagePayRequest.php',


+ 21
- 0
src/applet/app/controllers/Alipay/PayController.php Näytä tiedosto

@@ -155,4 +155,25 @@ class PayController extends ControllerBase
}
$this->api(Msg::NewError(500, '提交方式错误!'));
}

public function tradeRefundQueryAction()
{
if ($this->request->isPost()) {
$args = $this->request->getJsonRawBody(true);
$config["pay_ali_app_id"] = $args["config"]["pay_ali_app_id"] ?? "2021004101651996";
$config["pay_ali_private_key"] = $args["config"]["pay_ali_private_key"] ?? "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCSGJ9ob4kmGy6y4YeynjKJc/LSg02EXjLErPZSfVrAOy69FTRfBDbazlxpfl6YCAxDdT5ZcspB5kS2XYOY4dmqqPmF4VywmcjmZM8IxZFl1p7YC8BOlP6JrzDPwVl3hn4z3Em1byj8ANLY/AxAaW9W43FSIX+cSfdJThTlxGcbHZ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TYvUO+yMkAHLmx1h4QkLCkWegB4g5QkKkAGPWp3hshAj/KA0cXthFXVUG/SGZ2K6eB+nbon1N+9cDETdM4QXzN5gE/mUlupIxqRU1ouI27YYPbJSQNTrC7OkwNzfnpe/gshEj/gr5eHHvd4UrvMQKBgD2Toow7sfpV0R9rhO8aJ9njlbH15LqUK/AotK3E7zr73Uv5j/BIKS4dVC7T56L2khEUbM/y8+Rig6CdyFf3A4i4GKfbp56Sap/Haa9OP6jfep6VW7Aa1AJxPvIPgPZ2U+EuRxrwrP1EBcL5z6Cern9c9Zzs8BPUacU+Q5e8c87W";
$config["pay_ali_public_key"] = $args["config"]["pay_ali_public_key"] ?? "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzEC7+3O/Ej/gkXug6EgcCM3LjWzz11RR6ESo0KshGg3ODgM8DfdKDHD5b1T6VbcRGFobXQBqVtW008ocUnSOZzE67a73l6mKT3FbmhRsbrgwcUuOHEJUZaLFxPibJgFl7fkOjBcIiz+Wc+9VDTt8O4YxIZhAL6L6ppXcrVrCkOaiIiuHGyp7FjQ+5s3Lk3NLSO3TfXw1WEX2F+IHnw32ZN/FlC8rF8HVlgM0w/PZJ9RuadoLqn5H6z/iqrurbtxscnx0Qbdt8CBzREabJnWxHjxO936AXu9njIPvsXkTfaJJIXxRGGb0b8peSiCljwi8UEODe8mjl2c/LzLel6RuLQIDAQAB";

$out_trade_no = $args["out_trade_no"] ?? "";
$out_request_no = $args["out_request_no"] ?? "";
$app_auth_token = $args["app_auth_token"] ?? "";

$result = (new AlipayService($config))->alipayTradeFastpayRefundQuery($out_trade_no, $out_request_no, $app_auth_token);
if (!$result["status"]) {
$this->api(["statusCode" => 500, "code" => $result["data"]["code"] * 1, "msg" => $result["msg"] ?? $result["sub_msg"]]);
}
$this->api($result["data"]);
}
$this->api(Msg::NewError(500, '提交方式错误!'));
}
}

+ 26
- 0
src/common/Service/Pay/AlipayService.php Näytä tiedosto

@@ -198,4 +198,30 @@ class AlipayService extends BaseService
}
}

/**
* alipay.trade.fastpay.refund.query(统一收单交易退款查询)
* @param $out_trade_no string 商户订单号
* @param $out_request_no string 退款请求号。
* @param string $app_auth_token 应用授权(详见应用授权概述https://opendocs.alipay.com/isv/10467/xldcyq)
* @return array
*/
public function alipayTradeFastpayRefundQuery($out_trade_no, $out_request_no, $app_auth_token)
{
$params["out_trade_no"] = $out_trade_no;
$params["out_request_no"] = $out_request_no;

$request = new \AlipayTradeRefundRequest();
$paramsJson = json_encode($params);
$request->setBizContent($paramsJson);
$response = self::$aopClient->execute($request, null, $app_auth_token);
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
$responseData = json_decode(json_encode($response->$responseNode), true);
$this->logger(["params" => $params, "response" => $responseData], 'alipay.trade.fastpay.refund.query', true);
if ($responseData['code'] == 10000) {
return $this->returnRes(true, $responseData['msg'], $responseData);
} else {
return $this->returnRes(false, ($responseData['sub_msg'] ?? $responseData['msg']), $responseData);
}
}

}

Ladataan…
Peruuta
Tallenna