Skip to content

Commit 6cab9e0

Browse files
authored
Release v2.0.0 (#14)
1 parent 3f24540 commit 6cab9e0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+3713
-1963
lines changed

.gitbook.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
root: ./docs/
2+
3+
structure:
4+
readme: README.md
5+
summary: SUMMARY.md

.github/ISSUE_TEMPLATE/bug_report.md

-11
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,5 @@ A clear and concise description of what you expected to happen.
2323
**Screenshots**
2424
If applicable, add screenshots to help explain your problem.
2525

26-
**Desktop (please complete the following information):**
27-
- OS: [e.g. iOS]
28-
- Browser [e.g. chrome, safari]
29-
- Version [e.g. 22]
30-
31-
**Smartphone (please complete the following information):**
32-
- Device: [e.g. iPhone6]
33-
- OS: [e.g. iOS8.1]
34-
- Browser [e.g. stock browser, safari]
35-
- Version [e.g. 22]
36-
3726
**Additional context**
3827
Add any other context about the problem here.

.github/workflows/php.yml

+29-25
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,36 @@
11
name: Tests
22

3-
on:
4-
push:
5-
branches: [ master ]
6-
pull_request:
7-
branches: [ master ]
3+
on: [push, pull_request]
84

95
jobs:
10-
build:
6+
test:
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
fail-fast: true
10+
matrix:
11+
os: [ubuntu-latest, windows-latest]
12+
php: [8.0, 7.4]
13+
stability: [prefer-stable]
1114

12-
runs-on: ubuntu-latest
15+
name: PHP${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }}
1316

1417
steps:
15-
- uses: actions/checkout@v2
16-
17-
- name: Setup PHP
18-
uses: shivammathur/setup-php@v2
19-
with:
20-
php-version: '7.4'
21-
22-
- name: Validate composer.json and composer.lock
23-
run: composer validate
24-
25-
- name: Install dependencies
26-
run: composer install --prefer-dist --no-progress --no-suggest
27-
28-
# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
29-
# Docs: https://getcomposer.org/doc/articles/scripts.md
30-
31-
- name: Run test suite
32-
run: composer test -- --coverage-clover=coverage.clover
18+
- name: Checkout code
19+
uses: actions/checkout@v2
20+
21+
- name: Setup PHP
22+
uses: shivammathur/setup-php@v2
23+
with:
24+
php-version: ${{ matrix.php }}
25+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap
26+
coverage: none
27+
28+
- name: Setup problem matchers
29+
run: |
30+
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
31+
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
32+
- name: Install dependencies
33+
run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction
34+
35+
- name: Execute tests
36+
run: vendor/bin/pest

.gitignore

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
/vendor
2-
/.idea
3-
/.vscode
4-
.env
5-
.phpunit.result.cache
1+
.idea
2+
.php_cs
63
.php_cs.cache
4+
.phpunit.result.cache
5+
build
6+
coverage
7+
psalm.xml
8+
testbench.yaml
9+
vendor
10+
.php-cs-fixer.cache
11+
.phpunit.cache

CODE_OF_CONDUCT.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ representative at an online or offline event.
6060

6161
Instances of abusive, harassing, or otherwise unacceptable behavior may be
6262
reported to the community leaders responsible for enforcement at
63-
hello@phpjuice.io.
63+
phpjuice@gmail.com.
6464
All complaints will be reviewed and investigated promptly and fairly.
6565

6666
All community leaders are obligated to respect the privacy and security of the

CONTRIBUTING.md

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Contributing
2+
3+
Contributions are **welcome** and will be fully **credited**.
4+
5+
Please read and understand the contribution guide before creating an issue or pull request.
6+
7+
## Etiquette
8+
9+
This project is open source, and as such, the maintainers give their free time to build and maintain the source code
10+
held within. They make the code freely available in the hope that it will be of use to other developers. It would be
11+
extremely unfair for them to suffer abuse or anger for their hard work.
12+
13+
Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the
14+
world that developers are civilized and selfless people.
15+
16+
It's the duty of the maintainer to ensure that all submissions to the project are of sufficient
17+
quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used.
18+
19+
## Viability
20+
21+
When requesting or submitting new features, first consider whether it might be useful to others. Open
22+
source projects are used by many developers, who may have entirely different needs to your own. Think about
23+
whether or not your feature is likely to be used by other users of the project.
24+
25+
## Procedure
26+
27+
Before filing an issue:
28+
29+
- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident.
30+
- Check to make sure your feature suggestion isn't already present within the project.
31+
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
32+
- Check the pull requests tab to ensure that the feature isn't already in progress.
33+
34+
Before submitting a pull request:
35+
36+
- Check the codebase to ensure that your feature doesn't already exist.
37+
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.
38+
39+
## Requirements
40+
41+
If the project maintainer has any additional requirements, you will find them listed here.
42+
43+
- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer).
44+
45+
- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
46+
47+
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
48+
49+
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option.
50+
51+
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
52+
53+
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.
54+
55+
**Happy coding**!

