通过API与ePay支付系统交互的库

dev-master 2018-10-22 11:13 UTC

This package is not auto-updated.

Last update: 2024-09-29 05:48:30 UTC


README

通过API与ePay支付系统交互的库。

设置

  1. 在您的终端中使用以下命令安装此库。(目前库处于开发模式)

    composer require masterzero/epay dev-master

  2. 更新 config/app.php 中的提供者

     'providers' => [
         // ...
         MasterZero\Epay\ApiServiceProvider::class,
     ]
    
  3. 更新 config/app.php 中的别名

     'aliases' => [
         // ...
         'EpayApi' => MasterZero\Epay\Facade\Api::class,
     ]
    
  4. 创建 config/epay.php 文件,内容如下

return [
    'merchantnumber'=> env('EPAY_MERCHANTNUMBER', '1337'),
    'password'=> env('EPAY_PASSWORD', '12345678'),
];
  1. 将这些参数添加到 .env(可选)
EPAY_MERCHANTNUMBER=1337
EPAY_PASSWORD=12345678

用法

捕获交易

捕获交易。客户资金 -> 您的资金

use EpayApi;
// ...

$optionalParams = [
    'group'     => 'customers',
    'invoice'   => 'for some product',
]


$result = EpayApi::capture($transactionid, $amount /*, $optionalParams*/);

if ($result['captureResult']) {
    echo "ba dum tss! the method works!";
} else {
    echo "nope. something went wrong :C";
}

信用交易

信用交易。部分已捕获(您的)资金 -> 返回客户资金

use EpayApi;
// ...

$optionalParams = [
    'group'     => 'customers',
    'invoice'   => 'for some product',
]

$result = EpayApi::credit($transactionid, $amount /*, $optionalParams*/);

if ($result['creditResult']) {
    echo "ba dum tss! the method works!";
} else {
    echo "nope. something went wrong :C";
}

删除交易

删除交易。所有未捕获(非您的)资金 -> 返回客户资金

use EpayApi;
// ...

$optionalParams = [
    'group'     => 'customers',
]

$result = EpayApi::delete($transactionid /*, $optionalParams*/);

if ($result['deleteResult']) {
    echo "ba dum tss! the method works!";
} else {
    echo "nope. something went wrong :C";
}

授权

获取支付订阅的资金

use EpayApi;
// ...

$params = [
    'subscriptionid' => 123,
    'orderid' => 123,
    'amount' => 5000, // 50.00 * 100 
    'currency' => 208, // DKK
    'instantcapture' => 1,
    'group' => 'customer', //optional
    'description' => 'la la la', //optional
    'email' => 'test@example.com', //optional
    'sms' => 'la la la', //optional
    'ipaddress' => '255.255.255.255', //optional
]

$result = EpayApi::authorize($params);

if ($result['authorizeResult']) {
    echo "ba dum tss! the method works!";
} else {
    echo "nope. something went wrong :C";
}

删除订阅

删除订阅并停止授权。

use EpayApi;


// ...

$result = EpayApi::deletesubscription($subscriptionid);

if ($result['deletesubscriptionResult']) {
    echo "ba dum tss! the method works!";
} else {
    echo "nope. something went wrong :C";
}

获取 epay 错误

通过 epayresponsecode 获取 epay 错误描述

use EpayApi;
// ...


/**
 * laguages:
 * 1 - Danish
 * 2 - English
 * 3 - Swedish
 */
$result = EpayApi::getEpayError($language, $epayresponsecode);

if ($result['getEpayErrorResult']) {
    echo "ba dum tss! the method works!";
} else {
    echo "nope. something went wrong :C";
}

获取 pbs 错误

通过 pbsresponsecode 获取 pbs 错误描述

use EpayApi;
// ...


/**
 * laguages:
 * 1 - Danish
 * 2 - English
 * 3 - Swedish
 */
$result = EpayApi::getPbsError($language, $pbsresponsecode);

if ($result['getPbsErrorResult']) {
    echo "ba dum tss! the method works!";
} else {
    echo "nope. something went wrong :C";
}

多商户使用

use MasterZero\Epay\Api;

// ...

$api = new Api([
    'merchantnumber' => '1337',
    'password' => '12345678',
]);


$api->authorize($params);