Skip to content

Commit

Permalink
Refactor & updated README.
Browse files Browse the repository at this point in the history
  • Loading branch information
srmklive committed Sep 11, 2020
1 parent 2d86e87 commit 5cbd236
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ build:
- php-scrutinizer-run
environment:
php:
version: '7.1.33'
version: '7.3.21'
tests:
override:
-
Expand Down
23 changes: 7 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
[![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/TestsV3/badge.svg)
[![Coverage Status](https://coveralls.io/repos/github/srmklive/laravel-paypal/badge.svg)](https://coveralls.io/github/srmklive/laravel-paypal)
[![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)
[![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)

- [Introduction](#introduction)
- [PayPal API Credentials](#paypal-api-credentials)
Expand Down Expand Up @@ -36,23 +36,14 @@ https://developer.paypal.com/docs/api/overview/
* Use following command to install:

```bash
composer require srmklive/paypal:~1.0|~2.0
composer require srmklive/paypal:~3.0
```

Perform the following steps if you are using Laravel 5.4 or less.
To use this package for Laravel 5.1 to 5.8 use the following commands

* Add the service provider to your `providers[]` array in `config/app.php` file like:

```php
Srmklive\PayPal\Providers\PayPalServiceProvider::class
```

* Add the alias to your `aliases[]` array in `config/app.php` file like:

```php
'PayPal' => Srmklive\PayPal\Facades\PayPal::class
```bash
composer require srmklive/paypal:~2.0
```

* Run the following command to publish configuration:

```bash
Expand Down Expand Up @@ -134,7 +125,7 @@ $provider->setCurrency('EUR')->setExpressCheckout($data);
<a name="support"></a>
## Support

This plugin only supports Laravel 5.1 or greater.
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.
Expand Down
21 changes: 12 additions & 9 deletions src/Traits/PayPalAPI/Subscriptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ public function reviseSubscription($subscription_id, array $items)
/**
* List transactions for an existing subscription.
*
* @param string $subscription_id
* @param string $start_date
* @param string $end_date
* @param string $subscription_id
* @param \DateTimeInterface|string $start_date
* @param \DateTimeInterface|string $end_date
*
* @throws \Throwable
*
Expand All @@ -217,13 +217,16 @@ public function reviseSubscription($subscription_id, array $items)
*/
public function listSubscriptionTransactions($subscription_id, $start_date = '', $end_date = '')
{
$start_date = empty($start_date) ?
Carbon::now()->subDay()->toIso8601String() :
Carbon::parse($start_date)->toIso8601String();
if (($start_date instanceof \DateTimeInterface) === false) {
$start_date = Carbon::parse($start_date);
}

if (($end_date instanceof \DateTimeInterface) === false) {
$end_date = Carbon::parse($end_date);
}

$end_date = empty($end_date) ?
Carbon::now()->toIso8601String() :
Carbon::parse($end_date)->toIso8601String();
$start_date = $start_date->toIso8601String();
$end_date = $end_date->toIso8601String();

$this->apiEndPoint = "v1/billing/subscriptions/{$subscription_id}/transactions?start_time={$start_date}&end_time={$end_date}";
$this->apiUrl = collect([$this->config['api_url'], $this->apiEndPoint])->implode('/');
Expand Down
17 changes: 7 additions & 10 deletions src/Traits/PayPalHttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,14 @@ protected function setHttpClientConfiguration()
*/
private function setDefaultValues()
{
$defaults = [
'paymentAction' => 'Sale',
'locale' => 'en_US',
'validateSSL' => true,
];
$paymentAction = empty($this->paymentAction) ? 'Sale' : $this->paymentAction;
$this->paymentAction = $paymentAction;

foreach ($defaults as $key => $value) {
if (empty($this->$key)) {
$this->$key = $defaults[$key];
}
}
$locale = empty($this->locale) ? 'en_US' : $this->locale;
$this->locale = $locale;

$validateSSL = empty($validateSSL) ? true : $this->validateSSL;
$this->validateSSL = $validateSSL;
}

/**
Expand Down

0 comments on commit 5cbd236

Please sign in to comment.