mothership-ec / cog-mothership-ecommerce
Mothership中的E-Commerce处理Cog模块
Requires
- php: >=5.4.0
- mothership-ec/cog: ~4.10
- mothership-ec/cog-mothership-cms: ~4.13
- mothership-ec/cog-mothership-commerce: ~5.17
- mothership-ec/cog-mothership-cp: ~3.0
- mothership-ec/cog-mothership-user: ~4.0
- omnipay/common: ~2.0
Requires (Dev)
- mockery/mockery: ~0.9
Suggests
- mothership-ec/cog-mothership-stripe: The Stripe gateway integration for Mothership
- dev-develop
- 3.8.0
- 3.7.3
- 3.7.2
- 3.7.1
- 3.7.0
- 3.6.1
- 3.6.0
- 3.5.1
- 3.5.0
- 3.4.0
- 3.3.1
- 3.3.0
- 3.2.1
- 3.2.0
- 3.1.2
- 3.1.1
- 3.1.0
- 3.0.5
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 2.8.1
- 2.8.0
- 2.7.0
- 2.6.2
- 2.6.1
- 2.6.0
- 2.5.1
- 2.5.0
- 2.4.1
- 2.4.0
- 2.3.0
- 2.2.1
- 2.2.0
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.0
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.7
- 1.2.6
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-master
- dev-feature/validate-email
- dev-fulfillment-button-fix
- dev-revert-250-feature/product-page-tab
- dev-feature/product-page-create
- dev-user-form
- dev-feature/product-filtering
- dev-feature/save-documents
- dev-feature/delivery-note
- dev-feature/view-namespacing
- dev-feature/2.8.1
- dev-feature/product-selector
- dev-feature/fulfillment-titles
- dev-feature/too-many-items-in-fulfillment
- dev-release/2.2.2
- dev-feature/default-view-updates
- dev-feature/lazy-loading
- dev-feature/ajax-update
- dev-feature/add-ms-option
- dev-feature/delivery-note-w-stickers
- dev-compatibility/uniform-wares
- dev-feature/checkout-confirm-images
- dev-feature/image-loading-bugfix
- dev-compatibility/demo-dashboards
- dev-feature/checkout-refactor
- dev-feature/447-add-item-cancelled-status
- dev-mob-refactoring/gateways
- dev-feature/refactor-order-assembler
- dev-ux/improvements
- dev-checkout-progress
This package is not auto-updated.
Last update: 2021-03-22 11:07:42 UTC
README
配置
分发
- 打印机名称: ...
支付
- gateway:要使用的网关名称。注意该网关必须对系统可用。
- use-test-payments:使用外部支付网关的测试环境。
- salt:在支付过程中对数据进行散列时使用。
网关
支付网关允许您通过外部服务处理支付。
在Mothership中,网关有两个组件;一个是实现Gateway\GatewayInterface
的实现,用于与外部服务通信,另一个是处理购买和退款请求的控制器。
默认网关
ZeroPayment
零支付网关是最基本的实现,它仅完成订单并直接重定向到成功URL。
LocalPayment
本地支付网关是零支付的扩展。
使用新的网关提供商扩展
要添加新的网关提供商,您需要创建一个新的适配器,该适配器实现Gateway\GatewayInterface
并将其附加到gateway.collection
服务。
其次,您需要实现Controllers\Gateway\PurchaseControllerInterface
和Controllers\Gateway\RefundControllerInterface
。如果您的网关不支持退款,则应将refund()
方法返回$this->createNotFoundException()
。
当然,您的网关和控制器可以使用额外的处理新提供商特定功能和流程的方法,例如外部服务的回调。
购买
购买过程是一个系统,它向网关发送支付请求,并在成功响应中创建/修改对象,并对已取消和失败的购买做出相应反应。例如,标准结账流程在成功时将订单保存到数据库并记录其付款。
当编写新的购买过程时,'继续支付'操作应使用$this->get('gateway')->getPurchaseControllerReference()
将请求转发到当前网关的购买控制器引用。
此转发请求应传递正在购买的PayableInterface
实例和阶段配置。
$controller = 'Message:Mothership:Foo::Controller:Bar'; return $this->forward($this->get('gateway')->getPurchaseControllerReference(), [ 'payable' => $instanceOfPayableInterface, 'stages' => [ 'cancel' => $controller . '#cancel', // Method for reacting to cancelled purchases 'failure' => $controller . '#failure', // Method for reacting to failed purchases 'success' => $controller . '#success', // Method for reacting to successful purchases ] ]);
购买过程需要一个实现Controllers\Gateway\CompleteControllerInterface
的控制器。这应该实现success
、cancel
和failure
方法。
success()
方法应将可支付对象转换为它所表示的对象的已保存实例,例如订单,根据需要存储任何付款,并返回一个 JsonResponse
中的成功 URL。此完成过程应在通过外部提供商确认购买时由网关购买控制器调用。
退款
退款过程与购买过程相同,除了您需要将请求转发到 $this->get('gateway')->getRefundControllerReference()
并传递一个额外的 reference
参数。退款不需要 cancel
阶段。
$controller = 'Message:Mothership:Foo::Controller:Bar'; return $this->forward($this->get('gateway')->getRefundControllerReference(), [ 'payable' => $instanceOfPayableInterface, 'reference' => 'reference for the payment made previously being refunded', 'stages' => [ 'failure' => $controller . '#failure', // Method for reacting to failed refunds 'success' => $controller . '#success', // Method for reacting to successful refunds ] ]);