# Laravel PayPal
[](LICENSE.md)
[](https://packagist.org/packages/srmklive/paypal)
[](https://packagist.org/packages/srmklive/paypal)
[](https://github.styleci.io/repos/43671533?branch=v2.0)

[](https://coveralls.io/github/srmklive/laravel-paypal?branch=v3.0)
[](https://scrutinizer-ci.com/g/srmklive/laravel-paypal/?branch=v3.0)
- [Documentation](#introduction)
- [Usage](#usage)
- [Support](#support)
<a name="introduction"></a>
## Documentation
The documentation for the package can be viewed by clicking the following link:
[https://laravel-paypal.readthedocs.io/en/latest/](https://laravel-paypal.readthedocs.io/en/latest/)
The old documentation can be found at the following link:
[https://srmklive.github.io/laravel-paypal/docs.html](https://srmklive.github.io/laravel-paypal/docs.html)
<a name="usage"></a>
## Usage
Following are some ways through which you can access the paypal provider:
```php
// 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();
```
<a name="usage-paypal-api-configuration"></a>
## Configuration File
The configuration file **paypal.php** is located in the **config** folder. Following are its contents when published:
```php
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' => env('PAYPAL_LIVE_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.
];
```
## Override PayPal API Configuration
You can override PayPal API configuration by calling `setApiCredentials` method:
```php
$config = [
'mode' => 'live',
'live' => [
'client_id' => 'PAYPAL_LIVE_CLIENT_ID',
'client_secret' => 'PAYPAL_LIVE_CLIENT_SECRET',
'app_id' => 'PAYPAL_LIVE_APP_ID',
],
'payment_action' => 'Sale',
'currency' => 'USD',
'notify_url' => 'https://your-site.com/paypal/notify',
'locale' => 'en_US',
'validate_ssl' => true,
];
$provider->setApiCredentials($config);
```
<a name="usage-paypal-get-access-token"></a>
## Get Access Token
After setting the PayPal API configuration by calling `setApiCredentials` method. You need to get access token before performing any API calls
```php
$provider->getAccessToken();
```
<a name="usage-currency"></a>
## 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:
```php
$provider->setCurrency('EUR');
```
<a name="usage-helpers"></a>
## Helper Methods
> Please note that in the examples below, the call to `addPlanTrialPricing` is optional and it can be omitted when you are creating subscriptions without trial period.
> `setReturnAndCancelUrl()` is optional. If you set urls you have to use real domains. e.g. localhost, project.test does not work.
### Create Recurring Daily Subscription
```php
$response = $provider->addProduct('Demo Product', 'Demo Product', 'SERVICE', 'SOFTWARE')
->addPlanTrialPricing('DAY', 7)
->addDailyPlan('Demo Plan', 'Demo Plan', 1.50)
->setReturnAndCancelUrl('https://example.com/paypal-success', 'https://example.com/paypal-cancel')
->setupSubscription('John Doe', 'john@example.com', '2021-12-10');
```
### Create Recurring Weekly Subscription
```php
$response = $provider->addProduct('Demo Product', 'Demo Product', 'SERVICE', 'SOFTWARE')
->addPlanTrialPricing('DAY', 7)
->addWeeklyPlan('Demo Plan', 'Demo Plan', 30)
->setReturnAndCancelUrl('https://example.com/paypal-success', 'https://example.com/paypal-cancel')
->setupSubscription('John Doe', 'john@example.com', '2021-12-10');
```
### Create Recurring Monthly Subscription
```php
$response = $provider->addProduct('Demo Product', 'Demo Product', 'SERVICE', 'SOFTWARE')
->addPlanTrialPricing('DAY', 7)
->addMonthlyPlan('Demo Plan', 'Demo Plan', 100)
->setReturnAndCancelUrl('https://example.com/paypal-success', 'https://example.com/paypal-cancel')
->setupSubscription('John Doe', 'john@example.com', '2021-12-10');
```
### Create Recurring Annual Subscription
```php
$response = $provider->addProduct('Demo Product', 'Demo Product', 'SERVICE', 'SOFTWARE')
->addPlanTrialPricing('DAY', 7)
->addAnnualPlan('Demo Plan', 'Demo Plan', 600)
->setReturnAndCancelUrl('https://example.com/paypal-success', 'https://example.com/paypal-cancel')
->setupSubscription('John Doe', 'john@example.com', '2021-12-10');
```
### Create Recurring Subscription with Custom Intervals
```php
$response = $provider->addProduct('Demo Product', 'Demo Product', 'SERVICE', 'SOFTWARE')
->addCustomPlan('Demo Plan', 'Demo Plan', 150, 'MONTH', 3)
->setReturnAndCancelUrl('https://example.com/paypal-success', 'https://example.com/paypal-cancel')
->setupSubscription('John Doe', 'john@example.com', '2021-12-10');
```
### Create Subscription by Existing Product & Billing Plan
```php
$response = $this->client->addProductById('PROD-XYAB12ABSB7868434')
->addBillingPlanById('P-5ML4271244454362WXNWU5NQ')
->setReturnAndCancelUrl('https://example.com/paypal-success', 'https://example.com/paypal-cancel')
->setupSubscription('John Doe', 'john@example.com', $start_date);
```
<a name="support"></a>
## Support
This version supports Laravel 6 or greater.
* In case of any issues, kindly create one on the [Issues](https://github.com/srmklive/laravel-paypal/issues) section.
* If you would like to contribute:
* Fork this repository.
* Implement your features.
* Generate pull request.
The Future of Digital Wallets: How Mobile Payments are Shaping the Financial Landscape
Digital wallets have fundamentally transformed how we manage money, offering a streamlined, secure, and highly efficient method for handling payments and transactions. By consolidating credit, debit, and loyalty card information into a single app, digital wallets simplify the payment process and eliminate the need for physical cards, enhancing both convenience and security. As digital wallets evolve, they are integrating advanced features that push the boundaries of traditional payment methods. Biometric authentication, such as fingerprint and facial recognition, adds an extra layer of security, ensuring that only authorized users can access their payment information. Real-time transaction alerts provide instant notifications for every transaction, allowing users to monitor their spending and detect any unauthorized activity swiftly. Budgeting tools within digital wallets offer personalized insights and financial management capabilities, helping users track their expenses and plan their budgets more effectively. The growing adoption of digital wallets is fueled by their ease of use and the increasing demand for contactless payment solutions. As technology advances, digital wallets are likely to incorporate even more innovative features, such as artificial intelligence for personalized financial advice, integrated loyalty programs for seamless rewards management, and cross-border transaction capabilities for global shopping convenience. The integration of these features is reshaping the financial landscape by making transactions not only faster but also more secure and user-friendly. The future of digital wallets is set to further revolutionize how we handle our finances, offering an all-encompassing solution that caters to the evolving needs of modern consumers. As digital wallets continue to advance, they will play an increasingly central role in shaping the future of financial interactions, driving the global shift towards a more digital and cashless economy.
In the digital age, privacy concerns have become increasingly paramount, prompting the European Union to enact the General Data Protection Regulation (GDPR) in 2018. Among its many provisions, GDPR sets strict guidelines for the collection and processing of personal data, including the use of cookies on websites. Privacy Policy