payxpert/connect2pay
Composer 安装命令:
composer require payxpert/connect2pay
包简介
PayXpert Payment Page System client library
README 文档
README
This library is the official PHP client to interact with the PayXpert Payment Page system. The whole payment workflow is implemented through easy to use methods.
Installation
Easy installation with Composer is available.
Install with composer.phar.
php composer.phar require "payxpert/connect2pay"
Basic usage
The example below shows a simple use case to create a Credit Card payment.
use PayXpert\Connect2Pay\Connect2PayClient; use PayXpert\Connect2Pay\containers\request\PaymentPrepareRequest; use PayXpert\Connect2Pay\containers\Order; use PayXpert\Connect2Pay\containers\Shipping; use PayXpert\Connect2Pay\containers\Shopper; use PayXpert\Connect2Pay\containers\Account; use PayXpert\Connect2Pay\containers\constant\OrderShippingType; use PayXpert\Connect2Pay\containers\constant\PaymentMethod; use PayXpert\Connect2Pay\containers\constant\PaymentMode; use PayXpert\Connect2Pay\containers\constant\AccountAge; use PayXpert\Connect2Pay\containers\constant\AccountLastChange; use PayXpert\Connect2Pay\containers\constant\AccountPaymentMeanAge; $connect2pay = "https://connect2.payxpert.com/"; // This will be provided once your account is approved $originator = "000000"; $password = "Gr3atPassw0rd!"; $c2pClient = new Connect2PayClient($connect2pay, $originator, $password); $prepareRequest = new PaymentPrepareRequest(); $shopper = new Shopper(); $account = new Account(); $order = new Order(); $shipping = new Shipping(); // Set all information for the payment $prepareRequest->setPaymentMethod(PaymentMethod::CREDIT_CARD); $prepareRequest->setPaymentMode(PaymentMode::SINGLE); // To charge €25.99 $prepareRequest->setCurrency("EUR"); $prepareRequest->setAmount(2599); // Extra custom data that are returned with the payment status $prepareRequest->setCtrlCustomData("Give that back to me please!!"); // Where the customer will be redirected after the payment $prepareRequest->setCtrlRedirectURL("https://merchant.example.com/payment/redirect"); // URL on the merchant site that will receive the callback notification $prepareRequest->setCtrlCallbackURL("https://merchant.example.com/payment/callback"); $order->setId("ABC-123456"); $order->setShippingType(OrderShippingType::DIGITAL_GOODS); $order->setDescription("Payment of €25.99"); $shopper->setId("1234567WX"); $shopper->setFirstName("John")->setLastName("Doe"); $shopper->setAddress1("Debit Street, 45"); $shopper->setZipcode("3456TRG")->setCity("New York")->setState("NY")->setCountryCode("US"); $shopper->setHomePhonePrefix("212")->setHomePhone("12345678"); $shopper->setEmail("shopper@example.com"); $account->setAge(AccountAge::LESS_30_DAYS); $account->setDate("20210106"); $account->setLastChange(AccountLastChange::LESS_30_DAYS); $account->setLastChangeDate("20210106"); $account->setPaymentMeanAge(AccountPaymentMeanAge::LESS_30_DAYS); $account->setPaymentMeanDate("20210106"); $account->setSuspicious(false); $shipping->setName("Lady Gogo"); $shipping->setAddress1("125 Main Street"); $shipping->setZipcode("ABC-5678")->setState("NY")->setCity("New York")->setCountryCode("US"); $shipping->setPhone("+47123456789"); $shopper->setAccount($account); $prepareRequest->setShopper($shopper); $prepareRequest->setOrder($order); $prepareRequest->setShipping($shipping); $result = $c2pClient->preparePayment($prepareRequest); if ($result !== false) { // The customer token info returned by the payment page could be saved in session (may // be used later when the customer will be redirected from the payment page) $_SESSION['merchantToken'] = $result->getMerchantToken(); // The merchantToken must also be used later to validate the callback to avoid that anyone // could call it and abusively validate the payment. It may be stored in local database for this. // Now redirect the customer to the payment page header('Location: ' . $c2pClient->getCustomerRedirectURL($result)); } else { echo "Payment preparation error occurred: " . $c2pClient->getClientErrorMessage() . "\n"; }
See scripts in the examples/ folder to see more use cases.
payxpert/connect2pay 适用场景与选型建议
payxpert/connect2pay 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 102.73k 次下载、GitHub Stars 达 8, 最近一次更新时间为 2018 年 03 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「payment」 「credit card」 「bank transfer」 「SEPA Direct Debit」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 payxpert/connect2pay 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 payxpert/connect2pay 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 payxpert/connect2pay 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This Extension integrates a credit check and more made by the LEONEX Risk Management Platform into your order process. Extensive configuration and evaluation options is provided in the Platform
Integration with Cielo gateway.
Settings Card for Laravel Nova.
A tool for scraping URL resources (oEmbed, OpenGraph, Twitter cards, JSON-LD)
Validate credit card number, expiration date, cvc
A Laravel Nova Card to show Fathom Analytics stats.
统计信息
- 总下载量: 102.73k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 35
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2018-03-16