Coder Social home page Coder Social logo

stwinnie / laravel-paypal Goto Github PK

View Code? Open in Web Editor NEW

This project forked from srmklive/laravel-paypal

0.0 1.0 0.0 577 KB

Laravel plugin for processing payments through PayPal. Can be used separately.

Home Page: https://laravel-paypal-demo.srmk.info/

License: MIT License

PHP 100.00%

laravel-paypal's Introduction

Laravel PayPal

Software License Latest Version on Packagist Total Downloads StyleCI Tests Coverage Status Code Quality

Introduction

By using this plugin you can process or refund payments and handle IPN (Instant Payment Notification) from PayPal in your Laravel application.

This plugin supports the new paypal rest api.

PayPal API Credentials

This package uses the new paypal rest api. Refer to this link on how to create API credentials:

https://developer.paypal.com/docs/api/overview/

Installation

  • Use following command to install:
composer require srmklive/paypal:~3.0

To use this package for Laravel 5.1 to 5.8 use the following commands

composer require srmklive/paypal:~2.0
  • Run the following command to publish configuration:
php artisan vendor:publish --provider "Srmklive\PayPal\Providers\PayPalServiceProvider"

Configuration

  • After installation, you will need to add your paypal settings. Following is the code you will find in config/paypal.php, which you should update accordingly.
return [
    'mode'    => env('PAYPAL_MODE', 'sandbox'), // Can only be 'sandbox' Or 'live'. If empty or invalid, 'live' will be used.
    'sandbox' => [
        'client_id'         => env('PAYPAL_SANDBOX_CLIENT_ID', ''),
        'client_secret'     => env('PAYPAL_SANDBOX_CLIENT_SECRET', ''),
        'app_id'            => 'APP-80W284485P519543T',
    ],
    'live' => [
        'client_id'         => env('PAYPAL_LIVE_CLIENT_ID', ''),
        'client_secret'     => env('PAYPAL_LIVE_CLIENT_SECRET', ''),
        'app_id'            => '',
    ],

    'payment_action' => env('PAYPAL_PAYMENT_ACTION', 'Sale'), // Can only be 'Sale', 'Authorization' or 'Order'
    'currency'       => env('PAYPAL_CURRENCY', 'USD'),
    'notify_url'     => env('PAYPAL_NOTIFY_URL', ''), // Change this accordingly for your application.
    'locale'         => env('PAYPAL_LOCALE', 'en_US'), // force gateway language  i.e. it_IT, es_ES, en_US ... (for express checkout only)
    'validate_ssl'   => env('PAYPAL_VALIDATE_SSL', true), // Validate SSL when creating api client.
];
  • Add this to .env.example and .env
#PayPal Setting & API Credentials - sandbox
PAYPAL_SANDBOX_CLIENT_ID=
PAYPAL_SANDBOX_CLIENT_SECRET=

#PayPal Setting & API Credentials - live
PAYPAL_LIVE_CLIENT_ID=
PAYPAL_LIVE_CLIENT_SECRET=

Usage

Following are some ways through which you can access the paypal provider:

// Import the class namespaces first, before using it directly
use Srmklive\PayPal\Services\PayPal as PayPalClient;

$provider = new PayPalClient;

// Through facade. No need to import namespaces
$provider = PayPal::setProvider();

Override PayPal API Configuration

You can override PayPal API configuration by calling setApiCredentials method:

$provider->setApiCredentials($config);

Set Currency

By default the currency used is USD. If you wish to change it, you may call setCurrency method to set a different currency before calling any respective API methods:

$provider->setCurrency('EUR')->setExpressCheckout($data);

Support

This version supports Laravel 6 or greater.

  • In case of any issues, kindly create one on the Issues section.
  • If you would like to contribute:
    • Fork this repository.
    • Implement your features.
    • Generate pull request.

laravel-paypal's People

Contributors

matheusbenedet avatar srmklive avatar

Watchers

 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.