readme.md renamed to README.md

+57-22
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
[![Total Downloads](http://poser.pugx.org/phpjuice/paypal-checkout-sdk/downloads)](https://packagist.org/packages/phpjuice/paypal-checkout-sdk)
77
[![License](http://poser.pugx.org/phpjuice/paypal-checkout-sdk/license)](https://packagist.org/packages/phpjuice/paypal-checkout-sdk)
88

9-
PayPal Checkout SDK is a wrapper around the V2 PayPal rest API.
9+
This Package is a PHP SDK wrapper around version 2 of the PayPal rest API. It provides a simple, fluent API to create
10+
and capture orders with both sandbox and production environments supported.
11+
12+
To learn all about it, head over to the extensive [documentation](https://phpjuice.gitbook.io/paypal-checkout-sdk).
1013

1114
## Installation
1215

@@ -20,7 +23,7 @@ The supported way of installing PayPal Checkout SDK package is via Composer.
2023
composer require phpjuice/paypal-checkout-sdk
2124
```
2225

23-
## Usage
26+
## Setup
2427

2528
PayPal Checkout SDK is designed to simplify using the new PayPal checkout api in your app.
2629

@@ -34,14 +37,14 @@ generating a REST API app. Get Client ID and Secret from there.
3437

3538
Inorder to communicate with PayPal platform we need to set up a client first :
3639

37-
- Create a client with sandbox environment :
40+
#### Create a client with sandbox environment :
3841

3942
```php
4043
// import namespace
4144
use PayPal\Checkout\Environment\SandboxEnvironment;
4245
use PayPal\Checkout\Http\PayPalClient;
4346

44-
// client id and client secret retrieved from paypal
47+
// client id and client secret retrieved from PayPal
4548
$clientId = "<<PAYPAL-CLIENT-ID>>";
4649
$clientSecret = "<<PAYPAL-CLIENT-SECRET>>";
4750

@@ -52,14 +55,14 @@ $environment = new SandboxEnvironment($clientId, $clientSecret);
5255
$client = new PayPalClient($environment);
5356
```
5457

55-
- Create a client with production environment :
58+
#### Create a client with production environment :
5659

5760
```php
5861
// import namespace
5962
use PayPal\Checkout\Environment\ProductionEnvironment;
6063
use PayPal\Checkout\Http\PayPalClient;
6164

62-
// client id and client secret retrieved from paypal
65+
// client id and client secret retrieved from PayPal
6366
$clientId = "<<PAYPAL-CLIENT-ID>>";
6467
$clientSecret = "<<PAYPAL-CLIENT-SECRET>>";
6568

@@ -70,42 +73,73 @@ $environment = new ProductionEnvironment($clientId, $clientSecret);
7073
$client = new PayPalClient($environment);
7174
```
7275

73-
### Create a new Order
76+
> **INFO**: head over to the extensive [documentation](https://phpjuice.gitbook.io/paypal-checkout-sdk).
77+
78+
## Usage
79+
80+
### Create an Order
7481

7582
```php
76-
// import namespace
83+
// Import namespace
7784
use PayPal\Checkout\Http\OrderCreateRequest;
85+
use PayPal\Checkout\Orders\AmountBreakdown;
7886
use PayPal\Checkout\Orders\Item;
7987
use PayPal\Checkout\Orders\Order;
8088
use PayPal\Checkout\Orders\PurchaseUnit;
8189

82-
// create a purchase unit with the total amount
83-
$purchase_unit = new PurchaseUnit('USD', 100.00);
84-
// create a new item
85-
$item = new Item('Item 1', 'USD', 100.00, 1);
86-
// add item to purchase unit
87-
$purchase_unit->addItem($item);
88-
// create a new order with intent to capture a payment
89-
$order = new Order('CAPTURE');
90-
// add a purchase unit to order
90+
// Create a purchase unit with the total amount
91+
$purchase_unit = new PurchaseUnit(AmountBreakdown::of('100.00'));
92+
93+
// Create & add item to purchase unit
94+
$purchase_unit->addItem(Item::create('Item 1', '100.00', 'USD', 1));
95+
96+
// Create a new order with intent to capture a payment
97+
$order = new Order();
98+
99+
// Add a purchase unit to order
91100
$order->addPurchaseUnit($purchase_unit);
92101

93-
// create an order create http request
102+
// Create an order create http request
94103
$request = new OrderCreateRequest($order);
95-
// send request to paypal
104+
105+
// Send request to PayPal
96106
$response = $client->send($request);
97-
// parse result
107+
108+
// Parse result
98109
$result = json_decode((string) $response->getBody());
99110
echo $result->id; // id of the created order
111+
echo $result->intent; // CAPTURE
112+
echo $result->status; // CREATED
113+
```
114+
115+
> **INFO**: head over to the extensive [documentation](https://phpjuice.gitbook.io/paypal-checkout-sdk).
116+
117+
### Capture an Order
118+
119+
```php
120+
// Import namespace
121+
use PayPal\Checkout\Http\OrderCaptureRequest;
122+
123+
// Create an order capture http request
124+
$request = new OrderCaptureRequest($order_id);
125+
126+
// Send request to PayPal
127+
$response = $client->send($request);
128+
129+
// Parse result
130+
$result = json_decode((string) $response->getBody());
131+
echo $result->id; // id of the captured order
132+
echo $result->status; // CAPTURED
100133
```
134+
> **INFO**: head over to the extensive [documentation](https://phpjuice.gitbook.io/paypal-checkout-sdk).
101135
102-
## Change log
136+
## Changelog
103137

104138
Please see the [changelog](changelog.md) for more information on what has changed recently.
105139

106140
## Contributing
107141

108-
Please see [contributing.md](contributing.md) for details and a todo list.
142+
Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for details and a todo list.
109143

110144
## Security
111145

@@ -114,6 +148,7 @@ If you discover any security related issues, please email author instead of usin
114148
## Credits
115149

116150
- [PayPal Docs](https://developer.paypal.com/docs/)
151+
- [Gitbook](https://www.gitbook.com/)
117152

118153
## License
119154

_config.yml

-1
This file was deleted.

changelog.md

+23-14
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,50 @@
22

33
All notable changes to `phpjuice/paypal-checkout-sdk` will be documented in this file.
44

5-
## Version 1.0.0
5+
## Version 1.2.0
66

7-
### Added
7+
### Changed
8+
- fix amount breakdown to include discount #12
89

9-
- Orders API Requests
10-
- PayPal Client
11-
- Access Token Requests
10+
### Removed
11+
- Removed `setValue` & `setCurrencyCode` from `Amount.php`
12+
- Removed `setValue` & `setCurrencyCode` from `PurchaseUnit`
1213

13-
## Version 1.0.1
14+
## Version 1.1.2
1415

1516
### Added
1617

17-
- Update package documentation
18+
- Clean and refactor code #8
1819

19-
## Version 1.0.2
20+
## Version 1.1.1
2021

2122
### Added
2223

23-
- Add type hints to all classes.
24-
- Add the calculated total test.
24+
- Remove PHP version header on sandbox environment (#7) (see #6)
2525

2626
## Version 1.1.0
2727

2828
### Added
2929

3030
- Upgrade guzzle http to version 7 (#3)
3131

32-
## Version 1.1.1
32+
## Version 1.0.2
3333

3434
### Added
3535

36-
- Remove PHP version header on sandbox environment (#7) (see #6)
36+
- Add type hints to all classes.
37+
- Add the calculated total test.
3738

38-
## Version 1.1.2
39+
## Version 1.0.1
3940

4041
### Added
4142

42-
- Clean and refactor code #8
43+
- Update package documentation
44+
45+
## Version 1.0.0
46+
47+
### Added
48+
49+
- Orders API Requests
50+
- PayPal Client
51+
- Access Token Requests

0 commit comments

Comments
 (0)