尊龙凯时人生就是搏

ÔõÑùÔÚThinkPHP6ÖÐʹÓÃÖ§¸¶±¦¿ª·Åƽ̨£¿

Ëæ×ŵç×ÓÉÌÎñµÄÆÕ¼°ºÍÉú³¤£¬Çå¾²±ã½ÝµÄÔÚÏßÖ§¸¶·½·¨ÒѾ­³ÉΪÏûºÄÕß²»¿É»òȱµÄЧÀÍ¡£Ö§¸¶±¦×÷Ϊº£ÄÚ×î´óµÄÔÚÏßÖ§¸¶Æ½Ì¨Ö®Ò»£¬ÎªÊýÒÔÒڼƵÄÓû§Ìṩ×ÅÐÅÍÐÓë±ãµ±£¬¹ØÓÚÆóÒµ¶øÑÔ£¬Ò²ÊǾÙÐÐÖ§¸¶ÓªÒµ±Ø²»¿ÉÉÙµÄÑ¡Ôñ¡£±¾ÎĽ«ÏÈÈÝÔõÑùÔÚthinkphp6¿ò¼ÜÏÂʹÓÃÖ§¸¶±¦¿ª·Åƽ̨£¬ÒÔÀû±ãÆóÒµ¾ÙÐÐÖ§¸¶ÓªÒµ¡£

Ò»¡¢ ×¼±¸ÊÂÇé

ÔÚʹÓÃÖ§¸¶±¦¿ª·Åƽ̨¾ÙÐпª·¢Ö®Ç°£¬ÐèÒª¾ÙÐжÔÓ¦µÄ¿ª·¢Õß×¢²áºÍÓ¦Óý¨Éè¡£Ïêϸ°ì·¨ÈçÏ£º

1¡¢ ×¢²á³ÉΪ¿ª·¢Õß

Ê×ÏÈ£¬¿ª·¢ÕßÐèÒª½øÈëÖ§¸¶±¦¿ª·Åƽ̨£¨https://open.alipay.com/platform/home.htm£©²¢Íê³É×¢²á£¬»ñÈ¡¿ª·¢ÕßIDºÍKEY¡£

Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»

2¡¢ ½¨ÉèÓ¦ÓÃ

Ó¦ÓõĽ¨ÉèÐèÒªÔÚ¿ª·Åƽ̨ºǫ́¾ÙÐУ¬Ñ¡Ôñ½¨ÉèÓ¦Óã¬ÌîдӦÓõĻù±¾ÐÅÏ¢¡£

Íê³É½¨Éèºó£¬»áÌìÉúAPP ID¡¢ÃÜÔ¿µÈÏà¹ØÐÅÏ¢¡£

¶þ¡¢ ÉèÖÃÖ§¸¶±¦¿ª·Åƽ̨SDK

Pay APIÊÇ°¢À↑·Åƽ̨µÄÒ»Ïî³£Óÿª·Å½Ó¿Ú£¬Ê¹ÓÃPay API¾ÙÐÐÖ§¸¶¿ÉÒÔ¼«´óµØ½µµÍ¿ª¾ÙʶÈ¡£Pay APIÌṩ¿ªÏä¼´ÓõÄÖ§¸¶¹¦Ð§£¬Ê¹Óû§Äܹ»¿ìËÙÇáËɵؿª·¢³öÍêÕûµÄÖ§¸¶Á÷³Ì¡£

1¡¢ ÒýÈëSDK

ÔÚThinkPHP6ÖоÙÐÐÖ§¸¶±¦¿ª·Åƽ̨µÄ¿ª·¢£¬ÐèÒªÏÈÒýÈëSDK£¬ÔÚcomposer.jsonÖÐÐÂÔö£º

"require": {
"alipay/easysdk":"^2.1"
}

µÇ¼ºó¸´ÖÆ

Ö®ºóÖ´ÐÐcomposer install×°ÖÃSDK£¬Íê³ÉÖ®ºó£¬¾Í¿ÉÒÔ¾ÙÐÐÖ§¸¶±¦Ïà¹Ø¿ª·¢ÁË¡£

2¡¢ ÉèÖÃÎļþ

