safecharge-international/safecharge-php
Composer 安装命令:
composer require safecharge-international/safecharge-php
包简介
A PHP client library for accessing Nuvei API
关键字:
README 文档
README
Nuvei’s REST API SDK for PHP provides developer tools for accessing Nuvei's REST API. Nuvei’s REST API is a simple, easy-to-use, secure and stateless API, which enables online merchants and service providers to process consumer payments through Nuvei’s digital payment Gateway. The API supports merchants of all levels of PCI certification, online and mobile merchant applications, and is compatible with a large variety of payment options, such as payment cards and alternative payment methods. For Nuvei REST API documentation, please see: https://docs.nuvei.com/api/main/
Requirements
PHP 5.4 or later.
Installation
Installation via Composer
composer require nuvei/nuvei-server-php
Manual
If you do not wish to use Composer, you can download the latest release, and then include the init.php file.
require_once('/path/to/nuvei-sdk/init.php');
Dependencies
The PHP SDK requires the following extensions to work properly:
Configuration
Client
$client = new \Nuvei\Api\RestClient([ 'environment' => \Nuvei\Api\Environment::TEST, 'merchantId' => '<your merchantId>', 'merchantSiteId' => '<your merchantSiteId>', 'merchantSecretKey' => '<your merchantSecretKey>', ]);
Or
$client = new \Nuvei\Api\RestClient(); $config = $client->getConfig(); $config->setEnvironment(\Nuvei\Api\Environment::TEST); $config->setMerchantId('<your merchantId>'); $config->setMerchantSiteId('<your merchantSiteId>'); $config->setMerchantSecretKey('<your merchantSecretKey>');
Logger
Logger can be configured with a PSR-3 compatible logger .
Example with Monolog
$logger = new Monolog\Logger('nuvei-php-sdk'); $logger->pushHandler(new Monolog\Handler\StreamHandler('path/to/log', Monolog\Logger::DEBUG)); $client->setLogger($logger);
Example
Nuvei's PHP SDK appends merchantId, merchantSiteId, timestamp, and checksum in the request.
<?php use Nuvei\Api\RestClient; use Nuvei\Tests\SimpleData; use Nuvei\Tests\TestCaseHelper; require __DIR__ . '/../vendor/autoload.php'; require __DIR__ . '/../init.php'; require __DIR__ . '/../tests/TestCaseHelper.php'; require __DIR__ . '/../tests/SimpleData.php'; $config = [ 'environment' => \Nuvei\Api\Environment::TEST, 'merchantId' => '<your merchantId>', 'merchantSiteId' => '<your merchantSiteId>', 'merchantSecretKey' => '<your merchantSecretKey>', 'hashAlgorithm' => '<sha256>' ]; $nuvei = new \Nuvei\Api\Nuvei(); $nuvei->initialize($config); $paymentResponse = $nuvei->getPaymentService()->initPayment([ 'currency' => 'EUR', 'amount' => '10', 'userTokenId' => '<user token id>', 'paymentOption' => [ 'card' => [ 'cardNumber' => '<card number>', 'cardHolderName' => 'card name', 'expirationMonth' => '<expiration month>', 'expirationYear' => '<expiration year>', 'CVV' => '<cvv>', ] ], 'billingAddress' => [ "firstName" => "<first name>", "lastName" => "<last name>", "address" => "<address>", "phone" => "<phone number>", "zip" => "<zip code>", "city" => "<city>", 'country' => "<country ISO 3166-1 alpha-2>", "state" => "<state>", "email" => "<email address>", "county" => "<county>", ] ]); print_r($paymentResponse); $openOrderResponse = $nuvei->getPaymentService()->openOrder([ 'userTokenId' => '<user token id>', 'clientUniqueId' => '', 'clientRequestId' => '', 'currency' => SimpleData::getCurrency(), 'amount' => SimpleData::getAmount(), 'amountDetails' => SimpleData::getAmountDetails(), 'items' => SimpleData::getItems(), 'deviceDetails' => SimpleData::getDeviceDetails(), 'userDetails' => SimpleData::getUserDetails(), 'shippingAddress' => SimpleData::getShippingAddress(), 'billingAddress' => SimpleData::getBillingAddress(), 'dynamicDescriptor' => SimpleData::getDynamicDescriptor(), 'merchantDetails' => SimpleData::getMerchantDetails(), 'addendums' => SimpleData::getAddEndUms(), ]); print_r($openOrderResponse);
safecharge-international/safecharge-php 适用场景与选型建议
safecharge-international/safecharge-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 832.16k 次下载、GitHub Stars 达 13, 最近一次更新时间为 2017 年 10 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「nuvei」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 safecharge-international/safecharge-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 safecharge-international/safecharge-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 safecharge-international/safecharge-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PHP client library for accessing Nuvei API
Smart2Pay SDK - enable payments on your site easily 200+ methods, 80+ countries
A PHP wrapper for Nuvei's api.
A PHP wrapper for Nuvei's api.
Helpers to intergate with Nuvei
统计信息
- 总下载量: 832.16k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 13
- 点击次数: 23
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-10-04