-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8a5eea0
Showing
29 changed files
with
879 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_style = space | ||
insert_final_newline = true | ||
indent_size = 2 | ||
trim_trailing_whitespace = true | ||
|
||
[*.php] | ||
indent_size = 4 | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/vendor/ | ||
/bin/ | ||
composer.lock | ||
composer.phar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
$finder = Symfony\CS\Finder\DefaultFinder::create() | ||
->in(__DIR__ . '/src'); | ||
|
||
return Symfony\CS\Config\Config::create() | ||
->finder($finder) | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
language: php | ||
|
||
php: | ||
- 5.5 | ||
- 5.6 | ||
|
||
before_script: | ||
- composer install -n --dev --prefer-source | ||
|
||
script: vendor/bin/php-cs-fixer fix --dry-run --verbose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2016 | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
# PayPal IPN | ||
|
||
**PayPal Instant Payment Notification Listener driver for PHP** | ||
|
||
[![StyleCI](https://styleci.io/repos/77810461/shield?branch=master)](https://styleci.io/repos/77810461) | ||
[![Build Status](https://travis-ci.org/sudiptpa/paypal-ipn.svg?branch=master)](https://travis-ci.org/sudiptpa/paypal-ipn) | ||
[![Latest Stable Version](https://poser.pugx.org/sudiptpa/paypal-ipn/v/stable)](https://packagist.org/packages/sudiptpa/paypal-ipn) | ||
[![Total Downloads](https://poser.pugx.org/sudiptpa/paypal-ipn/downloads)](https://packagist.org/packages/sudiptpa/paypal-ipn) | ||
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/sudiptpa/paypal-ipn/master/LICENSE) | ||
|
||
## Requirements | ||
This package requires PHP >=5.5 | ||
|
||
## Installation | ||
|
||
This package is installed via [Composer](http://getcomposer.org/). To install, simply add it | ||
to your `composer.json` file: | ||
|
||
```json | ||
{ | ||
"require": { | ||
"sudiptpa/paypal-ipn": "~2.0" | ||
} | ||
} | ||
``` | ||
And run composer to update your dependencies: | ||
|
||
$ curl -s http://getcomposer.org/installer | php | ||
$ php composer.phar update | ||
|
||
## Basic Usage | ||
|
||
The following are 2 different methods provided by the package to handle PayPal IPN. | ||
|
||
### Using ArrayListener with by passing array of Data | ||
```php | ||
require __DIR__.'/vendor/autoload.php'; | ||
|
||
use PayPal\IPN\Event\IPNInvalid; | ||
use PayPal\IPN\Event\IPNVerificationFailure; | ||
use PayPal\IPN\Event\IPNVerified; | ||
use PayPal\IPN\Listener\Http\ArrayListener; | ||
|
||
$listener = new ArrayListener; | ||
|
||
/* | ||
* Payload received from PayPal end. | ||
*/ | ||
$data = array( | ||
'foo' => 'bar', | ||
'bar' => 'baz', | ||
); | ||
|
||
$listener->setData($data); | ||
|
||
$listener = $listener->run(); | ||
|
||
$listener->onInvalid(function (IPNInvalid $event) { | ||
$ipnMessage = $event->getMessage(); | ||
|
||
// IPN message was was invalid, something is not right! Do your logging here... | ||
}); | ||
|
||
$listener->onVerified(function (IPNVerified $event) { | ||
$ipnMessage = $event->getMessage(); | ||
|
||
// IPN message was verified, everything is ok! Do your processing logic here... | ||
}); | ||
|
||
$listener->onVerificationFailure(function (IPNVerificationFailure $event) { | ||
$error = $event->getError(); | ||
|
||
// Something bad happend when trying to communicate with PayPal! Do your logging here... | ||
}); | ||
|
||
$listener->listen(); | ||
``` | ||
|
||
### Using InputStreamListener | ||
|
||
```php | ||
use PayPal\IPN\Event\IPNInvalid; | ||
use PayPal\IPN\Event\IPNVerificationFailure; | ||
use PayPal\IPN\Event\IPNVerified; | ||
use PayPal\IPN\Listener\Http\InputStreamListener; | ||
|
||
$listener = new InputStreamListener; | ||
|
||
$listener = $listener->run(); | ||
|
||
$listener->onInvalid(function (IPNInvalid $event) { | ||
$ipnMessage = $event->getMessage(); | ||
|
||
// IPN message was was invalid, something is not right! Do your logging here... | ||
}); | ||
|
||
$listener->onVerified(function (IPNVerified $event) { | ||
$ipnMessage = $event->getMessage(); | ||
|
||
// IPN message was verified, everything is ok! Do your processing logic here... | ||
}); | ||
|
||
$listener->onVerificationFailure(function (IPNVerificationFailure $event) { | ||
$error = $event->getError(); | ||
|
||
// Something bad happend when trying to communicate with PayPal! Do your logging here... | ||
}); | ||
|
||
$listener->listen(); | ||
``` | ||
|
||
##Contributing | ||
|
||
Contributions are **welcome** and will be fully **credited**. | ||
|
||
Contributions can be made via a Pull Request on [Github](https://github.com/sudiptpa/paypal-ipn). | ||
|
||
##Testing | ||
|
||
PayPal provide an Instant Payment Notification (IPN) simulator here: [https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNSimulator/](https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNSimulator/) | ||
|
||
## Support | ||
|
||
If you are having general issues with the package, feel free to drop me and email [[email protected]](mailto:[email protected]) | ||
|
||
If you believe you have found a bug, please report it using the [GitHub issue tracker](https://github.com/sudiptpa/paypal-ipn/issues), | ||
or better yet, fork the library and submit a pull request. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# PayPal IPN Log | ||
|
||
## Version 1.0.1 | ||
|
||
- Allow to handle PayPal IPN with InputStreamListener | ||
- Allow to handle PayPal IPN with ArrayListener | ||
- Support for Guzzle 5.* | ||
|
||
## Version 2.0.0 | ||
|
||
- Upgraded to support Guzzle 6.* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"name":"sudiptpa/paypal-ipn", | ||
"type":"library", | ||
"description":"PayPal IPN listener driver for PHP", | ||
"keywords":[ | ||
"paypal", | ||
"ipn" | ||
], | ||
"license":"MIT", | ||
"authors":[ | ||
{ | ||
"name":"Sujip Thapa", | ||
"email":"[email protected]" | ||
} | ||
], | ||
"require":{ | ||
"php": ">=5.5", | ||
"guzzlehttp/guzzle":"6.*", | ||
"symfony/event-dispatcher":"~2.0|~3.0" | ||
}, | ||
"require-dev":{ | ||
"friendsofphp/php-cs-fixer":"~1.0" | ||
}, | ||
"extra":{ | ||
"branch-alias":{ | ||
"dev-master":"2.0.x-dev" | ||
} | ||
}, | ||
"autoload":{ | ||
"psr-4":{ | ||
"PayPal\\IPN\\":"src/" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
require __DIR__.'/vendor/autoload.php'; | ||
|
||
use PayPal\IPN\Event\IPNInvalid; | ||
use PayPal\IPN\Event\IPNVerificationFailure; | ||
use PayPal\IPN\Event\IPNVerified; | ||
use PayPal\IPN\Listener\Http\InputStreamListener; | ||
|
||
$listener = new InputStreamListener(); | ||
|
||
$listener = $listener->run(); | ||
|
||
$listener->onInvalid(function (IPNInvalid $event) { | ||
$ipnMessage = $event->getMessage(); | ||
|
||
file_put_contents('outcome.txt', "INVALID\n\n$ipnMessage"); | ||
}); | ||
|
||
$listener->onVerified(function (IPNVerified $event) { | ||
$ipnMessage = $event->getMessage(); | ||
|
||
file_put_contents('outcome.txt', "VERIFIED\n\n$ipnMessage"); | ||
}); | ||
|
||
$listener->onVerificationFailure(function (IPNVerificationFailure $event) { | ||
$error = $event->getError(); | ||
|
||
file_put_contents('outcome.txt', "VERIFICATION FAILURE\n\n$error"); | ||
}); | ||
|
||
$listener->listen(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace PayPal\IPN\Event; | ||
|
||
class IPNInvalid extends IPNVerification | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace PayPal\IPN\Event; | ||
|
||
use PayPal\IPN\IPNMessage; | ||
use Symfony\Component\EventDispatcher\Event; | ||
|
||
abstract class IPNVerification extends Event | ||
{ | ||
/** | ||
* @var mixed | ||
*/ | ||
private $message; | ||
|
||
/** | ||
* @param Message $message | ||
*/ | ||
public function __construct(IPNMessage $message) | ||
{ | ||
$this->message = $message; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getMessage() | ||
{ | ||
return $this->message; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace PayPal\IPN\Event; | ||
|
||
use PayPal\IPN\IPNMessage; | ||
|
||
class IPNVerificationFailure extends IPNVerification | ||
{ | ||
/** | ||
* @var mixed | ||
*/ | ||
private $error; | ||
|
||
/** | ||
* @param IPNMessage $message | ||
* @param $error | ||
*/ | ||
public function __construct(IPNMessage $message, $error) | ||
{ | ||
$this->error = $error; | ||
|
||
parent::__construct($message); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getError() | ||
{ | ||
return $this->error; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace PayPal\IPN\Event; | ||
|
||
class IPNVerified extends IPNVerification | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace PayPal\IPN\Exception; | ||
|
||
use Exception; | ||
|
||
class ServiceException extends Exception | ||
{ | ||
} |
Oops, something went wrong.