2017 © Pedro Peláez
 

library verify-paypal

PHP class to verify Paypal SDK payments, it verifies both credit card and paypal account transactions using the REST API and Adaptive Payments.

image

redfro/verify-paypal

PHP class to verify Paypal SDK payments, it verifies both credit card and paypal account transactions using the REST API and Adaptive Payments.

  • Thursday, July 31, 2014
  • by redfro
  • Repository
  • 2 Watchers
  • 1 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

VerifyPaypal

VerifyPaypal is a PHP class to verify Paypal SDK payments, it verifies both credit card and paypal account transactions using the REST API and Adaptive Payments., (*1)

Known Issues

Paypal is currently having an issue with the Rest API in sandbox mode. Testing a credit card will result in an Invalid Resourse ID error. Hopefully this gets fixed soon., (*2)

Getting Started

  • Start by cloning VerifyPaypal into your project:
git clone https://github.com/redfro/VerifyPaypal.git
  • Next, provided you have composer installed, run the following command:
$ php composer.phar install
  • This will install the library into a vendor folder. Now add the autoloader to your php files where applicable.
require 'VerifyPaypal/vendor/autoload.php';
  • You need to use the PaypalPayment class, so add this directly under the autoloader.
use VerifyPaypal\Classes\PaypalPayment;
  • Now update VerifyPaypalConfig.php (src/VerifyPaypal/Config/VerifyPaypalConfig.php) with your paypal information:
/*==========  Live Credentials  ==========*/

define('CLIENT_ID', '');
define('SECRET_KEY', '');
define('PAYPAL_ID', '');
define('PAYPAL_PW', '');
define('PAYPAL_SIG', '');
define('RECEIVER_EMAIL', '');

/*==========  Sandbox Credentials  ==========*/

define('CLIENT_ID_SANDBOX', '');
define('SECRET_KEY_SANDBOX', '');
define('PAYPAL_ID_SANDBOX', '');
define('PAYPAL_PW_SANDBOX', '');
define('PAYPAL_SIG_SANDBOX', '');
define('RECEIVER_EMAIL_SANDBOX', '');
  • Create a new PaypalPayment() and set the environment to either "sandbox" or "live":
$payment = new PaypalPayment("sandbox");
  • Pass the JSON sent from the Paypal SDK into verify():
$payment->verify($json);

The verify() method returns true if the payment is valid, false if not., (*3)

  • You can check the status returned from Paypal using:
$payment->getStatus();

Example

require 'vendor/autoload.php';
use VerifyPaypal\Classes\PaypalPayment;

$payment = new PaypalPayment("sandbox");
$validPayment = $payment->verify($json);

if ($validPayment)
{
    // do something with valid payment
}

echo $payment->getStatus();  // check status message from paypal

Testing

You can test if VerifyPaypal is installed correctly by running the following command., (*4)

$ php tests/test.php

This should return "VerifyPaypal was installed correctly!"., (*5)

License

VerifyPaypal is licensed under the MIT license. See the LICENSE file for more details., (*6)

The Versions

31/07 2014

dev-master

9999999-dev

PHP class to verify Paypal SDK payments, it verifies both credit card and paypal account transactions using the REST API and Adaptive Payments.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Chris Hustman