PHP中的BillDesk支付集成

6ojccjat  于 2023-10-15  发布在  PHP
关注(0)|答案(2)|浏览(113)

我试图找到方法来整合账单台支付在php,但我无法找到任何代码片段在php,然而,没有任何线索的沙箱环境在billdesk
任何人都可以请给予我正确的步骤,以整合billdesk与php?

yzxexxkh

yzxexxkh1#

首先创建订单API,它将返回一个authToken和bOrderid。请确保您的IP没有在BillDesk侧的黑名单.

function orderCreate()
{
         $headers = ["alg" => "HS256", "clientid" => 'YOUR CLIENT ID'];

        $payload = [
          "mercid" => 'YOUR MERCHANT ID',
          "orderid" => 'RANDOM STRING' // must be unique for every request
          "amount" => "300.00",
          "order_date" => '2023-03-24T10:59:15+05:30',
          "currency" => "356", // for INR
          "ru" => 'Return Url',
          "additional_info" => [
            "additional_info1" => 'q34324',
            "additional_info2" => 'dsaasaasd',
          ],
          "itemcode" => "DIRECT",
          "device" => [
            "init_channel" => "internet",
            "ip" => 'YOUR IP ADDRESS',
            //"mac" => '',  //not mandatory 
            //"imei" => '14134234343242', //not mandatory
            "accept_header" => "text/html", 
            "user_agent"=> "Windows 10",
           // "fingerprintid" => '' //not mandatory
          ]
        ];
        

        $this->load->library('jwt');
        $curl_payload = $this->jwt->encode($payload, 'YOUR SECRET KEY', "HS256", null ,$headers); // you should use Firebase/JWT library to encrypt the response

        $ch = curl_init( 'https://pguat.billdesk.io/payments/ve1_2/orders/create' );

        $ch_headers = array(
            "Content-Type: application/jose",
            "accept: application/jose",
            "BD-Traceid: RANDOM STRING",
            "BD-Timestamp: 20200817132207"
        );
        curl_setopt( $ch, CURLOPT_HTTPHEADER, $ch_headers);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt( $ch, CURLOPT_POSTFIELDS, $curl_payload);
        curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
                            
        $result = curl_exec($ch);
        
        curl_close($ch);
        

        /*****************************************/
                 // Billdesk Response
        /*****************************************/
        
        $launch_billdesk = false;
        try { 
            $result_decoded = $this->jwt->decode($result, 'Cjlj6qiBlQ7qdnglXvlJCKY1t3rNk7x4', array('HS256'));

            $result_array = (array) $result_decoded;

            if ($result_decoded->status == 'ACTIVE') {
                echo $result_array;
            } else { // Response error
                echo "Response error";
            }
                            
        } catch (\Exception $e) {
          echo $e;
        }
  
    }

获取OauthToken和bOrderId后.启动账单桌面sdk

<html>
<head>
    <meta charset="utf-8" />
    <title></title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <script type="module" src="https://uat.billdesk.com/jssdk/v1/dist/billdesksdk/billdesksdk.esm.js"></script>
    <script nomodule="" src="https://uat.billdesk.com/jssdk/v1/dist/billdesksdk.js"></script>
    <link href="https://uat.billdesk.com/jssdk/v1/dist/billdesksdk/billdesksdk.css" rel="stylesheet">
    <script>

        var flow_config = {
            merchantId: "YOUR MERCHANT ID",
            bdOrderId: "OADY19XTURZ7NE", // get from orderCreate response
            authToken: "OToken 90FA4D84784AD18EEB9833BBD0CA27AFC045BD17FD625B4C43C85B8C0FCEB941573F37C0D8D6870257493C1AB70C702BEC3D8266786C3A0E8DB9FE10882F0A270C5D32F07CADFC5E86920333673BA4B48F7E0FE7867694F0D237F154211B8E29D789DBD4A4D8202BB0E5BC46134EBF963ED82724B561DB305946A246968C38524DD26BB660B63BCDE9E879583616B2A767B5C5C867272FFA16976B.4145535F55415431", // get from orderCreate response
            childWindow: false,
            returnUrl: "Return URL",
            crossButtonHandling: 'Y',
            retryCount: 0
        };
        var responseHandler = function (txn) {
            if (txn.response) {
                alert("callback received status:: ", txn.status);
                alert("callback received response:: ", txn.response);
            }
        };

        var config = {
            flowConfig: flow_config,
            flowType: "payments"
        };
        window.onload = function () {
            window.loadBillDeskSdk(config);
        };

    </script>
    
</head>
<body>

</body>
</html>
9udxz4iz

9udxz4iz2#

预计银行本身将提供此类教程。
如果你在他们的网站上找不到,那么你不太可能在其他地方找到他们,除非它是一家已经广泛用于在线交易处理的银行。打电话给他们,问他们能提供什么帮助。我合作过的银行一直很乐意提供帮助。
而不是仅仅集成到您的网站,它可以帮助使用现有的,流行的购物车系统,例如。Ubercart,它将有很多你需要的代码已经到位,并将有类似的插件已经与其他银行完成的例子,例如。here.

相关问题