course-link/omnipay-polish-payments
Composer 安装命令:
composer require course-link/omnipay-polish-payments
包简介
Polish payments drivers for the Omnipay payment processing library
关键字:
README 文档
README
Polish Gateways support for the Omnipay PHP payment processing library.
Installation
composer require course-link/omnipay-polish-payments
Examples
Here is a simple example of how to use Omnipay. As you can see, Omnipay has a consistent, well thought out API. As much as possible, we try to abstract the differences between the various payments gateways.
Making a purchase
require_once __DIR__ . '/vendor/autoload.php'; use Omnipay\Omnipay; use CourseLink\Omnipay\Customer; // Select gateway $gateway = Omnipay::create('imoje'); $gateway = Omnipay::create('Paynow'); $gateway = Omnipay::create('PayU'); $gateway = Omnipay::create('Przelewy24'); $gateway = Omnipay::create('Tpay'); $gateway->initialize([]); // Pass gateway specific options // Send purchase request $response = $gateway->purchase([ // Minimum options to use with any of package gateways 'customer' => new Customer([ 'name' => 'John Doe', 'firstName' => 'John', 'lastName' => 'Doe', 'email' => 'johnny@example.com', 'address' => 'Testowa 25', 'city' => 'Warszawa', 'postcode' => '00-000', 'country' => 'PL' ]), 'language' => 'pl', 'amount' => 99.99, 'description' => 'Ebook', 'client_ip' => '127.0.0.1', 'currency' => 'pln', 'transaction_id' => '1', 'notifyUrl' => 'https://example.com/notify-url', 'paymentMethod' => 150 // required for tpay gateway ])->send(); // Process response if ($response->isSuccessful()) { // Payment was successful // This will never happen, since user will always be redirected to off-site payment gateway print_r($response); } elseif ($response->isRedirect()) { // Redirect to offsite payment gateway $response->redirect(); } else { // Payment failed echo $response->getMessage(); }
Accepting notification from gateway
require_once __DIR__ . '/vendor/autoload.php'; use Omnipay\Omnipay; // Select gateway $gateway = Omnipay::create('imoje'); $gateway = Omnipay::create('Paynow'); $gateway = Omnipay::create('PayU'); $gateway = Omnipay::create('Przelewy24'); $gateway = Omnipay::create('Tpay'); $gateway->initialize([]); // Pass gateway specific options $notification = $gateway->acceptNotification(); $status = $notification->getTransactionStatus(); $data = $notification->getData(); $transactionReference = $notification->getTransactionReference(); if ($gateway->supportsCompletePurchase()) { // This is required for Przelewy24 $response = $gateway->completePurchase(array_merge($purchaseOptions, $data))->send(); }
Configuration
imoje
Gateway
use Omnipay\Omnipay; $gateway = Omnipay::create('imoje'); $gateway->initialize([ 'merchant_id' => '', 'service_id' => '', 'service_key' => '', 'auth_token' => '', 'test_mode' => false, 'verify_ip_address' => true, 'notification_ip_addresses' => [ ], ]);
Purchase
$response = $gateway->purchase([ 'customer' => new Customer([ 'firstName' => 'John', //required 'lastName' => 'Doe', // required 'email' => 'johnny@example.com', // required ]), 'language' => 'pl', //required 'amount' => 99.99, //required 'description' => 'Ebook', 'currency' => 'pln', //required 'transaction_id' => '1', //required 'notifyUrl' => 'https://example.com/notify-url', 'returnUrl' => 'https://example.com/return-url', 'cancelUrl' => 'https://example.com/cancel-url', ])->send();
Notification
$notification = $gateway->acceptNotification( options: [], // request body, if empty values are taken from httpRequest headers: [] // if empty values are taken from httpRequest ); $status = $notification->getTransactionStatus(); $data = $notification->getData(); $transactionReference = $notification->getTransactionReference();
Paynow
Gateway
use Omnipay\Omnipay; $gateway = Omnipay::create('Paynow'); $gateway->initialize([ 'api_key' => '', 'signature_key' => '', 'test_mode' => true, ]);
Purchase
$response = $gateway->purchase([ 'customer' => new Customer([ 'firstName' => 'John', 'lastName' => 'Doe', 'email' => 'johnny@example.com', //required 'phone' => '+48123456789' ]), 'language' => 'pl', 'amount' => 99.99, //required 'description' => 'Ebook', //required 'currency' => 'pln', 'transaction_id' => '1', //required 'returnUrl' => 'https://example.com/return-url', ])->send();
Notification
$notification = $gateway->acceptNotification( options: [], // request body, if empty values are taken from httpRequest headers: [] // if empty values are taken from httpRequest ); $status = $notification->getTransactionStatus(); $data = $notification->getData(); $transactionReference = $notification->getTransactionReference();
PayU
Http Client Config
PayU requires Http Client to configure:
'allow_redirects' => false,
Gateway
use Omnipay\Omnipay; $gateway = Omnipay::create('PayU'); $gateway->initialize([ 'pos_id' => '', 'signature_key' => '', 'client_id' => '', 'client_secret' => '', 'test_mode' => true, 'verify_ip_address' => true, 'notification_ip_addresses' => [ ], ]);
Purchase
$response = $gateway->purchase([ 'customer' => new Customer([ 'firstName' => 'John', //required 'lastName' => 'Doe', //required 'email' => 'johnny@example.com', //required 'phone' => '+48123456789' ]), 'language' => 'pl', 'amount' => 99.99, //required 'description' => 'Ebook', //required 'client_ip' => '127.0.0.1', //required 'currency' => 'pln', //required 'transaction_id' => '1', 'notifyUrl' => 'https://example.com/notify-url', 'returnUrl' => 'https://example.com/return-url', ])->send();
Notification
$notification = $gateway->acceptNotification( options: [], // request body, if empty values are taken from httpRequest headers: [] // if empty values are taken from httpRequest ); $status = $notification->getTransactionStatus(); $data = $notification->getData(); $transactionReference = $notification->getTransactionReference();
Przelewy24
Gateway
use Omnipay\Omnipay; $gateway = Omnipay::create('Przelewy24'); $gateway->initialize([ 'posId' => '', 'merchantId' => '', 'crcKey' => '', 'reportKey' => '', 'test_mode' => false, 'verify_ip_address' => true, 'notification_ip_addresses' => [ ], ]);
Purchase
$response = $gateway->purchase([ 'customer' => new Customer([ 'name' => 'John Doe', 'email' => 'johnny@example.com', //required 'address' => 'Testowa 25', 'city' => 'Warszawa', 'postcode' => '00-000', 'phone' => '+48123456789' 'country' => 'PL' //required ]), 'language' => 'pl', 'amount' => 99.99, //required 'description' => 'Ebook', //required 'currency' => 'pln', //required 'transaction_id' => '1', //required 'notifyUrl' => 'https://example.com/notify-url', 'returnUrl' => 'https://example.com/return-url', //required ])->send();
Notification
$notification = $gateway->acceptNotification( options: [], // request body, if empty values are taken from httpRequest headers: [] // if empty values are taken from httpRequest ); // Przelewy24 requires to complete purchase after accepting notification $response = $gateway->completePurchase(array_merge($purchaseOptions, $notificationData))->send(); $status = $notification->getTransactionStatus(); $data = $notification->getData(); $transactionReference = $notification->getTransactionReference();
Tpay
Gateway
use Omnipay\Omnipay; $gateway = Omnipay::create('Tpay'); $gateway->initialize([ 'merchant_id' => '', 'service_id' => '', 'service_key' => '', 'auth_token' => '', 'test_mode' => false, 'verify_ip_address' => true, 'notification_ip_addresses' => [ ], ]);
Purchase
$response = $gateway->purchase([ 'customer' => new Customer([ 'name' => 'John Doe', //required 'email' => 'johnny@example.com', //required 'address' => 'Testowa 25', 'city' => 'Warszawa', 'postcode' => '00-000', 'phone' => '+48123456789' 'country' => 'PL' ]), 'language' => 'pl', 'amount' => 99.99, //required 'description' => 'Ebook', //required 'currency' => 'pln', //required 'notifyUrl' => 'https://example.com/notify-url', 'returnUrl' => 'https://example.com/return-url', 'cancelUrl' => 'https://example.com/cancel-url', 'paymentMethod' => 150 // required ])->send();
Notification
When using Tpay: Regardless of the transaction status (tr_status), the merchant's system should print TRUE response when all validations are correct.
$notification = $gateway->acceptNotification( options: [], // request body, if empty values are taken from httpRequest headers: [] // if empty values are taken from httpRequest ); $status = $notification->getTransactionStatus(); $data = $notification->getData(); $transactionReference = $notification->getTransactionReference();
course-link/omnipay-polish-payments 适用场景与选型建议
course-link/omnipay-polish-payments 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 260 次下载、GitHub Stars 达 2, 最近一次更新时间为 2023 年 01 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「payment」 「payments」 「pay」 「gateway」 「polish」 「payu」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 course-link/omnipay-polish-payments 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 course-link/omnipay-polish-payments 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 course-link/omnipay-polish-payments 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Payyo Gateway for the Omnipay payment processing library
Dealing with payments through the Egyptian payment gateway PayMob
Librería para la gestión sencilla de pagos mediante TPV Redsys y Paypal
Библиотека для приема платежей через Альфабанк.
Some pre-defined rules for validation in Omnipay payment processing library.
BluePay gateway for the Omnipay payment processing library
统计信息
- 总下载量: 260
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 37
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-01-06