-
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.
- Loading branch information
Showing
132 changed files
with
4,095 additions
and
1,129 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.pdf filter=lfs diff=lfs merge=lfs -text |
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,35 @@ | ||
name: Static Analysis | ||
on: [push, pull_request] | ||
jobs: | ||
paypal: | ||
name: PHP ${{ matrix.php-versions }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
php-versions: ['7.0', '7.1', '7.2', '7.3', '7.4'] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Setup PHP with Composer and extensions | ||
with: | ||
php-version: ${{ matrix.php-versions }} | ||
uses: shivammathur/setup-php@v2 | ||
- name: Get Composer cache directory | ||
id: composercache | ||
run: echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
- name: Cache Composer dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
php-version: ${{ matrix.php-versions }} | ||
path: ${{ steps.composercache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: ${{ runner.os }}-composer- | ||
- name: Install Composer dependencies | ||
env: | ||
PHP_VERSION: ${{ matrix.php-versions }} | ||
run: composer install --no-progress --prefer-dist --optimize-autoloader $(if [ "$PHP_VERSION" == "8.0" || "$PHP_VERSION" == "8.1" ]; then echo "--ignore-platform-reqs"; fi;) | ||
- name: Run type checking analysis | ||
env: | ||
PHP_VERSION: ${{ matrix.php-versions }} | ||
run: vendor/bin/phpstan |
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 |
---|---|---|
|
@@ -3,7 +3,8 @@ | |
.env | ||
composer.lock | ||
/build | ||
*docker* | ||
*-container* | ||
*.phpunit* | ||
test.php | ||
/.venv | ||
/docs/build |
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,19 @@ | ||
FROM srmklive/docker-php-cli:7.2 | ||
|
||
LABEL maintainer="Raza Mehdi<[email protected]>" | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
# Set apps home directory. | ||
ENV APP_DIR /server/http | ||
|
||
# Define current working directory. | ||
WORKDIR ${APP_DIR} | ||
|
||
RUN apt-get -y autoclean \ | ||
&& apt-get -y autoremove \ | ||
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
|
||
COPY supervisor.conf /etc/supervisor/conf.d/supervisord.conf | ||
|
||
CMD ["/usr/bin/supervisord"] |
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 |
---|---|---|
|
@@ -67,6 +67,20 @@ return [ | |
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); | ||
``` | ||
|
||
|
@@ -128,9 +142,68 @@ $response = $provider->addProduct('Demo Product', 'Demo Product', 'SERVICE', 'SO | |
|
||
## Create Subscription by Existing Product & Billing Plan | ||
|
||
<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', '[email protected]', '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', '[email protected]', '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', '[email protected]', '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', '[email protected]', '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', '[email protected]', '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', '[email protected]', $start_date); | ||
``` | ||
|
||
|
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,10 @@ | ||
version: '2' | ||
services: | ||
app: | ||
build: | ||
context: ./ | ||
dockerfile: Dockerfile | ||
image: srmklive/laravel-paypal | ||
restart: always | ||
volumes: | ||
- ./:/server/http |
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,9 @@ | ||
parameters: | ||
paths: | ||
- src | ||
level: 0 | ||
ignoreErrors: | ||
- "#Parameter#" | ||
- "#Call to static method error\\(\\)\\ on an unknown class Log.#" | ||
excludePaths: | ||
- "src/Providers/PayPalServiceProvider.php" |
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 was deleted.
Oops, something went wrong.
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,34 @@ | ||
<?php | ||
|
||
namespace Srmklive\PayPal\Services; | ||
|
||
use GuzzleHttp\Utils; | ||
|
||
class Str extends \Illuminate\Support\Str | ||
{ | ||
/** | ||
* Determine if a given value is valid JSON. | ||
* | ||
* @param mixed $value | ||
* | ||
* @return bool | ||
*/ | ||
public static function isJson($value): bool | ||
{ | ||
if (!is_string($value)) { | ||
return false; | ||
} | ||
|
||
if (function_exists('json_validate')) { | ||
return json_validate($value, 512); | ||
} | ||
|
||
try { | ||
Utils::jsonDecode($value, true, 512, 4194304); | ||
} catch (\JsonException $jsonException) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
} |
Oops, something went wrong.