Download the PHP package krzysztof-gzocha/payu without Composer
On this page you can find all versions of the php package krzysztof-gzocha/payu. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download krzysztof-gzocha/payu
More information about krzysztof-gzocha/payu
Files in krzysztof-gzocha/payu
Package payu
Short Description Integration with PayU
License MIT
Homepage https://github.com/krzysztof-gzocha/payu
Informations about the package payu
PayU Integration
This library written in PHP will allow easily integration with PayU API v2.1.
Works with PHP version >=5.4 and HHVM.
Installation by composer
To install this library simply add requirement to composer.
You can do this by
or simply add this to composer.json:
and run
Basic usage
1. Configuration
Default configuration's object is , but any object that implements will do the job. Most of the configuration parameters are already defined, you only have to set credentials (merchant ID and private key) taken from PayU. Test account credentials are already defined in , so if you just want to test the appllication you can use this class.
Configuration with test credentials:
Configuration with real credentials:
2. Create basic order object
Please remember that orders created by those examples are not configured enough. Some required parameters like OpenPayU-Signature, totalAmount, customerIp, etc are still missing. You can add them automatically, but it will be described in another chapter. Both examples are describing the most basic configuration. Order created by both examples are equal.
2.1 Using order object from library
Order object in this library is by default represented by , but anything that implements will work. This chapter is about creating this object, but if you are integrating this library with currently working application you can do this work automatically with annotations described in chapter below.
Example order with single product:
2.2 Using annotations
You don't need to create another order object if you already have one in your application. You will just have to put single annotation on methods that returns useful parameters. Lets say you have your own order class called and product class called . Annotation can be set on public, protected or private methods. You can add annotation in presented way:
All property names can be found at . It's worth to mention that one of the annotation is especially useful in complicated architecture. It's called annotation. If you have to collect required parameters from different, connected entities you can use this annotation. Result of this method will be passed through this transformer again.
Now to create order object you have to use UserOrderTransfomer, which will literally transform your's object for library purposes. To do so you can use this example:
3. Order parameters auto-completion
You are not left alone when it comes to fulfill other required parameters like signature. To do so you can use this code:
4. Inform PayU about new order
To inform PayU about our new order you have to send OrderCreateRequest with correctly build object, check HTTP status code of the response, deserialize the response to OrderCreateResponse object, check if request status is and redirect user to given URL. Here is an example how to use RequestProcess:
5. Retrieve order from PayU
Retrieving info is similar process to creating new order. You can use the same RequestProcess, but with different Request object. Example:
6. Order cancel request
You can send to PayU request that will say "cancel this order". To do so you can use RequestProcess described above. If you will pass to it and object of and initialize it with with parameter then you will cancel the order. In this case RequestProcess will return . You can see it's parameters in documentation. Please note that parameter is status of the request, not order!
7. Process notification about order
PayU can inform you about any changes in your order. To use this mechanism you simply need to define . PayU will send notification directly to this URL. In action defined in notify URL you have to parse JSON string of the notification and check for the order status. To do so you can use NotificationProcess.
Important
Please note that PayU will send notification in asynchronous way, so when you will receive notification about completing or cancelling order then you should ignore all later notifications.
Running tests
To run tests locally you have to install the library via composer with parameter. This will install Codeception framework which is helping with unit tests. Codeception is using helpers, but they are not in this library. You can build them by using - now you are all set. Now you can use to run unit tests or to generate code coverage report. This library was built using Phing so you can use or .
Actual code coverage report can be found at krzysztof-gzocha.github.io/payu/coverage.
Contributing
All pull requests are welcome and appreciated :)
License
License MIT available in license.txt.
All versions of payu with dependencies
jms/serializer Version >=0.11.0
symfony/validator Version >=2.0.4
psr/log Version 1.0.*@dev
php Version >=5.4.0
ext-curl Version *
kriswallsmith/buzz Version 0.13