Download the PHP package simplon/payment without Composer
On this page you can find all versions of the php package simplon/payment. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download simplon/payment
More information about simplon/payment
Files in simplon/payment
Package payment
Short Description Flexible solution to enable payments for multiple payment providers.
License MIT
Homepage https://github.com/fightbulc/simplon_payment
Informations about the package payment
_ _ ___(_)_ __ ___ _ __ | | ___ _ __ / __| | '_ ` _ \| '_ \| |/ _ \| '_ \ \__ \ | | | | | | |_) | | (_) | | | | |___/_|_| |_| |_| .__/|_|\___/|_| |_| |_| _ _ __ __ _ _ _ _ __ ___ ___ _ __ | |_ | '_ \ / _` | | | | '_ ` _ \ / _ \ '_ \| __| | |_) | (_| | |_| | | | | | | __/ | | | |_ | .__/ \__,_|\__, |_| |_| |_|\___|_| |_|\__| |_| |___/
Simplon Payment
Version 0.5.8
Intro
Simplon Payment was built to host conform libraries for different payment service provider. At the moment of writing this module consist of two libraries: and . Both libraries were created by applying the Builder Pattern.
Make sure to create test accounts for both libraries. Setting up test accounts for PayPal is really easy.
Skrill is a bit more challenging. The setup for real- and test-accounts is the same. However, in order to activate an account as test-account you need to send an inquiry via email to the support. Include your account number. This takes some time. The easiest and fastest way though would be to contact your Skrill key account manager to handle the setup - provided that you have a key account manager.
Install
You can install Simplon/Payment either via package download from github or via Composer install. I encourage you to do the latter:
Note
This documentation is work in progress. Therefore, in case of any questions have a look in to the code or drop me a message.
PayPal
PayPal's checkout flow consists of three steps:
- Request checkout token (Response: session token)
- Request checkout details (Response: all payment details)
- Request checkout payment (Response: all payment details + transactionId)
Requirements
PayPal demands for a set of authentication credentials which have to be registered with PayPal's Merchant Service. Upon successful registration the following credentials will be available:
- merchant username
- merchant password
- signature
Request checkout token
PayPal requires always authentication which is handled by our class:
Before we can send our request we need a product. This will be created by our class. As you will see we can create more than just one product. All product items will be store in a simple array:
Ok, lets finish this and request the :
We don't get really far with the token alone. We actually need PayPal's store URL:
Alright, this prints an anchor on our page which takes us to PayPal's store where we can enter our data.
Request checkout details
Our next step takes action as soon as the user entered all at PayPal's end. When everything went fine PayPal will call our prior defined with a GET parameter . The script which is behind our should do the following to fetch the :
The holds now all essential data from our call. Have a look at the class to see what else is available. The VO can be extended if necessary.
Request checkout payment
That's the last step in order to finalise the checkout. To run this last request we need three values from our just filled VO :
The order amount and the currency code have to match the values from our initial checkout request. Ok, lets assume we are still in the exact script as for our last example. Now, lets get some money:
If no exception occurs the checkout went through and we received some money. All what is left to conclude a PayPal checkout is to save the response data to a DB so that we have a persistent access.
Sandbox mode
Note that in sandbox mode the only currency accepted is . If you checkout by using another one PayPal will throw exceptions and you will never be able to finalise your test bookings.
Skrill
Skrill's checkout flow has two steps:
- Request checkout token (Response: session token)
- Request checkout payment data (Response: all payment details + transactionId)
Requirements
Skrill requires an active merchant account which will be referenced by the merchant's email address. Also, you need to make sure that all payment methods are activated for your account. Credit cards require a special audit by Skrill.
In order to fetch all final checkout data we need to use Skrill's . For that we need a password which needs to be defined at your merchant account.
Request checkout token
When it comes to authentication Skrill only demands the merchant's email address. As for PayPal we also define our product via the class and cache it to an array:
Before we can request the checkout token we need to define which payment options we would like to offer to our customers. Since Skrill comes with quite some payment options, which differ by country, we need to find a way to easily define them. Well, lets use our again:
Ok, what happened here? First, we create an instance which has all possible payment options for . Then we enable the options , and .
Alright, now that we have all what is needed lets get the respectively the :
As we can see there are a couple of blanks we need to fill in:
- : Redirect URL upon successful data entry on Skrill's page
- : Redirect URL upon cancel on Skrill's page
- : Callback URL upon successful booking. Receives all booking data via POST (optional)
- : Email as defined in your merchant account
If all went fine we should receive a . Redirecting to this url shows Skrill's form page with all required fields.
Upon successful data entry and all confirmations on Skrill's page the user will be redirected to .
Request checkout payment data
If we defined a Skrill will send us all booking data via . From there on its up to us on how to process these data.
Another way would be to set a or via . Skrill will send us all data either to the given or regardless of a transactions success. If you need another callback you can use . Same rules apply as for the prior method.
However, there is yet another alternative which allows us to fetch booking data at any time. For that we have to use the aforementioned in combination with our , and a .
Important note: The is the ID we passed to Skrill. In our example above it would be .
With that example we have finished the checkout cycle for Skrill payments.
Changelog
0.5.5
- Prepare Skrill response status codes
0.5.4
- Added method ()
- Fixed deprecated PayPal response fields for
- Added descriptions for response fields , and (see )