定制 devpark/laravel-przelewy24 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

devpark/laravel-przelewy24

Composer 安装命令:

composer require devpark/laravel-przelewy24

包简介

Laravel przelewy24.pl integration

README 文档

README

This module makes integration with przelewy24.pl payment system easier. It supports making payments using przelewy24.pl system.

New version 3.0 released

Package supports recently version Przelewy24 REST API.

The old Payment Provider Api version will expire before end of year 2021.

We recommend immediately upgrading the package version.

Installation

  1. Run

    composer require devpark/laravel-przelewy24

    in console to install this module

  2. Open config/app.php and add

    Laravel 5.5+ uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider. You can go to 3.
    Devpark\Transfers24\Providers\Transfers24ServiceProvider::class

    in section providers

  3. Run

    php artisan vendor:publish --provider="Devpark\Transfers24\Providers\Transfers24ServiceProvider"

    in your console to publish default configuration files transfers24.php in config directory

    Add flag force to alter configuration after upgrade package

    These are all configuration settings. Some settings can be changed via environment settings, see below.

  4. Open .env and add your configuration:

  • PRZELEWY24_MERCHANT_ID -a Company or an Individual number, who has signed a contract with Przelewy24 (Merchant ID),

  • PRZELEWY24_POS_ID - the identification number of the shop (default: Merchant ID)

  • PRZELEWY24_CRC -a random string, used to calculate a CRC value, shown in Przelewy24 Admin panel.

  • PRZELEWY24_REPORT_KEY -a report key, used to calculate a Report Key value, shown in Przelewy24 Admin panel.

  • PRZELEWY24_TEST_SERVER - if true, set the test environment

  • PRZELEWY24_URL_RETURN - Return address, where Client will be redirected to, after the transaction is completed (default 'transfers24/callback').

  • PRZELEWY24_URL_STATUS - (POST route) address where the status of a transaction is sent. It can be omitted if stored in P24 system (default 'transfers24/status').

Usage

In order to use the system, you need to do a few things:

  1. You need to launch the registration request in order to init payment

  2. You need to handle customer returning routes to your app. By default there are routes 'transfers24/callback'

  3. You should ensure transaction verify. Here you should send verify request of payment after receiving notification about correct transaction from payment system. You need to handle returning routes to status of the transaction which is sent automatically from payment system. By default there are routes 'transfers24/status'

Registration request

This is main request you need to launch to init payment.

The most basic sample code for authorization request could look like this:

$payment = app()->make(\App\Payment::class);
$registration_request = app()->make(\Devpark\Transfers24\Requests\Transfers24::class);

$register_payment = $registration_request->setEmail('test@example.com')->setAmount(100)->init();

if($register_payment->isSuccess())
{
    // save registration parameters in payment object
    
    return $registration_request->execute($register_payment->getToken(), true);
}

This code should be run in controller as it's returning response which will takes few things.

  1. Status registration payment

  2. Token, if registration done with success

  3. Error code return from payment system

  4. Error Message return from payment system

  5. Request parameters send to payment system

For setAmount default currency is PLN. If you want to use other currency, you should use currency constant from \Devpark\Transfers24\Currency class as 2nd parameter. Also please notice that amount you should give to this function is real amount (with decimal places) and not converted already to Przelewy24 format.

For \Devpark\Transfers24\Requests\Transfers24::execute method 2nd parameter decides of redirection to payment system when true or return url for making payment when false

Define customer returning routes

You should create routes that will redirect customer after the completed transaction (those routes will be launched using GET HTTP method),

Handling transaction verify route

To make sure the payment was really successful you should use \Devpark\Transfers24\Requests\Transfers24::receive method. The simplest code could look like this:

$payment_verify = app()->make(\Devpark\Transfers24\Requests\Transfers24::class);
$payment_response = $payment_verify->receive($request);

if ($payment_response->isSuccess()) {
    $payment = Payment::where('session_id',$payment_response->getSessionId())->firstOrFail();
   // process order here after making sure it was real payment
}
echo "OK";

This code should be run in controller, because you should return non-empty response when receiving valid przelewy24 request for transaction verify. As you see, you should make sure it was real payment before you process the order and then you need to make sure that it was successful. You can identify payment via session_id (unique ID generate during registration of payment)).

Licence

This package is licenced under the MIT license

devpark/laravel-przelewy24 适用场景与选型建议

devpark/laravel-przelewy24 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 37.19k 次下载、GitHub Stars 达 39, 最近一次更新时间为 2017 年 01 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 devpark/laravel-przelewy24 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 devpark/laravel-przelewy24 我们能提供哪些服务?
定制开发 / 二次开发

基于 devpark/laravel-przelewy24 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 37.19k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 40
  • 点击次数: 9
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 39
  • Watchers: 8
  • Forks: 35
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-01-02