cool-studio/globalpayments-magento2
Composer 安装命令:
composer require cool-studio/globalpayments-magento2
包简介
Demonstrates integration with payment gateway from GlobalPayments, modified for PHP8.3
README 文档
README
After a conversation with GlobalPayments, they did not have a timeline for supporting PHP8.3, but claimed that it should work just fine, even though you can't install it becasue of the dependency check in Composer.
Synopsis
An extension to add integration with Payment Gateway. This payment method can be restricted to work only with specific Shipping method.
Motivation
This is one of a collection of examples to demonstrate the features of Magento 2. The intent of this sample is to demonstrate how to create own Payment Gateway integration
Technical feature
Module configuration
- Package details composer.json.
- Module configuration details (sequence) in module.xml.
- Module configuration available through Stores->Configuration system.xml
Payment gateway module depends on Sales, Payment and Checkout Magento modules.
For more module configuration details, please look through module development docs.
Gateway configuration
On the next step, we might specify gateway domain configuration in config.xml.
Let's look into configuration attributes:
debugenables debug mode by default, e.g log for request/responseactiveis payment active by defaultmodelPayment Method Facadeused for integration withSalesandCheckoutmodulesmerchant_gateway_keyencrypted merchant credentialorder_statusdefault order statuspayment_actiondefault action of paymenttitledefault title for a payment methodcurrencysupported currencycan_authorizewhether payment method supports authorizationcan_capturewhether payment method supports capturecan_voidwhether payment method supports voidcan_use_checkoutcheckout availabilityis_gatewayis an integration with gatewaysort_orderpayment method order position on checkout/system configuration pagesdebugReplaceKeysrequest/response fields, which will be masked in logpaymentInfoKeystransaction request/response fields displayed on payment information blockprivateInfoKeyspaymentInfoKeys fields which should not be displayed in customer payment information block
Dependency Injection configuration
To get more details about dependency injection configuration in Magento 2, please see DI docs.
In a case of Payment Gateway, DI configuration is used to define pools of Gateway Commands with related infrastructure and to configure Payment Method Facade (used by Sales and Checkout modules to perform commands)
Payment Method Facade configuration:
<!-- Payment Method Facade configuration --> <virtualType name="GlobalPaymentsPaymentGatewayFacade" type="Magento\Payment\Model\Method\Adapter"> <arguments> <argument name="code" xsi:type="const">\GlobalPayments\PaymentGateway\Model\Ui\ConfigProvider::CODE</argument> <argument name="formBlockType" xsi:type="string">Magento\Payment\Block\Form</argument> <argument name="infoBlockType" xsi:type="string">GlobalPayments\PaymentGateway\Block\Info</argument> <argument name="valueHandlerPool" xsi:type="object">GlobalPaymentsPaymentGatewayValueHandlerPool</argument> <argument name="commandPool" xsi:type="object">GlobalPaymentsPaymentGatewayCommandPool</argument> </arguments> </virtualType>
codePayment Method codeformBlockTypeBlock class name, responsible for Payment Gateway Form rendering on a checkout. Since Opepage Checkout uses knockout.js for rendering, this renderer is used only during Checkout process from Admin panel.infoBlockTypeBlock class name, responsible for Transaction/Payment Information details rendering in Order block.valueHandlerPoolValue handler pool used for queries to configurationcommandPoolPool of Payment Gateway commands
Pools
! All
Payment\Gatewayprovided pools implementations use lazy loading for components, i.e configured with component type name instead of component object
Value Handlers
There should be at least one Value Handler with default key provided for ValueHandlerPool.
!-- Value handlers infrastructure --> <virtualType name="GlobalPaymentsPaymentGatewayValueHandlerPool" type="Magento\Payment\Gateway\Config\ValueHandlerPool"> <arguments> <argument name="handlers" xsi:type="array"> <item name="default" xsi:type="string">GlobalPaymentsPaymentGatewayConfigValueHandler</item> </argument> </arguments> </virtualType> <virtualType name="GlobalPaymentsPaymentGatewayConfigValueHandler" type="Magento\Payment\Gateway\Config\ConfigValueHandler"> <arguments> <argument name="configInterface" xsi:type="object">GlobalPaymentsPaymentGatewayConfig</argument> </arguments> </virtualType>
Commands
All gateway commands should be added to CommandPool instance
<!-- Commands infrastructure --> <virtualType name="GlobalPaymentsPaymentGatewayCommandPool" type="Magento\Payment\Gateway\Command\CommandPool"> <arguments> <argument name="commands" xsi:type="array"> <item name="authorize" xsi:type="string">GlobalPaymentsPaymentGatewayAuthorizeCommand</item> <item name="capture" xsi:type="string">GlobalPaymentsPaymentGatewayCaptureCommand</item> <item name="void" xsi:type="string">GlobalPaymentsPaymentGatewayVoidCommand</item> </argument> </arguments> </virtualType>
Example of Authorization command configuration:
<!-- Authorize command --> <virtualType name="GlobalPaymentsPaymentGatewayAuthorizeCommand" type="Magento\Payment\Gateway\Command\GatewayCommand"> <arguments> <argument name="requestBuilder" xsi:type="object">GlobalPaymentsPaymentGatewayAuthorizationRequest</argument> <argument name="handler" xsi:type="object">GlobalPaymentsPaymentGatewayResponseHandlerComposite</argument> <argument name="transferFactory" xsi:type="object">GlobalPayments\PaymentGateway\Gateway\Http\TransferFactory</argument> <argument name="client" xsi:type="object">GlobalPayments\PaymentGateway\Gateway\Http\Client\ClientMock</argument> </arguments> </virtualType> <!-- Authorization Request --> <virtualType name="GlobalPaymentsPaymentGatewayAuthorizationRequest" type="Magento\Payment\Gateway\Request\BuilderComposite"> <arguments> <argument name="builders" xsi:type="array"> <item name="transaction" xsi:type="string">GlobalPayments\PaymentGateway\Gateway\Request\AuthorizationRequest</item> <item name="mockData" xsi:type="string">GlobalPayments\PaymentGateway\Gateway\Request\MockDataRequest</item> </argument> </arguments> </virtualType> <type name="GlobalPayments\PaymentGateway\Gateway\Request\AuthorizationRequest"> <arguments> <argument name="config" xsi:type="object">GlobalPaymentsPaymentGatewayConfig</argument> </arguments> </type> <!-- Response handlers --> <virtualType name="GlobalPaymentsPaymentGatewayResponseHandlerComposite" type="Magento\Payment\Gateway\Response\HandlerChain"> <arguments> <argument name="handlers" xsi:type="array"> <item name="txnid" xsi:type="string">GlobalPayments\PaymentGateway\Gateway\Response\TxnIdHandler</item> <item name="fraud" xsi:type="string">GlobalPayments\PaymentGateway\Gateway\Response\FraudHandler</item> </argument> </arguments> </virtualType>
GlobalPaymentsPaymentGatewayAuthorizeCommand- instance of GatewayCommand provided byPayment\Gatewayconfigured with request builders, response handlers and transfer clientGlobalPaymentsPaymentGatewayAuthorizationRequest- Composite of request parts used for AuthorizationGlobalPaymentsPaymentGatewayResponseHandlerComposite- Composite\List of response handlers.
Installation
This module is intended to be installed using composer. After including this component and enabling it, you can verify it is installed by going the backend at: STORES -> Configuration -> ADVANCED/Advanced -> Disable Modules Output Once there check that the module name shows up in the list to confirm that it was installed correctly.
Tests
Unit tests could be found in the Test/Unit directory.
Contributors
Magento Core team
License
cool-studio/globalpayments-magento2 适用场景与选型建议
cool-studio/globalpayments-magento2 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 129 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 09 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 cool-studio/globalpayments-magento2 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cool-studio/globalpayments-magento2 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 129
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-09-12