Skip to content

Commit

Permalink
Release v3.0.0 (#22)
Browse files Browse the repository at this point in the history
* update namespace

* add upgrading steps

* add api docs

* add other api docs
  • Loading branch information
mhdcodes authored Oct 12, 2021
1 parent 00a4475 commit e128bc1
Show file tree
Hide file tree
Showing 34 changed files with 906 additions and 720 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ Inorder to communicate with PayPal platform we need to set up a client first :

```php
// import namespace
use PayPal\Checkout\Environment\SandboxEnvironment;
use PayPal\Checkout\Http\PayPalClient;
use PayPal\Http\Environment\SandboxEnvironment;
use PayPal\Http\PayPalClient;

// client id and client secret retrieved from PayPal
$clientId = "<<PAYPAL-CLIENT-ID>>";
Expand All @@ -58,8 +58,8 @@ $client = new PayPalClient($environment);

```php
// import namespace
use PayPal\Checkout\Environment\ProductionEnvironment;
use PayPal\Checkout\Http\PayPalClient;
use PayPal\Http\Environment\ProductionEnvironment;
use PayPal\Http\PayPalClient;

// client id and client secret retrieved from PayPal
$clientId = "<<PAYPAL-CLIENT-ID>>";
Expand All @@ -80,7 +80,7 @@ $client = new PayPalClient($environment);

```php
// Import namespace
use PayPal\Checkout\Http\OrderCreateRequest;
use PayPal\Checkout\Requests\OrderCreateRequest;
use PayPal\Checkout\Orders\AmountBreakdown;
use PayPal\Checkout\Orders\Item;
use PayPal\Checkout\Orders\Order;
Expand Down Expand Up @@ -117,7 +117,7 @@ echo $result->status; // CREATED

```php
// Import namespace
use PayPal\Checkout\Http\OrderCaptureRequest;
use PayPal\Checkout\Requests\OrderCaptureRequest;

// Create an order capture http request
$request = new OrderCaptureRequest($order_id);
Expand Down
6 changes: 2 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@
"require": {
"php": "^7.4|^8.0",
"ext-json": "*",
"guzzlehttp/psr7": "^1.6|^2.0",
"guzzlehttp/guzzle": "^7.0",
"brick/money": "^0.5.2"
"brick/money": "^0.5.2",
"phpjuice/paypal-http-client": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^9.0",
"squizlabs/php_codesniffer": "^3.4",
"phpstan/phpstan": "^0.12",
"pestphp/pest": "^1.18"
Expand Down
101 changes: 93 additions & 8 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

91 changes: 90 additions & 1 deletion docs/api/amount-breakdown.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,93 @@
# Amount Breakdown

coming soon.
See https://developer.paypal.com/docs/api/orders/v2/#definition-Amount_breakdown.

## Methods

### AmountBreakdown::__construct()

Creates an amount breakdown object using constructor.

#### Signature

```php
public function __construct(string $value, string $currency_code = 'USD');
```

#### Example

```php
$amount = new AmountBreakdown('100.00', 'USD');
```

### AmountBreakdown::of()

Creates an amount from a value and an optional currency code.

#### Signature

```php
public static function of(string $value, string $currency_code = 'USD'): AmountBreakdown;
```

#### Example

```php
$amount = AmountBreakdown::of('100.00', 'USD');
```

### AmountBreakdown::getCurrencyCode()

Gets an amount currency code.

#### Signature

```php
public function getCurrencyCode(): string;
```

#### Example

```php
$amount = AmountBreakdown::of('100.00', 'USD');
$currency = $amount->getCurrencyCode(); // USD
```

### AmountBreakdown::getValue()

Gets an amount value.

#### Signature

```php
public function getValue(): string;
```

#### Example

```php
$amount = AmountBreakdown::of('100.00', 'USD');
$value = $amount->getValue(); // '100.00'
```

### AmountBreakdown::toArray()

Casts the AmountBreakdown an array representation, used when serializing an amount into http request.

#### Signature

```php
public function toArray(): array;
```

#### Example

```php
$amount = AmountBreakdown::of('100.00', 'USD');
$array = $amount->toArray();
// result
[
'value' => '100.00',
'currency_code' => 'USD'
];
```
91 changes: 90 additions & 1 deletion docs/api/amount.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,93 @@
# Amount

coming soon.
See https://developer.paypal.com/docs/api/orders/v2/#definition-Amount_breakdown.

## Methods

### Amount::__construct()

Creates an amount object using constructor.

#### Signature

```php
public function __construct(string $value, string $currency_code = 'USD');
```

#### Example

```php
$amount = new Amount('100.00', 'USD');
```

### Amount::of()

Creates an amount from a value and an optional currency code.

#### Signature

```php
public static function of(string $value, string $currency_code = 'USD'): Amount;
```

#### Example

```php
$amount = Amount::of('100.00', 'USD');
```

### Amount::getCurrencyCode()

Gets an amount currency code.

#### Signature

```php
public function getCurrencyCode(): string;
```

#### Example

```php
$amount = Amount::of('100.00', 'USD');
$currency = $amount->getCurrencyCode(); // USD
```

### Amount::getValue()

Gets an amount value.

#### Signature

```php
public function getValue(): string;
```

#### Example

```php
$amount = Amount::of('100.00', 'USD');
$value = $amount->getValue(); // '100.00'
```

### Amount::toArray()

Casts the Amount an array representation, used when serializing an amount into http request.

#### Signature

```php
public function toArray(): array;
```

#### Example

```php
$amount = Amount::of('100.00', 'USD');
$array = $amount->toArray();
// result
[
'value' => '100.00',
'currency_code' => 'USD'
];
```
Loading

0 comments on commit e128bc1

Please sign in to comment.