亚洲国产精品成人无码区,公天天吃我奶躁我的比视频,亚洲国产欧美视频亚洲国产精品一区二区成人片不卡,天天躁日日躁狠狠躁视频2021,起视碰看97视频在线少妇久久久久久人妻无码, 芒果乱码一线二线三线新区 ,亚洲熟妇无码AⅤ不卡在线播放,人妻少妇乱子伦无码专区

400-800-9385
網(wǎng)站建設(shè)資訊詳細

第三方銀行卡支付空中云匯怎么用php對接支付

發(fā)表日期:2023-08-17 16:13:57   作者來源:劉紅旺   瀏覽:1928   標(biāo)簽:空中云匯    第三方支付    
Airwallex 中文名稱空中云匯 主頁是做境外VISA信用卡、銀聯(lián)支付等的一個集成支付接口

空中云匯

公司網(wǎng)址可以搜索空中云匯
 
一.注冊創(chuàng)建支持api key
 

獲取key


 
 
二.獲取到平臺登入token
 
    function getToken(){
        $token=session('air_token');
        $config=$this->config();
        $client_id=$config['x-client-id'];
        $api_key=$config['x-api-key'];
       
      if(!$token){
        $curl = curl_init();
        curl_setopt_array($curl, array(
          CURLOPT_URL => 'https://api.airwallex.com/api/v1/authentication/login',
          CURLOPT_RETURNTRANSFER => true,
          CURLOPT_ENCODING => '',
          CURLOPT_MAXREDIRS => 10,
          CURLOPT_TIMEOUT => 0,
          CURLOPT_FOLLOWLOCATION => true,
          CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
          CURLOPT_CUSTOMREQUEST => 'POST',
          CURLOPT_HTTPHEADER => array(
            'Content-Type: application/json',
            'x-client-id:'.$client_id.'',
            'x-api-key:'.$api_key.'',
         
          ),
        ));
       
        $response = curl_exec($curl);
 
        $data=json_decode($response,true);
        //dump($data);exit;
            if($data['token']){
                session('air_token',$data['token'],60*30);
                $token= $data['token'];
            }
        }
        return $token;
 
    }
 
三. 通過token 去獲取溝通平臺創(chuàng)建支付意向訂單
public  function create_order($order)
    {
        $curl = curl_init();
        $token=$this->getToken();
       
        $time=date(DATE_ISO8601);//注意時間格式必須是DATE_ISO8601
        //dump($time);
       
        curl_setopt_array($curl, array(
          CURLOPT_URL => 'https://api.airwallex.com/api/v1/pa/payment_intents/create',
          CURLOPT_RETURNTRANSFER => true,
          CURLOPT_ENCODING => '',
          CURLOPT_MAXREDIRS => 10,
          CURLOPT_SSL_VERIFYPEER=>false,
          CURLOPT_SSL_VERIFYHOST=>false,
          CURLOPT_TIMEOUT => 0,
          CURLOPT_FOLLOWLOCATION => true,
          CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
          CURLOPT_CUSTOMREQUEST => 'POST',
          CURLOPT_POSTFIELDS =>'{
            "request_id": "'.$order['merchant_order_id'].'",
            "amount": '.$order['amount'].',
            "currency": "CNY",
            "merchant_order_id": "'.$order['merchant_order_id'].'",  
            "return_url": "xxxxxxxxxxx"
          }',
          CURLOPT_HTTPHEADER => array(
            'Content-Type: application/json',
            'Authorization: Bearer '.$token.''
          ),
        ));
       
        $response = curl_exec($curl);
       
        curl_close($curl);
        return  json_decode($response,true);
 
    }
 
return_url:可選 如果你用的支付模式是跳轉(zhuǎn)到空中云付的托管頁面就要填寫,支付成功后回跳頁面,這里我們用的是內(nèi)嵌卡片
 

選擇支付方式


    
四、前端設(shè)置支付卡片
<script src="https://checkout.airwallex.com/assets/elements.bundle.min.js"></script>
 
<div class="main-page shopping-main">
  <div class="container clear pay_box">
      <div class="syt-body">
          <div class="t1">Payment amount</div>
          <div class="t3">{$order.order_no}</div>
          <div class="t2">$ {$total_amount}</div>
          <div id="card-container" style="display: none">
            <!-- STEP #3a: Add an empty container for the card element to be injected into -->
            <div id="card"></div>
            <p id="input-error" style="color: red"></p>
            <!-- STEP #3b: Add a submit button to trigger the payment request -->
            <button id="submit" disabled="true">Submit</button>
          </div>
          <!-- Example response message containers -->
          <p id="error"></p>
          <p id="success">Payment successful!</p>
      </div>
  </div>
