mothership-ec / cog-mothership-ecommerce
Cog module for processing E-Commerce in Mothership
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
Configuration
Dispatch
- printer-name: ...
Payment
- gateway: Name of gateway to use. Note the gateway must be available to the system.
- use-test-payments: Use the test environment of external payment gateways.
- salt: Used when hashing data in the payment processes.
Gateways
Payment gateways allow you to process payments through an external service.
There are two components to a gateway within mothership; an implementation of Gateway\GatewayInterface
to communicate with the external service, and controllers to handle purchase and refund requests.
Default gateways
ZeroPayment
The zero payment gateway is the most basic implementation, it simply completes the order and redirects straight to the success url.
LocalPayment
The local payment gateway is an extension of zero payment.
Extending with new gateway providers
To add a new gateway provider you'll need to create a new adapter that implements Gateway\GatewayInterface
and append it to the gateway.collection
service.
Secondly you'll need to implement the Controllers\Gateway\PurchaseControllerInterface
and Controllers\Gateway\RefundControllerInterface
. If your new gateway does not support refunds then the refund()
method should just return $this->createNotFoundException()
.
Of course your gateway and controller(s) can use additional methods for handling the specific functionality and process flow for the new provider, such as callbacks from the external service.
Purchases
A purchase process is a system which sends a payment request to a gateway and creates / modifies an object on a success response and reacts accordingly to cancelled and failed purchases. For example, the standard checkout process which on success saves the order to the database and records the payment against it.
When writing a new purchase process the 'continue to payment' action should forward the request to the current gateway's purchase controller reference using $this->get('gateway')->getPurchaseControllerReference()
.
This forward request should pass the instance of PayableInterface
that is being purchased and the stages configuration.
$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 ] ]);
The purchase process requires a controller that implements Controllers\Gateway\CompleteControllerInterface
. This should implement the success
, cancel
and failure
methods.
The success()
method should turn the payable into a saved instance of the object it represents, e.g. an order, store any payments as necessary and return a success url in a JsonResponse
. This completion process should be called by the gateway purchase controller when confirming the purchase with the external provider.
Refunds
A refund process works in the same way as a purchase purchase, except you forward the request to $this->get('gateway')->getRefundControllerReference()
and pass an additional reference
parameter. The cancel
stage is not required for refunds.
$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 ] ]);