-
Notifications
You must be signed in to change notification settings - Fork 321
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add more tests. * Update build config & refactor tests for v3. * Add functional tests for Reporting API. * Refactor & updated README. * Support PHP 8. * Add PHP 8.0 to build * Url error, remove / (#398) * Refactor tests for PHP 8.0 * Update package for code coverage * Update README.md * Update README.md * Update README.md * Order api implementation and README (#413) Additional order API methods Co-authored-by: Ron Heywood <[email protected]> * Apply fixes from StyleCI (#415) Co-authored-by: Raza Mehdi <[email protected]> * Add CNY currency code (#419) * Fix sample code for create order (#421) * Fix: Scrutinizer-CI Issue for PayPalHttpClient.php (#431) https://scrutinizer-ci.com/g/srmklive/laravel-paypal/issues/v2.0/files/src/Traits/PayPalHttpClient.php?orderField=path&order=asc&honorSelectedPaths=0 * Update Subscriptions capture parameter (#426) * Typo fixed (#427) * Add documentation link * Refactor & fix listPlans API call. * Update date format for listSubscriptionTransactions * Added support for setting a request header. (#446) * Fix CI issues * Adjust QR code size * Refactor invoices search by adding custom filters. * CI fixes and add remaining filter methods for coverage. * Add missing fields filter for search invoices. * Add missing data types. * Update config. * Update function data types and error response. * Update README.md * Implement Identity API. * Update API endpoints & Implement Partner Referral API. * Update initialization flow (fixes #467). * Add configuration checks for API. * Fix CI. * Refactoring. * Apply fixes from StyleCI (#472) * Implement Payment Experience Web Profiles API. * Implement Payouts API. * Implement Referenced Payouts API. * Move API endpoint setup to request call. * Refactor setCurlConstants method. * Add defineCurlConstant method. * Temporarily remove PHP 8.0 from CI. * Remove redundant function call. * Convert boolean to string to fix INVALID_PARAMETER_VALUE for listPlans (#475) * Remove unnecessary header params. * Add custom methods to create recurring monthly/annual subscriptions. (#477) * Add custom method to create recurring weekly subscriptions. (#478) * Add custom method to create recurring daily subscriptions. (#479) * Fix conflicts. * Fix return types and imports. * Fix build. Co-authored-by: vendaagil <[email protected]> Co-authored-by: ronheywood <[email protected]> Co-authored-by: Ron Heywood <[email protected]> Co-authored-by: Raza Mehdi <[email protected]> Co-authored-by: Zelin Ning <[email protected]> Co-authored-by: Raja-Omer-Mustafa <[email protected]> Co-authored-by: Sean <[email protected]> Co-authored-by: Andrei Ristea <[email protected]> Co-authored-by: Dasun Tharanga <[email protected]> Co-authored-by: Jesse Tolj <[email protected]> Co-authored-by: Tom Shaw <[email protected]> Co-authored-by: Jesse Tolj <[email protected]>
- Loading branch information
1 parent
f438a91
commit d79b43a
Showing
86 changed files
with
4,816 additions
and
327 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,9 @@ | |
[![Latest Version on Packagist](https://img.shields.io/packagist/v/srmklive/paypal.svg?style=flat-square)](https://packagist.org/packages/srmklive/paypal) | ||
[![Total Downloads](https://img.shields.io/packagist/dt/srmklive/paypal.svg?style=flat-square)](https://packagist.org/packages/srmklive/paypal) | ||
[![StyleCI](https://github.styleci.io/repos/43671533/shield?branch=v2.0)](https://github.styleci.io/repos/43671533?branch=v2.0) | ||
![Tests](https://github.com/srmklive/laravel-paypal/workflows/TestsV2/badge.svg) | ||
[![Coverage Status](https://coveralls.io/repos/github/srmklive/laravel-paypal/badge.svg?branch=v2.0)](https://coveralls.io/github/srmklive/laravel-paypal?branch=v2.0) | ||
[![Code Quality](https://scrutinizer-ci.com/g/srmklive/laravel-paypal/badges/quality-score.png?b=v2.0)](https://scrutinizer-ci.com/g/srmklive/laravel-paypal/?branch=v2.0) | ||
![Tests](https://github.com/srmklive/laravel-paypal/workflows/TestsV3/badge.svg) | ||
[![Coverage Status](https://coveralls.io/repos/github/srmklive/laravel-paypal/badge.svg?branch=v3.0)](https://coveralls.io/github/srmklive/laravel-paypal?branch=v3.0) | ||
[![Code Quality](https://scrutinizer-ci.com/g/srmklive/laravel-paypal/badges/quality-score.png?b=v3.0)](https://scrutinizer-ci.com/g/srmklive/laravel-paypal/?branch=v3.0) | ||
|
||
- [Documentation](#introduction) | ||
- [Usage](#usage) | ||
|
@@ -18,7 +18,7 @@ | |
|
||
The documentation for the package can be viewed by clicking the following link: | ||
|
||
https://srmklive.github.io/laravel-paypal/docs.html | ||
[https://srmklive.github.io/laravel-paypal/docs.html](https://srmklive.github.io/laravel-paypal/docs.html) | ||
|
||
<a name="usage"></a> | ||
## Usage | ||
|
@@ -32,10 +32,36 @@ use Srmklive\PayPal\Services\PayPal as PayPalClient; | |
$provider = new PayPalClient; | ||
|
||
// Through facade. No need to import namespaces | ||
$provider = PayPal::setProvider(); | ||
$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: | ||
|
@@ -58,40 +84,60 @@ $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: | ||
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'); | ||
``` | ||
|
||
## Initiating an order for Checkout | ||
Use the createOrder method to initiate an order | ||
## Create Recurring Daily Subscription | ||
|
||
```php | ||
$response = $provider->addProduct('Demo Product', 'Demo Product', 'SERVICE', 'SOFTWARE') | ||
->addSubscriptionTrialPricing('DAY', 7) | ||
->addDailyPlan('Demo Plan', 'Demo Plan', 1.50) | ||
->setupSubscription('John Doe', '[email protected]', '2021-12-10') ; | ||
``` | ||
|
||
## Create Recurring Weekly Subscription | ||
|
||
```php | ||
$response = $provider->addProduct('Demo Product', 'Demo Product', 'SERVICE', 'SOFTWARE') | ||
->addSubscriptionTrialPricing('DAY', 7) | ||
->addWeeklyPlan('Demo Plan', 'Demo Plan', 30) | ||
->setupSubscription('John Doe', '[email protected]', '2021-12-10') ; | ||
``` | ||
|
||
## Create Recurring Monthly Subscription | ||
|
||
```php | ||
$response = $provider->addProduct('Demo Product', 'Demo Product', 'SERVICE', 'SOFTWARE') | ||
->addSubscriptionTrialPricing('DAY', 7) | ||
->addMonthlyPlan('Demo Plan', 'Demo Plan', 100) | ||
->setupSubscription('John Doe', '[email protected]', '2021-12-10') ; | ||
``` | ||
|
||
## Create Recurring Annual Subscription | ||
|
||
```php | ||
$provider->createOrder([ | ||
"intent"=> "CAPTURE", | ||
"purchase_units"=> [ | ||
0 => [ | ||
"amount"=> [ | ||
"currency_code"=> "USD", | ||
"value"=> "100.00" | ||
] | ||
] | ||
] | ||
]); | ||
$response = $provider->addProduct('Demo Product', 'Demo Product', 'SERVICE', 'SOFTWARE') | ||
->addSubscriptionTrialPricing('DAY', 7) | ||
->addAnnualPlan('Demo Plan', 'Demo Plan', 600) | ||
->setupSubscription('John Doe', '[email protected]', '2021-12-10') ; | ||
``` | ||
|
||
The response from this will include an order ID which you will need to retail, and a links collection | ||
so you can redirect the user to Paypal to complete the order with their payment details | ||
## Create Subscription by Existing Product & Billing Plan | ||
|
||
When the user returns to the notifcation url you can capture the order payment with | ||
```php | ||
$provider->capturePaymentOrder($order_id); //order id from the createOrder step | ||
$response = $this->client->addProductById('PROD-XYAB12ABSB7868434') | ||
->addBillingPlanById('P-5ML4271244454362WXNWU5NQ') | ||
->setupSubscription('John Doe', '[email protected]', $start_date); | ||
``` | ||
|
||
<a name="support"></a> | ||
## Support | ||
|
||
This plugin only supports Laravel 5.1 to 5.8. | ||
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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit bootstrap="vendor/autoload.php" | ||
backupGlobals="false" | ||
backupStaticAttributes="false" | ||
colors="true" | ||
verbose="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false"> | ||
<testsuites> | ||
<testsuite name="PayPal Test Suite"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist> | ||
<directory suffix=".php">src/</directory> | ||
<exclude> | ||
<file>src/PayPalFacadeAccessor.php</file> | ||
<directory suffix=".php">src/Facades/</directory> | ||
<directory suffix=".php">src/Providers/</directory> | ||
</exclude> | ||
</whitelist> | ||
</filter> | ||
<logging> | ||
<log type="junit" target="build/report.junit.xml"/> | ||
<log type="coverage-html" target="build/coverage"/> | ||
<log type="coverage-text" target="build/coverage.txt"/> | ||
<log type="coverage-clover" target="build/logs/clover.xml"/> | ||
</logging> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.