Skip to content
Reza Shadman edited this page Dec 14, 2015 · 4 revisions

#What is this repo? Persian payment gateways is an unofficial protocol for working with payment gateway providers in Iran, and this repo is an PHP implementation of it, there would be other implementations in Javascript, Python and Ruby, soon!

##What can it do?

  • Ready-to-go modules for known providers (Zarinpal, Payline, Saman, Pasargad etc.)
  • Sugar protocol, hides details for working with different providers.
  • Extendable design, extra providers can be added by implementing only 2 methods of the provider contract(interface).
  • Failure surviving by swapping providers when they fail(pings them before connect).
  • Supports both RESTful and SOAP providers.

##Terminology

###Providers Providers are our external payment handlers like Zarinpal, Saman, Payline etc.

###Pinging In the context of this repo, pinging is the action of making request to the needed provider to ensure it is alive.

###Provider swapping If given provider fails during pinging process(Unsuccessful request to the given ping url in config), you have the option by automatically replace it by another provider, for example if Zarinpal provider dies you have the option to replace it by Saman provider.

###Payment Request In the context of this repo, a payment request is a request from your application to the provider endpoint for bootstrapping a new payment, the endpoint will then send a response which contains info for further actions.

###Payment Request Payload Your payment request should contain a payload which allows you track your payment after user redirected back to your website from the payment provider. Each request has these main keys:

###Verifying request You should define a route that handles your return url,the first thing you should do inside your route handler is to verify that it is for the requested payment, to do you need to call the verify method on the provider instance, that's it if it returns true you can go ahead and make the order completed or if it throws an exception you mark the order as incomplete or what strategy you like.

###GatewayManager class Gateway manager acts like a facade (and also a factory) around the features you have, it instantiates new providers for you, allows you to subscribe on gateway events, etc.

###Examples See examples folder for more details.

Clone this wiki locally