vb-payment/esunacq-cardlink

此包的最新版本(v0.1.2)没有提供许可信息。

v0.1.2 2017-04-14 09:56 UTC

This package is not auto-updated.

Last update: 2024-09-28 19:52:46 UTC


README

使用说明

$  composer require vb-payment/esunacq-cardlink

获取通讯键值 (txToken)

在每个 request 请求前都需要获取一次 txToken

时效性 300

<?php
    use VeryBuy\Payment\EsunBank\Acq\CardLink\RequestBuilder;

    // $mac 由玉山銀行提供`註冊`用的押碼
    $builder = new RequestBuilder($mac);

    /**
     * $SID 商家代碼
     * $SKey 使用者編號
     * $targetUrl 玉山 API 接口
     *
     * production: https://card.esunbank.com.tw/EsunCreditweb/txnproc/cardLink/commVerify
     * testing: https://cardtest.esunbank.com.tw/EsunCreditweb/txnproc/cardLink/commVerify
     */
//    單一商店
//    $communicate = $builder->communicate($targetUrl, [
//        'SID' => $SID,
//        'SKey' => $SKey,
//    ]);

    /**
     * 多商店版本
     */
    $communicate = $builder->communicate($targetUrl, [
        'SID' => '{專案代碼}',
        'SKey' => $SKey,
        'PRJCD' => 'C001',
        'PRJINFO' => $SID
    ]);

    if ($communicate->isSuccessful()) {
        print_r($communicate->getVerifyToken());
    }

导向至玉山刷卡页面注册卡号

格式为 HTML FROM 会 auto submit

<?php
    use VeryBuy\Payment\EsunBank\Acq\CardLink\RequestBuilder;

    // $mac 由玉山銀行提供`註冊`用的押碼
    $builder = new RequestBuilder($mac);

    /**
     * $SID 商家代碼
     * $SKey 使用者編號
     * $targetUrl 玉山 API 接口
     *
     * production: https://card.esunbank.com.tw/EsunCreditweb/txnproc/cardLink/rgstACC
     * testing: https://cardtest.esunbank.com.tw/EsunCreditweb/txnproc/cardLink/rgstACC
     *
     */
//    單一商店
//    echo $builder->registerForm($targetUrl, [
//        'SID' => $SID,
//        'SKey' => $SKey,
//        'txToken' => $communicate->getVerifyToken(),
//        'rData' => '提供商家傳值,原封不動回傳 length:200',
//    ]);

    /**
     * 多商店版本
     */
    echo $builder->registerForm($targetUrl, [
        'SID' => '{專案代碼}',
        'SKey' => $SKey,
        'txToken' => $communicate->getVerifyToken(),
        'rData' => '提供商家傳值,原封不動回傳 length:200',
    ]);

刷卡结果回传 CardLink 键值 (LKey)

设置于一开始玉山要求的 response url

需要保存

代表著 SID + SKey 的用户 (SID + SKey 是唯一值,意思是某家商店的某个用户 )

<?php
    use VeryBuy\Payment\EsunBank\Acq\CardLink\Response\RegisterFormResponse;

    $response = new RegisterFormResponse($_POST);

    if ($response->isSuccessful()) {
        print_r($response->getAccessToken());
    }

获取交易 token

仅限一次使用

时效性 300

<?php
    use VeryBuy\Payment\EsunBank\Acq\CardLink\RequestBuilder;

    // $mac 由玉山銀行提供`註冊`用的押碼
    $builder = new RequestBuilder($mac);

    /**
     * $SID 商家代碼
     * $SKey 使用者編號
     * $targetUrl 玉山 API 接口
     *
     * production: https://card.esunbank.com.tw/EsunCreditweb/txnproc/cardLink/tknService
     * testing: https://cardtest.esunbank.com.tw/EsunCreditweb/txnproc/cardLink/tknService
     *
     */
//    單一商店
//    $trade = $builder->trade($targetUrl, [
//        'SID' => $SID,
//        'SKey' => $SKey,
//        'txToken' => $communicate->getVerifyToken(),
//        'LKey' => $response->getAccessToken(),
//        'OrderNo' => sprintf('TO%08d', 3), // 訂單編號 length:50
//        'TxnAmt' => 1000,   // 訂單金額
//        'TxnDesc' => '顯示在 CardLink 頁面上',
//        'rData' => '提供商家傳值,原封不動回傳 length:200',
//    ]);

    /**
     * 多商店版本
     */
    $trade = $builder->trade($targetUrl, [
        'SID' => '{專案代碼}',
        'SKey' => $SKey,
        'txToken' => $communicate->getVerifyToken(),
        'LKey' => $response->getAccessToken(),
        'OrderNo' => sprintf('TO%08d', 3), // 訂單編號 length:50
        'TxnAmt' => 1000,   // 訂單金額
        'TxnDesc' => '顯示在 CardLink 頁面上',
        'rData' => '提供商家傳值,原封不動回傳 length:200',
    ]);

    if ($trade->isSuccessful()) {
        print_r($trade->getTradeToken());
    }

请求授权

<?php
    use VeryBuy\Payment\EsunBank\Acq\CardLink\RequestBuilder;
    use VeryBuy\Payment\EsunBank\Acq\CardLink\Request\AuthorizeRequest;

    // $mac 由玉山銀行提供`交易`用的押碼
    $builder = new RequestBuilder($mac);

    /**
     * $MID 商家代碼 ( 等同於註冊時的 SID )
     * $targetUrl 玉山 API 接口
     *
     * production: https://acq.esunbank.com.tw/ACQTrans/esuncard/txnf013c
     * testing: https://acqtest.esunbank.com.tw/ACQTrans/esuncard/txnf013c
     *
     */
//    單一商店
//    $authorize= $builder->authorize($targetUrl, [
//        'MID' => $MID,
//        'TID' => AuthorizeRequest::TYPE_TRANSACTION,
//        'ONO' => sprintf('TO%08d', 3), // 訂單編號,不可重複,不可包含【_】字元,英數限用大寫 length:50
//        'TA' => 1000, // 訂單金額
//        'TK' => $trade->getTradeToken(),
//    ]);

    /**
     * 多商店版本
     */
    $authorize= $builder->authorize($targetUrl, [
        'MID' => $MID,
        'TID' => AuthorizeRequest::TYPE_TRANSACTION,
        'ONO' => sprintf('TO%08d', 3), // 訂單編號,不可重複,不可包含【_】字元,英數限用大寫 length:50
        'TA' => 1000, // 訂單金額
        'TK' => $trade->getTradeToken(),
        'SID' => '{專案代碼}',
        'PRJCD' => 'C001',
    ]);

    if ($authorize->isSuccessful()) {
        print_r($trade->getOrderNumber());
    }

取消授权

<?php
    use VeryBuy\Payment\EsunBank\Acq\CardLink\RequestBuilder;

    // $mac 由玉山銀行提供`交易`用的押碼
    $builder = new RequestBuilder($mac);

    /**
     * $MID 商家代碼 ( 等同於註冊時的 SID )
     * $targetUrl 玉山 API 接口
     *
     * production: https://acq.esunbank.com.tw/ACQTrans/esuncard/txnf0150
     * testing: https://acqtest.esunbank.com.tw/ACQTrans/esuncard/txnf0150
     *
     */
    $unauthorize = $builder->unauthorize($targetUrl, [
        'MID' => $MID,
        'ONO' => sprintf('TO%08d', 3),
    ]);

    if ($unauthorize->isSuccessful()) {
        print_r($unauthorize->getOrderNumber());
    }