</div>
 
 
  <script>
    var id="{$payment.id}";
    var client_secret="{$payment.client_secret}"    
    var currency="{$payment.currency}"
    try {
      // STEP #2: Initialize the Airwallex global context for event communication
      Airwallex.init({
        env: 'prod', // Setup which Airwallex env('staging' | 'demo' | 'prod') to integrate with
        origin: window.location.origin, // Setup your event target to receive the browser events message
        intent_id: id,
        client_secret: client_secret,
        currency: currency,
 
        buttonType: 'buy', // Indicate the type of button you want displayed on your payments form. Like 'buy'
        fonts: [
          // Customizes the font for the payment elements
          {
            src:
              'https://checkout.airwallex.com/fonts/CircularXXWeb/CircularXXWeb-Regular.woff2',
            family: 'AxLLCircular',
            weight: 400,
          },
        ],
      });
 
      // STEP #4: Create 'card' element
      const card = Airwallex.createElement('card');
 
      // STEP #5: Mount card element
      const domElement = card.mount('card');
      // STEP #7: Add an event listener to ensure the element is mounted
      domElement.addEventListener('onReady', (event) => {
        /*
       ... Handle event
        */
        document.getElementById('card-container').style.display = 'block'; // Example: show element when it is mounted
        document.getElementById('submit').style.display = 'block'; // Example: show element when it is mounted
        console.log('Element is ready', event.detail);
      });
 
      // STEP #8: Add an event listener to validate element input
      domElement.addEventListener('onChange', (event) => {
        const { complete } = event.detail;
        document.getElementById('submit').disabled = !complete; // Example: only enable button when element input is completed
      });
 
      // STEP #9: Add an event listener to get input focus status
      domElement.addEventListener('onFocus', (event) => {
        // Customize your input focus style by listen onFocus event
        const element = document.getElementById('input-error');
        if (element) {
          element.innerHTML = ''; // Example: clear input error message
        }
      });
 
      // STEP #10: Add an event listener to show input error message when finish typing
      domElement.addEventListener('onBlur', (event) => {
        const { complete } = event.detail;
        const { error } = event.detail;
        const element = document.getElementById('input-error');
        if (element & error) {
          element.innerHTML = error.message || JSON.stringify(error); // Example: set input error message
        }
      });
 
      // STEP #11: Add an event listener to handle errors
      domElement.addEventListener('onError', (event) => {
        const { error } = event.detail;
        document.getElementById('error').style.display = 'block'; // Example: show error
        document.getElementById('error').innerHTML = error.message; // Example: set error message
        console.error('There was an error', error);
      });
    } catch (error) {
      document.getElementById('error').style.display = 'block'; // Example: show error
      document.getElementById('error').innerHTML = error.message; // Example: set error message
      console.error('There was an error', error);
    }
 
    // STEP #6a: Add a button handler to trigger the payment request
    document.getElementById('submit').addEventListener('click', () => {
      document.getElementById('error').style.display = 'none'; // Example: hide error
      document.getElementById('submit').innerHTML = 'Processing...'; // Example: set submitting state
      document.getElementById('submit').disabled = true; // Example: disable button to prevent double submission
 
      Airwallex.confirmPaymentIntent({
        element: Airwallex.getElement('card'),
        intent_id: id,
        client_secret: client_secret,
     
      })
        .then((response) => {
          // STEP #6b: Listen to the request response
          /* Handle confirm response */
          document.getElementById('success').style.display = 'block'; // Example: show success message
          document.getElementById('submit').innerHTML = 'Submit'; // Example: reset button state
          document.getElementById('submit').disabled = true; // Example: reset button state
         
        })
        .catch((response) => {
          // STEP #6c: Listen to the error response
          /* Handle error response */
          document.getElementById('error').style.display = 'block'; // Example: show error message
          document.getElementById('error').innerHTML = response.message; // Example: fill in error message
          document.getElementById('submit').innerHTML = 'Submit'; // Example: reset button state
          document.getElementById('submit').disabled = false; // Example: reset button state
          console.error(`There was an error, ${JSON.stringify(response)}`);
        });
    });
 

 
Id:創(chuàng)建訂單回調(diào)的訂單id
client_secret:創(chuàng)建訂單回調(diào)secret
Currency:支付的貨幣符號
 
  • 創(chuàng)建webhooks 回調(diào)支付結(jié)果

 

 

 
如沒特殊注明,文章均為方維網(wǎng)絡(luò)原創(chuàng),轉(zhuǎn)載請注明來自http://www.oulysa.com/news/6855.html
A一级黄色片免费一级毛片| 亚洲疯狂做受XXXX高潮| 精品国产午夜福利在线观看| 国产精品狼人久久久久影院| 国产性色福利在线视频| 97久久久精品综合88久久| 欧美XXXXX高潮喷水麻豆| 国产成人精品免高潮在线观看| 国产又粗又黄又猛又爽| 中文字幕AV无码不卡二区| 娇妻被打开双腿灌满白浆一区| 亚洲AV激情无码专区在线播放| 久久天天躁狠狠躁夜夜?v浪潮| 欧美精品性爱久久久午夜视频| 亚洲AV无码成人精品区在线观看| 国产免费AV片无码永久| 亚洲AV永久青草无码精品| 精品人妻无码一区二区色欲产成人| 日本一卡二卡三卡视频免费在线观看| 丁香五月国产精品| 欧美成人精品第一区二区三区| 99久久久国产精品免费蜜臀| 韩国的无码AV看免费大片在线| 亚洲精品国偷拍自产电影 | 91中文字幕免费人成毛片乱码| 少妇高潮惨叫久久久久久| 一区二区精品日韩高清一区| 少妇无码AV无码专区.| 久久久久无码国产精品不卡| 亚洲国产精品一区二区三区| 制服丝袜国产日韩一区| 国产精品永久免费,亚洲国产精品尤物YW在线观看| 丁香婷婷六月综合缴清| 国产一区二区视频在线| 欧美巨大另类极品videosbest| 怡红院免费快播视频| 日韩亚洲欧美无砖专区| 忘忧草社区中文字幕www| 亚洲区日韩区无码区| 亚洲一区二区三区无码站区| 免费国产成人福利在线观看网址|