Epay API 支付包装器

1.0.5 2016-04-23 13:34 UTC

This package is auto-updated.

Last update: 2024-09-17 00:38:08 UTC


README

安装

"escapeboy/epay": "1.*"

在 config/app.php 中

Escapeboy\Epay\EpayServiceProvider::class,
'Epay' => Escapeboy\Epay\EpayServiceProvider::class,

发布配置文件

php artisan vendor:publish --provider="Escapeboy\Epay\EpayServiceProvider" --tag="config" 

--

使用

编辑 config/epay.php

return [
	'submit_url' => 'https://devep2.datamax.bg/ep2/epay2_demo/', // test submit url
	// 'submit_url' => 'https://www.epay.bg/', // production submit url
	'secret' => REQUIRED, // client secret
	'client_id' => REQUIRED, // client id
	'expire_days' => 1 // expire time for transations in days
	'success_url' => 'epay/success', // return url for success
	'cancel_url' => 'epay/cancel', // return url for cancel
];

生成提交给 Epay 的隐藏输入字段

echo \Epay::generateInputFields([
				'invoice' => '000001', // invoice ID
				'amount' => 100, // amount
				'descr' => 'Some info about order' // info about order
]);

接收 epay 通知(url 已填写在商家的个人资料中)

Route::post('epay/notification', function(){

	$notification_data = \Epay::receiveNotification(request()->all());
		/**
        * $notification_data contains array with data:
        *
        *    array (
        *      'invoice' => 'your_order_id',
        *      'status' => 'PAID',
        *      'pay_date' => '20162304154530',
        *      'stan' => '045138',
        *      'bcode' => '045138'
        *    ),
        *
        **/
	return response()->make($notification_data['response']);
});