A PayPal IPN (Instant Payment Notification) listener for PHP, кэшбэк ipn

A PayPal IPN (Instant Payment Notification) listener for PHP



A PayPal IPN (Instant Payment Notification) listener for PHP





A PayPal IPN (Instant Payment Notification) listener for PHP



Prerequisites


PHP >=5.6.0 A good understanding of how the PayPal Instant Payment Notification system works. See https://developer. paypal. com/webapps/developer/docs/classic/ipn/integration-guide/IPNIntro/

Installation



Architecture



This package is made up of several components that work together:




    Listener – Listens for and processes the IPN messages Verifier – Verifies the IPN message with PayPal Service – Communicates with PayPal Message – Wrapper around the IPN message MessageFactory – Creates a new message instance from a data source EventDispatcher – Dispatches events



The listener creates a Message using a MessageFactory. The Message is passed to the Verifier which uses a Service to communicate with PayPal. The Listener uses the EventDispatcher to dispatch events relating to the outcome of the IPN message verification.



The MessageFactory and Service components are swappable components.



This package provides 2 message factories:



MdbPayPalIpnMessageFactoryInputStreamMessageFactory – Creates a message from the php://input stream MdbPayPalIpnMessageFactoryArrayMessageFactory – Creates a message from an array passed to the setData method



This package provides 1 service:



MdbPayPalIpnServiceGuzzleService – Uses Guzzle to communicate with PayPal



You can either build up the listener object manually or you can use a listener builder. This package provides 2 listener builders:



MdbPayPalIpnListenerBuilderGuzzleInputStreamListenerBuilder – Builds a listener using the guzzle service and the input stream message factory MdbPayPalIpnListenerBuilderGuzzleArrayListenerBuilder – Builds a listener using the guzzle service and the array message factory



Using a listener builder is the preferred way of building up a listener object.



Using a listener builder



Building up the listener manually



A lot of plumbing is needed to create the listener manually. The job of the listener builder is to abstract away this logic.



Subscribing to events



Once you have created the listener object you can subscribe to the events that it will dispatch:



You can use any callable when subscribing to an event:



Listening for IPN messages



The last thing you need to do to kick of the process is listen for an IPN message:



Full Example



Sandbox mode



When using one of the provided listener builders you can set your listener to use PayPal’s sandbox for testing purposes:



You can find some full usage examples in the examples directory.



To create your own service you must implement MdbPayPalIpnService.



To create your own message factory you must implement MdbPayPalIpnMessageFactory.



To create your own listener builder it is best to extend MdbPayPalIpnListenerBuilder as this provides most of the boilerplate code needed to create a listener builder.



You will notice that when using any of the provided guzzle listener builders that there is a useSandbox method exposed. You can add this functionality to your listener builder by using the MdbPayPalIpnListenerBuilderModeDependentServiceEndpoint trait (see MdbPayPalIpnListenerBuilderGuzzleListenerBuilder for usage example).

Комментарии

Популярные сообщения из этого блога

Альфа Банк кэшбэк по кредитной и дебетовой карте условия, отзывы, альфа кэшбэк дебетовая

Dns Cash Back - Скачать или слушать бесплатно в mp3, cash back dns