Php - 綠界金流使用

開啟信用卡測試範例

<?php
/**
*    Credit信用卡付款產生訂單範例
*/
    
    //載入SDK(路徑可依系統規劃自行調整)

        include('ECPay.Payment.Integration.php');
    try {
        
    	$obj = new ECPay_AllInOne();
        

   		
        //服務參數 這裡要注意 這是測試用的url 正式的為 https://payment.ecpay.com.twㄋ/Cashier/AioCheckOut/V5
        $obj->ServiceURL  = "https://payment-stage.ecpay.com.tw/Cashier/AioCheckOut/V5";   //服務位置
        $obj->HashKey     = '5294y06JbISpM5x9' ;                                           //測試用Hashkey,請自行帶入ECPay提供的HashKey
        $obj->HashIV      = 'v77hoKGq4kWxNNIS' ;                                           //測試用HashIV,請自行帶入ECPay提供的HashIV
        $obj->MerchantID  = '2000132';                                                     //測試用MerchantID,請自行帶入ECPay提供的MerchantID
        $obj->EncryptType = '1';                                                           //CheckMacValue加密類型,請固定填入1,使用SHA256加密


        //基本參數(請依系統規劃自行調整)
        $MerchantTradeNo = "Test".time() ;
        $obj->Send['ReturnURL']         = "https://localhost/" ;    //付款完成通知回傳的網址(客戶部會導入頁面)
        $obj->Send['OrderResultURL']= "https://localhost/";    //付款完成通知回傳的網址,客戶會被導回此頁面(頁面C)
        $obj->Send['MerchantTradeNo']   = $MerchantTradeNo;                          //訂單編號
        $obj->Send['MerchantTradeDate'] = date('Y/m/d H:i:s');                       //交易時間
        $obj->Send['TotalAmount']       = 50;                                      //交易金額
        $obj->Send['TradeDesc']         = "good to drink" ;                          //交易描述
        $obj->Send['ChoosePayment']     = ECPay_PaymentMethod::ALL ;              //付款方式:ALL
        $obj->Send['IgnorePayment']     = ECPay_PaymentMethod::GooglePay ;           //不使用付款方式:GooglePay
        $obj->Send['CustomField1']      = "欄位1";
        $obj->Send['CustomField2']      = "欄位2";

        //訂單的商品資料
        array_push($obj->Send['Items'], array('Name' => "歐付寶黑芝麻豆漿", 'Price' => (int)"2000",
                   'Currency' => "元", 'Quantity' => (int) "1", 'URL' => "dedwed"));


        //Credit信用卡分期付款延伸參數(可依系統需求選擇是否代入)
        //以下參數不可以跟信用卡定期定額參數一起設定
        $obj->SendExtend['CreditInstallment'] = '' ;    //分期期數,預設0(不分期),信用卡分期可用參數為:3,6,12,18,24
        $obj->SendExtend['InstallmentAmount'] = 0 ;    //使用刷卡分期的付款金額,預設0(不分期)
        $obj->SendExtend['Redeem'] = false ;           //是否使用紅利折抵,預設false
        $obj->SendExtend['UnionPay'] = false;          //是否為聯營卡,預設false;


        //Credit信用卡定期定額付款延伸參數(可依系統需求選擇是否代入)
        //以下參數不可以跟信用卡分期付款參數一起設定
        // $obj->SendExtend['PeriodAmount'] = '' ;    //每次授權金額,預設空字串
        // $obj->SendExtend['PeriodType']   = '' ;    //週期種類,預設空字串
        // $obj->SendExtend['Frequency']    = '' ;    //執行頻率,預設空字串
        // $obj->SendExtend['ExecTimes']    = '' ;    //執行次數,預設空字串
        
        # 電子發票參數
        /*
        $obj->Send['InvoiceMark'] = ECPay_InvoiceState::Yes;
        $obj->SendExtend['RelateNumber'] = "Test".time();
        $obj->SendExtend['CustomerEmail'] = 'test@ecpay.com.tw';
        $obj->SendExtend['CustomerPhone'] = '0911222333';
        $obj->SendExtend['TaxType'] = ECPay_TaxType::Dutiable;
        $obj->SendExtend['CustomerAddr'] = '台北市南港區三重路19-2號5樓D棟';
        $obj->SendExtend['InvoiceItems'] = array();
        // 將商品加入電子發票商品列表陣列
        foreach ($obj->Send['Items'] as $info)
        {
            array_push($obj->SendExtend['InvoiceItems'],array('Name' => $info['Name'],'Count' =>
                $info['Quantity'],'Word' => '個','Price' => $info['Price'],'TaxType' => ECPay_TaxType::Dutiable));
        }
        $obj->SendExtend['InvoiceRemark'] = '測試發票備註';
        $obj->SendExtend['DelayDay'] = '0';
        $obj->SendExtend['InvType'] = ECPay_InvType::General;
        */


        //產生訂單(auto submit至ECPay)
        $obj->CheckOut();

    
    } catch (Exception $e) {
    	echo $e->getMessage();
    } 


 
?>

信用卡測試卡號
在这里插入图片描述
付款完成後 會傳送給導入頁面POST
內容如下

Array ( 
[CustomField1] => 123456789 
[CustomField2] => 987654321
[CustomField3] => 
[CustomField4] => 
[MerchantID] => 2000132 
[MerchantTradeNo] => Test1590129033 
[PaymentDate] => 2020/05/22 14:30:58 
[PaymentType] => Credit_CreditCard 
[PaymentTypeChargeFee] => 1 
[RtnCode] => 1 
[RtnMsg] => Succeeded 
[SimulatePaid] => 0 
[StoreID] => 
[TradeAmt] => 50
[TradeDate] => 2020/05/22 14:30:33 
[TradeNo] => 交易編號
[CheckMacValue] => 加密內容 
 )
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客
应支付0元
点击重新获取
扫码支付

支付成功即可阅读