kanazaca/easypay

Laravel 专用 easypay.pt 包

1.0.4 2018-03-25 02:54 UTC

This package is not auto-updated.

Last update: 2024-09-28 18:42:18 UTC


README

Laravel 包,用于与 easypay API 一起工作

功能概述

  • 支持 MB 和信用卡(VISA、MASTERCARD、AMERICAN-EXPRESS)
  • 创建参考
  • 实时获取支付通知
  • 获取所有支付
  • 等等...

安装

将此添加到 composer.json 文件中的 require 对象

"kanazaca/easypay": "1.0.*"

之后,运行 composer install 安装包。将服务提供者添加到 config/app.php 中的 providers 数组。

'providers' => array(
	// ...
	kanazaca\easypay\EasypayServiceProvider::class,
)

发布配置文件。

php artisan vendor:publish

之后,您可能需要更改位于 config/easypay.php 的配置文件,以输入您的凭据等。

最后,运行迁移以创建 easypay_notifications

php artisan migrate

用法

创建参考

此代码将请求 easypay 获取一个新参考,该参考可以使用 MB 或信用卡支付

$payment_info = [
            'o_name' => "Your name",
            'o_email' => 'Your email',
            't_value' => '29.00',
            'o_description' => 'Here is your description',
            'o_obs' => 'Here is your observations',
            'o_mobile' => 'Here is your mobile',
            't_key' => 'Here is the ID of your order'
    ];
    
$easypay = new EasyPay($payment_info);

$reference = $easypay->createReference();

这将返回一个包含以下内容的数组


Array
(
    [ep_status] => ok0
    [ep_message] => ep_country and ep_entity and ep_user and ep_cin ok and validation by code;code ok - new reference generated - NEW REFERENCE - 
    [ep_cin] => your CIN
    [ep_user] => your USER
    [ep_entity] => your ENTITY
    [ep_reference] => generated REFERENCE
    [ep_value] => Asked value
    [t_key] => Order ID sent
    [ep_link] => Link to pay using credit-card
)

现在您可以对这个信息做您想做的事情,也许您想将其保存到数据库中,以构建用户支付历史。

实时接收通知的方法

当 easypay 收到支付时,他们将调用您提供的 URL,这将执行类似于以下的方法,更多详情请参阅 (https://docs.easypay.pt/workflow/payment-notification)

$easypay = new EasyPay($payment_info);

$xml = $easypay->processPaymentInfo();

//do your code here if needed

return \Response::make($xml, '200')->header('Content-Type', 'text/xml'); //must return in text/xml for easypay

此代码块将存储到数据库中 easypay 收到的支付文件编号,使用他们发送的更多信息更新,并返回给 easypay xml。(第 4 步:https://docs.easypay.pt/workflow/payment-notification

获取所有支付

这将返回一个包含所有来自 easypay 的支付的所有内容的数组

$easypay = new EasyPay();

$all_payments = $easypay->fetchAllPayments();

就这样...

鸣谢

Hugo Neto