日日操夜夜添-日日操影院-日日草夜夜操-日日干干-精品一区二区三区波多野结衣-精品一区二区三区高清免费不卡

公告:魔扣目錄網(wǎng)為廣大站長提供免費收錄網(wǎng)站服務(wù),提交前請做好本站友鏈:【 網(wǎng)站目錄:http://www.ylptlb.cn 】, 免友鏈快審服務(wù)(50元/站),

點擊這里在線咨詢客服
新站提交
  • 網(wǎng)站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會員:747

官方接口文檔:
退款接口: https://opendocs.alipay.com/apis/api_1/alipay.trade.refund
支付訂單查詢接口:https://opendocs.alipay.com/apis/api_1/alipay.trade.query
支付寶退款的秘密

 

示例代碼如下:
<?php

/**
 * 掃碼支付
 * 提醒:提交支付請求后微信會同步返回支付結(jié)果(沒有異步回調(diào)通知)。當(dāng)返回結(jié)果為“系統(tǒng)錯誤”時,商戶系統(tǒng)等待5秒后調(diào)用【查詢訂單API】,查詢支付實際交易結(jié)果;當(dāng)返回結(jié)果為“USERPAYING”時,商戶系統(tǒng)可設(shè)置間隔時間(建議10秒)重新查詢支付結(jié)果,直到支付成功或超時(建議30秒);
 */
namespace Appapicontroller;
use thinkController;
use thinkDb;
use thinkInput;
use thinkfacadeRequest;
use appapicontrollerCommon;

header("Access-Control-Allow-Origin:*");
header("Content-type: text/html; charset=utf-8");
require_once $_SERVER['DOCUMENT_ROOT'].'/vendor/Alipaydangmianfu_demo/f2fpay/model/builder/AlipayTradePayContentBuilder.php';
require_once $_SERVER['DOCUMENT_ROOT'].'/vendor/Alipaydangmianfu_demo/f2fpay/service/AlipayTradeService.php';
require_once $_SERVER['DOCUMENT_ROOT'].'/vendor/Alipaydangmianfu_demo/aop/AopClient.php';
require_once $_SERVER['DOCUMENT_ROOT'].'/vendor/Alipaydangmianfu_demo/aop/request/AlipayTradeRefundRequest.php';
/**
 * 支付寶當(dāng)面付
 * @package appapicontroller
 */
