fmtl-studio/ laravel-epay
Laravel适配器,用于通过ePay、EasyPay和BPay接受支付。
Requires
- guzzlehttp/guzzle: ^6.5
- illuminate/support: ^5.8|^6.0
- nesbot/carbon: ^2.0
Requires (Dev)
- orchestra/testbench: ^4.0
This package is auto-updated.
Last update: 2024-09-29 05:35:47 UTC
README
Laravel包装器,用于轻松无缝集成所有可用的ePay支付方式
- ePay
- EasyPay(10位识别号)
- BPay(使用ATM机取款进行支付)
- ePay World(使用借记/信用卡进行支付)
由Fundamental Studio Ltd.用爱和代码制作
安装
该包与Laravel 7+版本兼容。
通过composer
$ composer require fmtl-studio/laravel-epay
使用提供者发布
安装后,该包应被Laravel自动发现。为了配置该包,您需要使用以下命令发布配置文件
$ php artisan vendor:publish --provider="Fundamental\Epay\EpayServiceProvider"
配置
发布配置文件后,您应将所需密钥添加到全局.env Laravel文件中
EPAY_PRODUCTION=FALSE # Should the platform use the production or the test ePay endpoint
EPAY_MIN=XXXXXXXXXX # Official KIN number from the ePay platform
EPAY_SECRET=XXXXXXXXXX # Secret token from the ePay platform
EPAY_DEFAULT_CURRENCY="BGN" # Default currency
EPAY_DEFAULT_URL_OK="https://myurl.com/"
EPAY_DEFAULT_URL_CANCEL="https://myurl.com/"
EPAY_GENERATE_INVOICE=TRUE # Should the package generate random invoice number if one isn't presented
EPAY_EXPIRATION_HOURS=72 # What is the period(in hours) that tha package should add to the current timestamp for an expiration date
您已准备好并可以启动了。
文档和使用说明
我们包的使用非常流畅且简单。首先,您需要使用我们包的正确命名空间
use Fundamental\Epay\Epay;
创建我们包的实例
$epay = new Epay('paylogin', array $data, 'BG'); // Use either paylogin or credit_paydirect, the second parameter is documented in the next section and the third parameter is the request language page will be shown in: BG or EN, default: BG. $epay->setData( 1000000000, // Could be either number or false(will be auto-generated if EPAY_GENERATE_INVOICE=TRUE) 40.00, // Amount of the payment, double formatted either as double or string '14.12.2019 20:46:00', // Could be either formatted date in d.m.Y H:i:s or false(will be auto-generated) 'Description of the payment in less than 100 symbols.', // Could be empty 'BGN', // Available currencies: BGN, USD, EUR, default to bgn, may be ommited 'utf-8' // Encoding, either null or utf-8, may be ommitted );
快速发起支付的方式
setData函数可以省略。数据可以作为数组设置,作为主类的构造函数的第二个参数。
$epay = new Epay('paylogin', [ 'invoice' => 1000000000, // Could be either number or false(will be auto-generated if EPAY_GENERATE_INVOICE=TRUE) 'amount' => 40.00, // Amount of the payment, double formatted either as double or string 'expiration' => '14.12.2019 20:46:00', // Could be either formatted date in d.m.Y H:i:s or false(will be auto-generated) 'description' => 'Description of the payment in less than 100 symbols.' // Could be empty ]);
所有可用方法都在下一节中展示,包括setter和getter方法。
生成支付字段和/或表单
检索所有所需参数的正确和格式化的隐藏字段、表单或数组。
// Both, URL OK and URL Cancel can be ommitted as not required by the ePay platform. // Would return all hidden fields as formatted html $epay->generatePaymentFields('https://ok.url', 'https://cancel.url'); // Would return html form with the first parameter as id $epay->generatePaymentForm('#form-id', 'https://ok.url', 'https://cancel.url'); // Would return array with all needed parameters for the platform request you need to do on your own $epay->getPaymentParameters();
所有可用方法都在下一节中展示。
注意
所有当前请求都可以用作表单,将用户重定向到ePay平台,包括
- 通过您的ePay账户进行支付
- 使用6位代码的BPay取款代码
- 通过ePay World使用借记/信用卡支付(如果ePay World包含在您的ePay合同中)
- EasyPay选项卡,将为您提供10位支付代码
EasyPay
但是,如果您需要并想自己集成平台与EasyPay 10位代码,您可以使用
// Using the initialization code from the upper piece of code $easyPayIDN = $epay->requestIDNumber(); // Returning the 10 digit number for EasyPay payment or throws an exception $epay->getEasypayIDN(); // Available method if needed and not assigned the requestIDNumber() to a variable
解析结果
也可以解析返回结果,并以数组形式输出。
// Would like the $response array to have two members encoded and checksum. $results = Fundamental\Epay\Epay::parseResult($response); // Will return full array of data, if the checksum check equals true
您可以在下一节中找到有关可用方法以及paylogin和credit_paydirect类型的差异的更多信息。所有可用方法都在下一节中展示。
官方ePay文档可以在这里找到。
- 生产ePay URL端点: https://epay.bg/
- 演示ePay URL端点: https://demo.epay.bg/
方法
所有可用方法及其参数和返回格式。
/** * Constructing the Epay class instance. * * @param String $type Can be either paylogin or credit_paydirect. * @param array $data May be ommitted and use the setData function. * @param String $language Can be either BG or EN. */ new Epay(String $type = 'paylogin', array $data = [], String $language = 'BG') /** * Setting main data for creating and sending the request. * * @param String $invoice * @param [type] $amount The amount * @param String $expiration * @param String $description Invoice description content in less than 100 symbols. * @param string $currency * @param [type] $encoding * @return void */ public function setData($invoice = false, $amount, $expiration = false, String $description = '', $currency = 'BGN', $encoding = null) /** * Setter for invoice number. * * @param String $invoice The invoice number. * @return void */ public function setInvoice($invoice): void /** * Get the set or generated invoice number. * * @return String */ public function getInvoice(): String /** * Setter for amount number. * * @param double|float|String $amount The invoice amount. * @return void */ public function setAmount($amount): void /** * Get the invoice amount. * * @return Double */ public function getAmount(): Double /** * Setter for expiration date in format d.m.Y H:i:s * * @param String $expiration Date format: d.m.Y H:i:s * @return void */ public function setExpiration($expiration): void /** * Get the already set expiration time. * * @return String */ public function getExpiration(): String /** * Setter for invoice description parameter. * * @param String $description Length should be less than 100 symbols. * @return void */ public function setDescription($description): void /** * Get the already set description parameter. * * @return String */ public function getDescription(): String /** * Send request to the ePay platform for 10 digit code generation and retrieve * * @return String */ public function requestIDNumber(): String /** * Retrieve the requested and generated IDN for in place payment at EasyPay * * @return String */ public function getEasypayIDN(): String /** * Parse result and get all status and ePay generated fields as array. * * @param array $data Should include encoded and checksum members of the array. * @return array */ public static function parseResult(array $data): array /** * Generate the checksum of the send or already initialized data array. * * @param boolean $data * @return void */ public function generateChecksum($data = false) /** * Get the encoded data string. * * @return String */ public function getEncoded(): String /** * Get the calculated checksum string. * * @return String */ public function getChecksum(): String /** * Get the target url for the ePay platform, using the english version and the test parameter. * * @return String */ public function getTargetUrl(): String /** * Get all hidden input fields for the needed request. * * @param boolean $urlOk Using the default value from the config or being ommitted. * @param boolean $urlCancel Using the default value from the config or being ommitted. * @return String All needed hidden input fields */ public function generatePaymentFields($urlOk = false, $urlCancel = false): String /** * Returns a html form with all hidden input fields for the needed request. * * @param String $id The id element of the generated form. * @param boolean $urlOk Using the default value from the config or being ommitted. * @param boolean $urlCancel Using the default value from the config or being ommitted. * @return String Html form with all hidden fields and set id attribute */ public function generatePaymentForm(String $id = '', $urlOk = false, $urlCancel = false): String /** * Get all request parameters for making the ePay request on your own. * * @return array */ public function getPaymentParameters(): array
变更日志
所有更改都可在我们的变更日志文件中找到。
支持
对于任何进一步的问题、功能请求、问题、想法等,您可以在问题跟踪器中创建问题或通过support@fundamental.bg联系我们
贡献
阅读贡献文件以获取更多信息。
致谢
- Konstantin Rachev
- Vanya Ananieva
该包由Fundamental Studio Ltd.的团队打包并贡献给社区。
问题
如果您发现任何问题,请使用问题跟踪器。
安全
如果在您的发现任何安全相关的问题,请通过电子邮件konstantin@fundamental.bg或support@fundamental.bg联系,而不是使用问题跟踪器。
许可
MIT许可(MIT)。有关更多信息,请参阅许可文件。