worldstream-labs/omnipay-paysafecard
Composer 安装命令:
composer require worldstream-labs/omnipay-paysafecard
包简介
Paysafecard driver for the Omnipay payment processing library
README 文档
README
Paysafecard library for the Omnipay V3 payment library
Installation
Use composer to add the library as dependency for your project
composer require worldstream-labs/omnipay-paysafecard
Development
To set up for development:
composer install
Usage
Setup
<?php require 'vendor/autoload.php'; use Omnipay\Omnipay; $gateway = Omnipay::create('Paysafecard'); $gateway->setApiKey('yourApiKey'); // When deploying to production, don't forget to set test mode to false $gateway->setTestMode(false);
Authorizing a payment
<?php require 'vendor/autoload.php'; use Omnipay\Omnipay; $gateway = Omnipay::create('Paysafecard'); $gateway->setApiKey('yourApiKey'); $response = $gateway->authorize([ 'amount' => 10.00, 'currency' => 'EUR', 'success_url' => 'https://website/success/{payment_id}', 'failure_url' => 'https://website/failure/{payment_id}', 'notification_url' => 'https://website/notification/{payment_id}', ])->send(); if (!$response->isSuccessful()) { throw new \RuntimeException('Error with payment'); } $paymentId = $response->getPaymentId(); // use this for the next call redirect($response->getRedirectUrl());
This call will return the AuthorizeResponse object. If the call is succesful then you can redirect the customer to the redirectUrl. Depending on the result in the next screen the customer will be redirected to the success or failure url.
Capture
Before you can capture the payment, make sure the payment is successfully authorized using the fetchTransaction call.
<?php $gateway = Omnipay::create('Paysafecard'); $gateway->setApiKey('yourApiKey'); $response = $gateway->fetchTransaction([ 'payment_id' = $paymentId ])->send(); if ($response->getStatus() === 'AUTHORIZED') { $captureResponse = $gateway->capture([ 'payment_id' = $paymentId ])->send(); }
Refund
[Optional] You can call validateRefund first. Quoted from Paysafecard: "In order to make sure that the requested refund can continue, the business partner has to precheck the likeliness of the upcoming refund to be successful, there are certain conditions why a refund might be refused"
<?php $gateway = Omnipay::create('Paysafecard'); $gateway->setApiKey('yourApiKey'); $validationResponse = $gateway->validateRefund([ 'payment_id' => $paymentId, 'amount' => 10.00, 'currency' => 'EUR', 'customer_email' => 'test@email.com', 'customer_id' => 1001, ])->send(); if (!$validationResponse->getStatus() != 'VALIDATION_SUCCESSFUL') { throw new \RuntimeException('Error with refund validation'); } $refundResponse = $gateway->refund([ 'payment_id' => $paymentId, 'refund_id' => $validationResponse->getRefundId(), ])->send(); if ($refundResponse->isSuccessful()) { // refund was successful }
or refund directly
<?php $gateway = Omnipay::create('Paysafecard'); $gateway->setApiKey('yourApiKey'); $refundResponse = $gateway->refund([ 'payment_id' => $paymentId, 'amount' => 10.00, 'currency' => 'EUR', 'customer_email' => 'test@email.com', 'customer_id' => 1001, ])->send(); if ($refundResponse->isSuccessful()) { // refund was successful }
Tests
Run the unit tests with composer run test
Support
If you are having general issues with Omnipay, we suggest posting on Stack Overflow. Be sure to add the omnipay tag so it can be easily found.
If you believe you have found a bug, please report it using the GitHub issue tracker, or better yet, fork the library and submit a pull request.
References
Paysafecard REST API docs Omnipay Mollie v3 (similar JSON API) (official package, use as template) Omnipay Paysafecard Rest (Omnipay v2)
worldstream-labs/omnipay-paysafecard 适用场景与选型建议
worldstream-labs/omnipay-paysafecard 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9.65k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2020 年 05 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「payment」 「pay」 「gateway」 「paysafecard」 「merchant」 「omnipay」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 worldstream-labs/omnipay-paysafecard 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 worldstream-labs/omnipay-paysafecard 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 worldstream-labs/omnipay-paysafecard 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
repository php library
Payyo Gateway for the Omnipay payment processing library
Библиотека для приема платежей через Альфабанк.
Some pre-defined rules for validation in Omnipay payment processing library.
BluePay gateway for the Omnipay payment processing library
支付宝接口扩展包
统计信息
- 总下载量: 9.65k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 26
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-05-15