class Alipay
{
    /**
     * Notes:
     * User: 小海
     * Time:下午 1:51
     * DATE:2020/12/10 0010
     */
    public function alipay($authCode, $totalAmount, $outTradeNo)
    {
        $common = new Common();
        $config = array(
            //簽名方式
            'sign_type' => "RSA2",
            //支付寶公鑰
//            'alipay_public_key' => "/fEsraprwCtzvzQETrNRwVxLO5jVmRGi60j8Ue1efIlzPXV9je9mkjzOmdssymZkh2QhUrCmZYI/FCEa3/cNMW0QIDAQAB",
            'alipay_public_key' => '+rHrXw7L+/HlesZSXoMsYRed7Ray6oFu/YjRTJ2e3zxkhcHjcy5pZIauuT5dz1vM6XA3q38VILGQZbK3RusYlcpNopbR5f6j8HOoIgSk3+qdmRgga2hgwhgd1JOj7R/aTmPGzTJ81E6FXCGN83PLnHYr0URgtnpjLVOg+xV5fiAeWGe9SOUasW3sfqFk54WRwBOcOm70Owl9+juDhGICJObdIxrbck0ij7xkSlU89/ZcUQQ4UNLSya6jghdF8oQzeeszHR0/QCYfWELTCoxUwH46RHy9rN0IOF5OkWUCVc7ga/kRuNl+Um1ryOPc3NUxwIDAQAB',
            //商戶私鑰
            'merchant_private_key' => "+h/C3LaaCSfd38eFTsInsZxYZsOJ6HLee78aqZ9+s3MKl1pd8naA6IdGWtDzfp5NcmIdcvELuGesxGYlORYxMTX9a3Sd8hjuPyWrrCgdXlfpNIzvkb00I9pMonmR7SgAkiLxhxfRZWOdCYfdK+HDuvOXWuDK7xQ9eVB/kZRzQ7S1WUMG9DPJYWe+naHQlXm+LZ3GBvAaqrlTofi3hYRsAcPM3S4tnJlHce2sIwOMpaBqbkRDVhtAgMBAAECggEAVs0zmH77Gt0fPMViBQj9fK46wyFQFdD9t/jCy+YaVMDgWDmhSMEnwkPUeZg+8wcOkJ0cghqCFph2w7G2irAdN+2lBFDEpv4xp2HoQW0b0r7HaY5F8t+51FmRYWA2i1zEEcWoODO30zEjsFWZe3cjS5fAimXoTZeRKdO4+3CAyCtqE3/9z3OUM0LAElSzwUsc+4CXTTE1kKLUB0W1mX55jQLLRQ2amwA8j4ZJR2UBQ8I+WRmfydLd70ezMKr+esHCZFWxEsZMDPdcOWRJsUAUZErwstlNBGKvHFMLe96wrCyuiRYx1Aath24+4oEr8Zuw5b5ISxMQC49akWrhUWBggQKBgQDo2SyHU+JcYh2hYD30++gwUM7uU9EerXt3+84p6nFkHXMAWQwsciwHJfZULcBw392xQCTAkGtUTStSDYq92Xfo57w7gRiiI4QN4glIIfP9WrefBlrd+RZVC98/zX7ZeAJgbIvaUSlpywuPY+Zc02BnHFMSDvpGTYTFGyPCwa6rOwKBgQCW7M1myaGB/aCxemacvBQNdPrwuKHaSjOzPh6iKb6iU1XlmZV3GWc+rTqm/RGs08uC4HKg16s2DGMXVE5VqIPObmn2mZyBd5rJrvcwWi6DKxfHYDjNJ0eO/xCFAFGeu0cc3rxiMEtMT/WtI0tsMM3TIiZZFNynOBVdwDzmt1dAdwKBgDlj9caxFTTB9h2lVAAC6rql4Cr7u6o9BhaPmMPaBfKwE309dXOq/FESuUEMOcdYVhLvBV/0+I9BqfDCZ7TdWeGs5EciTYkBCfZGBRWjULjcWC+46EKXtzpk/7SBGMfO/X74ogvAP13U7td7vvaYHsWrRIpJ6MPVLWlLhCfnhv6rAoGAPMhd6NmnnAyjXRZBDIHmqYzFS5FwTdO4gqWv/KtHRWS+oVt7YJ3wgMOPbZVaOvqJacovICv7niba+ZhQfBsECm1Za6Ft8I5U3okCsIyBUv5V80wDVExPe32qD4aTWJQgDbZ+tCSzDqbdUL94LrhxDGkifJn0S7xAjqNPY7PPBf0CgYAMG7Buyxb1ZLQq7X/0ippM1kQIBOYcmxyK5r7CHcgRmBFmNf9BzWEClunDOCrY5USD6LK+Z+XnXX2q4XkKCxug8iVWBPh4lsqd+Tsn0orDE7JRcoDwl8QwkjdlsalPq8tOv/A91YM2GRI3oWHiC9TyBLds3BgwmO0vaivhtJNVyA==",

            //編碼格式
            'charset' => "UTF-8",

            //支付寶網(wǎng)關(guān)
            'gatewayUrl' => "https://openapi.alipay.com/gateway.do",

            //應(yīng)用ID
            'app_id' => "123423",

            //異步通知地址,只有掃碼支付預(yù)下單可用
            'notify_url' => "",

            //最大查詢重試次數(shù)
            'MaxQueryRetry' => "10",

            //查詢間隔
            'QueryDuration' => "3"
        );
        // (必填) 商戶網(wǎng)站訂單系統(tǒng)中唯一訂單號,64個字符以內(nèi),只能包含字母、數(shù)字、下劃線,
        // 需保證商戶系統(tǒng)端不能重復(fù),建議通過數(shù)據(jù)庫sequence生成,
//        $outTradeNo = "Dsx" . date('Ymdhis') . mt_rand(100, 1000);
        $subject = "第三巷條形碼支付";
//        $totalAmount = $_POST['payAmount'];    // (必填) 訂單總金額,單位為元,不能超過1億元

        // (必填) 付款條碼,用戶支付寶錢包手機app點擊“付款”產(chǎn)生的付款條碼
//        $authCode = $_POST['auth_code']; //28開頭18位數(shù)字


        // 支付超時,線下掃碼交易定義為5分鐘
        $timeExpress = "5m";
        // 創(chuàng)建請求builder,設(shè)置請求參數(shù)
        $barPayRequestBuilder = new AlipayTradePayContentBuilder();


        $barPayRequestBuilder->setOutTradeNo($outTradeNo);
        $barPayRequestBuilder->setTotalAmount($totalAmount);
        $barPayRequestBuilder->setAuthCode($authCode);
        $barPayRequestBuilder->setTimeExpress($timeExpress);
        $barPayRequestBuilder->setSubject($subject);
        // 調(diào)用barPay方法獲取當(dāng)面付應(yīng)答
        $barPay = new AlipayTradeService($config);
        $barPayResult = $barPay->barPay($barPayRequestBuilder);
        switch ($barPayResult->getTradeStatus()) {
            case "SUCCESS":
//                echo "支付寶支付成功:" . "<br>--------------------------<br>";
                $data = $barPayResult->getResponse();
                $result = $common->returnway(2000, "支付寶支付成功!", $data);
                return json_encode($result);
                break;
            case "FAILED":
//                echo "支付寶支付失敗!!!" . "<br>--------------------------<br>";
                if (!empty($barPayResult->getResponse())) {
                    $data = $barPayResult->getResponse();
                    $result = $common->returnway(2002, "支付寶支付失敗!", $data);
                    return json_encode($result);
                }
                break;
            case "UNKNOWN":
//                echo "系統(tǒng)異常,訂單狀態(tài)未知!!!" . "<br>--------------------------<br>";
                if (!empty($barPayResult->getResponse())) {
                    $result = $common->returnway(4000, "系統(tǒng)異常,訂單狀態(tài)未知!", $barPayResult->getResponse());
                    return json_encode($result);
                }
                break;
            default:
                echo "不支持的交易狀態(tài),交易返回異常!!!";
                break;
        }
        return;
    }