ÔÚThinkPHP6ÖоÙÐÐÉèÖã¬ÐèҪн¨ÉèÖÃÎļþconfig/easysdk.php£¬È»ºó½«ÒÔÏÂÄÚÈݸ´ÖƽøÈ¥£º

<?php
return [
    'app_id' => '', //Ó¦ÓÃID
    'notify_url' => '', //Ö§¸¶»Øµ÷֪ͨµØµã
    'return_url' => '', //Ö§¸¶¿¢ÊºóÌøתµØµã
    'ali_public_key' => '', //Ö§¸¶±¦¹«Ô¿
    'private_key' => '', //Ó¦ÓÃ˽Կ
    'log' => [ //ÈÕÖ¾ÉèÖÃ
        'file' => './logs/easysdk.log',
        'level' => 'debug',
        'type' => 'daily', //°´ÈÕÖ¾Îļþ
    ],
    'http' => [ //APIÇëÇóÉèÖÃ
        'timeout' => 5.0,
        'connect_timeout' => 5.0,
    ],
];

µÇ¼ºó¸´ÖÆ

Èý¡¢ Ìᳫ֧¸¶ÇëÇó

ÓÐÁË×¼±¸ÊÂÇéºÍÉèÖÃÎļþºó£¬¾Í¿ÉÒÔÔÚThinkPHP6ÖÐÌᳫ֧¸¶ÇëÇóÁË¡£Ïêϸ°ì·¨ÈçÏ£º

1¡¢ ±àд¿ØÖÆÆ÷

Ê×ÏÈ£¬ÐèÒªÔÚapp/controllerĿ¼ÏÂн¨¿ØÖÆÆ÷ÎļþAlipyController.php¡£ÔÚ¸ÃÎļþÖÐдÈëÒÔÏÂÄÚÈÝ£º

<?php
namespace appcontroller;

use thinkApp;
use thinkhelperArr;
use thinkacadeConfig;
use alipayEasySDKKernelFactory;

class AlipayController
{
    public function pay()
    {
        //Ö§¸¶½ð¶î
        $totalAmount = 10.00;
        $pay = Factory::payment(Config::get('easysdk'));

        //½á¹¹Ö§¸¶ÇëÇó²ÎÊý
        $builder = $pay->common()->precreate(
            [
                'out_trade_no' => '20191120' . uniqid(),
                'total_amount' => $totalAmount,
                'subject' => '˼ÒôÍŽá»á -- Ö§¸¶²âÊÔ',
            ]
        );

        //Ìᳫ֧¸¶ÇëÇ󣬻ñÈ¡ÏìÓ¦
        $response = $builder->getResponse();
        $qrCode = Arr::get($response->bizContent, 'qr_code');

        //չʾ֧¸¶¶þάÂë
        echo "@@##@@";
    }
}

µÇ¼ºó¸´ÖÆ

2¡¢ ·¢³öÇëÇó

ÔÚä¯ÀÀÆ÷ÖÐÊäÈëÉÏÊö¿ØÖÆÆ÷µÄ·ÓÉ£¬¼´¿É¾ÙÐÐÖ§¸¶ÇëÇó¡£Ò³Ã潫չʾ֧¸¶¶þάÂë¡£

ÒÔÉϾÍÊÇÔÚThinkPHP6ÖÐʹÓÃÖ§¸¶±¦¿ª·Åƽ̨¾ÙÐÐÖ§¸¶¿ª·¢µÄ°ì·¨¡£Ê¹ÓÃPay API¾ÙÐÐÖ§¸¶£¬¿ÉÒÔÉÁ¿ª·¢ÕßÔ½·¢×¨×¢ÓÚÓªÒµÁ÷³ÌµÄ¿ª·¢£¬ïÔÌ­¿ª·¢Ê±¼äºÍ±¾Ç®¡£Í¬Ê±£¬Ö§¸¶±¦ÌṩµÄÖ§¸¶·½·¨Ò²ºÜÊÇÇå¾²¡¢Àû±ã£¬ÎªÆóÒµÌṩÁ˱㵱¡£

ÒÔÉϾÍÊÇÔõÑùÔÚThinkPHP6ÖÐʹÓÃÖ§¸¶±¦¿ª·Åƽ̨£¿µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是搏ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是搏ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是搏

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