GithubHelp home page GithubHelp logo

botnik / verifypaypal Goto Github PK

View Code? Open in Web Editor NEW
3.0 4.0 4.0 128 KB

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

License: MIT License

PHP 100.00%

verifypaypal's Introduction

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.

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.

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.

  • 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.

$ php tests/test.php

This should return "VerifyPaypal was installed correctly!".

License

VerifyPaypal is licensed under the MIT license. See the LICENSE file for more details.

verifypaypal's People

Contributors

hustmandotcom avatar

Stargazers

 avatar lccmorales avatar Ming avatar

Watchers

James Cloos avatar Chris Hustman avatar wan hussin abdul rahman avatar Lenlencatalan avatar

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.