    /**
     * 支付寶退貨處理
     * 退貨前提是必須支付成功
     * @$out_trade_no		平臺訂單號
     * @$wepay_serial		支付寶交易號
     * @$totalFee  //退款金額
     */
    public function alipayRefund($out_trade_no, $wepay_serial, $totalFee)
    {
        $aop = new AopClient ();
        $aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
        $aop->appId = '12342312';
        $aop->alipayrsaPublicKey = '+rHrXw7L+/HlesZSXoMsYRed7Ray6oFu/YjRTJ2e3zxkhcHjcy5pZIauuT5dz1vM6XA3q38VILGQZbK3RusYlcpNopbR5f6j8HOoIgSk3+qdmRgga2hgwhgd1JOj7R/aTmPGzTJ81E6FXCGN83PLnHYr0URgtnpjLVOg+xV5fiAeWGe9SOUasW3sfqFk54WRwBOcOm70Owl9+juDhGICJObdIxrbck0ij7xkSlU89/ZcUQQ4UNLSya6jghdF8oQzeeszHR0/QCYfWELTCoxUwH46RHy9rN0IOF5OkWUCVc7ga/kRuNl+Um1ryOPc3NUxwIDAQAB';
        $aop->rsaPrivateKey = '+h/C3LaaCSfd38eFTsInsZxYZsOJ6HLee78aqZ9+s3MKl1pd8naA6IdGWtDzfp5NcmIdcvELuGesxGYlORYxMTX9a3Sd8hjuPyWrrCgdXlfpNIzvkb00I9pMonmR7SgAkiLxhxfRZWOdCYfdK+HDuvOXWuDK7xQ9eVB/kZRzQ7S1WUMG9DPJYWe+naHQlXm+LZ3GBvAaqrlTofi3hYRsAcPM3S4tnJlHce2sIwOMpaBqbkRDVhtAgMBAAECggEAVs0zmH77Gt0fPMViBQj9fK46wyFQFdD9t/jCy+YaVMDgWDmhSMEnwkPUeZg+8wcOkJ0cghqCFph2w7G2irAdN+2lBFDEpv4xp2HoQW0b0r7HaY5F8t+51FmRYWA2i1zEEcWoODO30zE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NVyA==';
        $aop->apiVersion = '1.0';
        $aop->signType = 'RSA2';
        $aop->postCharset = 'UTF-8';
        $aop->format = 'json';
        $request = new AlipayTradeRefundRequest ();
        $bizcontent = json_encode([
            'out_trade_no' => $out_trade_no,
            'trade_no' => $wepay_serial,
            'refund_amount' => $totalFee,
            'refund_reason' => '正常退款'
        ]);

        $request->setBizContent($bizcontent);
        $result = $aop->execute($request);
        $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
        $resultCode = $result->$responseNode->code;
        if (!empty($resultCode) && $resultCode == 10000) {
            return 1000;
        } else {
            return -1;
        }


    }
}

在你的管理后臺調(diào)取支付類中的alipayRefund()即可!每天帶你們了解咱們周圍常見產(chǎn)品的實現(xiàn)原理,不明白的地方可以私聊我!

分享到:
標(biāo)簽:退款 支付寶
用戶無頭像

網(wǎng)友整理

注冊時間:

網(wǎng)站:5 個   小程序:0 個  文章:12 篇

  • 51998

    網(wǎng)站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會員

趕快注冊賬號,推廣您的網(wǎng)站吧!
最新入駐小程序

數(shù)獨大挑戰(zhàn)2018-06-03

數(shù)獨一種數(shù)學(xué)游戲,玩家需要根據(jù)9

答題星2018-06-03

您可以通過答題星輕松地創(chuàng)建試卷

全階人生考試2018-06-03

各種考試題,題庫,初中,高中,大學(xué)四六

運動步數(shù)有氧達人2018-06-03

記錄運動步數(shù),積累氧氣值。還可偷

每日養(yǎng)生app2018-06-03

每日養(yǎng)生,天天健康

體育訓(xùn)練成績評定2018-06-03

通用課目體育訓(xùn)練成績評定