Payment gateway
Payment gateway designed with forex in mind. Currently work in progres..., (*1)
Installation with composer:, (*2)
composer require twodudes\fxpay
The system consists of:, (*3)
MerchantConfig - stores the merchant configuration for the given vendor, (*4)
HandlerStrategy - describes the strategy of dealing with the vendor, (*5)
PaymentRequest - stores the request parameters, you want to send to the vendor, (*6)
RequestBuilder - builds the array of parameters, needed to be passed to the vendor, (*7)
ResponseValidator - validates the response, based on the merchants rules, (*8)
ResponseBuilder - builds the payment response object, containing information about the transaction, once you got the merchant notification from the vendors system, (*9)
For the workflow check the TwoDudes\FXPay\HandlerStrategy\FormWithRedirectStrategy, (*10)
Check the tests, (*11)
There is a build in events system. You can use the built in event manager (the simpliest possible), or include your own one, if you want, (*12)
$this->strategy = new FormWithRedirectStrategy($config); $this->strategy->setEventManager(new EventManager());
If you want your custom event manager, just make sure, that it implements the TwoDudes\FXPay\Events\EventManagerInterface, (*13)
Creating Request:, (*14)
AfterRequestBuildEvent - fires, once the request builder built the params to generate the form. Here you can modify the generated params, (*15)
AfterFormBuildEvent - fires, once the html content with the hidden form was built. Here you can modify the form html., (*16)
Processing response:, (*17)
BeforeProcessResponseEvent - fires before any processing took place., (*18)
AfterBuildVendorResponseEvent - fires in the very end, once the VendorResponse is ready., (*19)
$this->strategy->getEventManager()->attach(BeforeProcessResponseEvent::getName(), function(BeforeProcessResponseEvent $event) { $params = $event->getParams(); ... do something with the params ... $event->setParams($params); });