Giter Site home page Giter Site logo

sudiptpa / paypal-ipn Goto Github PK

View Code? Open in Web Editor NEW
10.0 2.0 11.0 40 KB

PayPal IPN (Instant Payment Notification) handling PHP library. PayPal NVP/SOAP API integration guide following the article, and learn more.

Home Page: https://sujipthapa.co/blog/paypal-instant-payment-notification-ipn-handling-with-laravel

License: MIT License

PHP 100.00%
php paypal-ipn api nvp paypal paypal-api paypal-checkout paypal-express-checkout paypal-payment-gateway soap

paypal-ipn's Introduction

PayPal IPN

PayPal Instant Payment Notification Listener driver for PHP

StyleCI Build Status Latest Stable Version Total Downloads License

Requirements

This package requires PHP >=5.5

Installation

This package is installed via Composer. To install, simply add it to your composer.json file:

  composer require sudiptpa/paypal-ipn

If you really need to work on guzzle 5.* pull version below.

  composer require sudiptpa/paypal-ipn:1.0.x-dev

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 by passing array of Data

  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

  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.

Testing

PayPal provide an Instant Payment Notification (IPN) simulator here: 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]

If you believe you have found a bug, please report it using the GitHub issue tracker, or better yet, fork the library and submit a pull request.

License

This package is open-sourced software licensed under the MIT license.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.