Skip to content

Commit

Permalink
Release v2.0.0 (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhdcodes authored Oct 4, 2021
1 parent 3f24540 commit 6cab9e0
Show file tree
Hide file tree
Showing 64 changed files with 3,713 additions and 1,963 deletions.
5 changes: 5 additions & 0 deletions .gitbook.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
root: ./docs/

structure:
readme: README.md
summary: SUMMARY.md
11 changes: 0 additions & 11 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,5 @@ A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
54 changes: 29 additions & 25 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
name: Tests

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
on: [push, pull_request]

jobs:
build:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest]
php: [8.0, 7.4]
stability: [prefer-stable]

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

steps:
- uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'

- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest

# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
# Docs: https://getcomposer.org/doc/articles/scripts.md

- name: Run test suite
run: composer test -- --coverage-clover=coverage.clover
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap
coverage: none

- name: Setup problem matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Install dependencies
run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction

- name: Execute tests
run: vendor/bin/pest
15 changes: 10 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
/vendor
/.idea
/.vscode
.env
.phpunit.result.cache
.idea
.php_cs
.php_cs.cache
.phpunit.result.cache
build
coverage
psalm.xml
testbench.yaml
vendor
.php-cs-fixer.cache
.phpunit.cache
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ representative at an online or offline event.

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

All community leaders are obligated to respect the privacy and security of the
Expand Down
55 changes: 55 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Contributing

Contributions are **welcome** and will be fully **credited**.

Please read and understand the contribution guide before creating an issue or pull request.

## Etiquette

This project is open source, and as such, the maintainers give their free time to build and maintain the source code
held within. They make the code freely available in the hope that it will be of use to other developers. It would be
extremely unfair for them to suffer abuse or anger for their hard work.

Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the
world that developers are civilized and selfless people.

It's the duty of the maintainer to ensure that all submissions to the project are of sufficient
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.

## Viability

When requesting or submitting new features, first consider whether it might be useful to others. Open
source projects are used by many developers, who may have entirely different needs to your own. Think about
whether or not your feature is likely to be used by other users of the project.

## Procedure

Before filing an issue:

- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident.
- Check to make sure your feature suggestion isn't already present within the project.
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
- Check the pull requests tab to ensure that the feature isn't already in progress.

Before submitting a pull request:

- Check the codebase to ensure that your feature doesn't already exist.
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.

## Requirements

If the project maintainer has any additional requirements, you will find them listed here.

- **[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).

- **Add tests!** - Your patch won't be accepted if it doesn't have tests.

- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.

- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option.

- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.

- **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.

**Happy coding**!
79 changes: 57 additions & 22 deletions readme.md → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
[![Total Downloads](http://poser.pugx.org/phpjuice/paypal-checkout-sdk/downloads)](https://packagist.org/packages/phpjuice/paypal-checkout-sdk)
[![License](http://poser.pugx.org/phpjuice/paypal-checkout-sdk/license)](https://packagist.org/packages/phpjuice/paypal-checkout-sdk)

PayPal Checkout SDK is a wrapper around the V2 PayPal rest API.
This Package is a PHP SDK wrapper around version 2 of the PayPal rest API. It provides a simple, fluent API to create
and capture orders with both sandbox and production environments supported.

To learn all about it, head over to the extensive [documentation](https://phpjuice.gitbook.io/paypal-checkout-sdk).

## Installation

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

## Usage
## Setup

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

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

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

- Create a client with sandbox environment :
#### Create a client with sandbox environment :

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

// client id and client secret retrieved from paypal
// client id and client secret retrieved from PayPal
$clientId = "<<PAYPAL-CLIENT-ID>>";
$clientSecret = "<<PAYPAL-CLIENT-SECRET>>";

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

- Create a client with production environment :
#### Create a client with production environment :

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

// client id and client secret retrieved from paypal
// client id and client secret retrieved from PayPal
$clientId = "<<PAYPAL-CLIENT-ID>>";
$clientSecret = "<<PAYPAL-CLIENT-SECRET>>";

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

### Create a new Order
> **INFO**: head over to the extensive [documentation](https://phpjuice.gitbook.io/paypal-checkout-sdk).
## Usage

### Create an Order

```php
// import namespace
// Import namespace
use PayPal\Checkout\Http\OrderCreateRequest;
use PayPal\Checkout\Orders\AmountBreakdown;
use PayPal\Checkout\Orders\Item;
use PayPal\Checkout\Orders\Order;
use PayPal\Checkout\Orders\PurchaseUnit;

// create a purchase unit with the total amount
$purchase_unit = new PurchaseUnit('USD', 100.00);
// create a new item
$item = new Item('Item 1', 'USD', 100.00, 1);
// add item to purchase unit
$purchase_unit->addItem($item);
// create a new order with intent to capture a payment
$order = new Order('CAPTURE');
// add a purchase unit to order
// Create a purchase unit with the total amount
$purchase_unit = new PurchaseUnit(AmountBreakdown::of('100.00'));

// Create & add item to purchase unit
$purchase_unit->addItem(Item::create('Item 1', '100.00', 'USD', 1));

// Create a new order with intent to capture a payment
$order = new Order();

// Add a purchase unit to order
$order->addPurchaseUnit($purchase_unit);

// create an order create http request
// Create an order create http request
$request = new OrderCreateRequest($order);
// send request to paypal

// Send request to PayPal
$response = $client->send($request);
// parse result

// Parse result
$result = json_decode((string) $response->getBody());
echo $result->id; // id of the created order
echo $result->intent; // CAPTURE
echo $result->status; // CREATED
```

> **INFO**: head over to the extensive [documentation](https://phpjuice.gitbook.io/paypal-checkout-sdk).
### Capture an Order

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

// Create an order capture http request
$request = new OrderCaptureRequest($order_id);

// Send request to PayPal
$response = $client->send($request);

// Parse result
$result = json_decode((string) $response->getBody());
echo $result->id; // id of the captured order
echo $result->status; // CAPTURED
```
> **INFO**: head over to the extensive [documentation](https://phpjuice.gitbook.io/paypal-checkout-sdk).
## Change log
## Changelog

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

## Contributing

Please see [contributing.md](contributing.md) for details and a todo list.
Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for details and a todo list.

## Security

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

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

## License

Expand Down
1 change: 0 additions & 1 deletion _config.yml

This file was deleted.

37 changes: 23 additions & 14 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,50 @@

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

## Version 1.0.0
## Version 1.2.0

### Added
### Changed
- fix amount breakdown to include discount #12

- Orders API Requests
- PayPal Client
- Access Token Requests
### Removed
- Removed `setValue` & `setCurrencyCode` from `Amount.php`
- Removed `setValue` & `setCurrencyCode` from `PurchaseUnit`

## Version 1.0.1
## Version 1.1.2

### Added

- Update package documentation
- Clean and refactor code #8

## Version 1.0.2
## Version 1.1.1

### Added

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

## Version 1.1.0

### Added

- Upgrade guzzle http to version 7 (#3)

## Version 1.1.1
## Version 1.0.2

### Added

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

## Version 1.1.2
## Version 1.0.1

### Added

- Clean and refactor code #8
- Update package documentation

## Version 1.0.0

### Added

- Orders API Requests
- PayPal Client
- Access Token Requests
Loading

0 comments on commit 6cab9e0

Please sign in to comment.