Skip to content

Commit

Permalink
Updated package meta information, documentation and license
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinMystikJonas committed Sep 6, 2015
1 parent 16d4035 commit 6ed6cfa
Show file tree
Hide file tree
Showing 12 changed files with 275 additions and 240 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
*~
*.iml
.idea/
/vendor/
composer.lock


4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ php:
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm

matrix:
allow_failures:
- php: 7.0
- php: hhvm

before_script:
Expand All @@ -18,7 +20,7 @@ before_script:
# Install Nette Tester
- travis_retry composer update --no-interaction --prefer-dist $dependencies

script: ./vendor/bin/tester -p php -c ./tests/php.ini-unix ./tests/
script: ./vendor/bin/tester -p php -c ./tests/php.ini-travis ./tests/

after_failure:
# Print *.actual content
Expand Down
28 changes: 0 additions & 28 deletions LICENSE

This file was deleted.

55 changes: 55 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
Licenses
========

You may use this package under the terms of either
the New BSD License or the GNU General Public License (GPL) version 2 or 3.

The BSD License is recommended for most projects. It is easy to understand and it places almost no restrictions on what
you can do with the framework. If the GPL fits better to your project, you can use the package under this license.

You don't have to notify anyone which license you are using. You can freely use this package in commercial projects
as long as the copyright header remains intact.



New BSD License
---------------

Copyright (c) 2015 GrowJOB s.r.o. (http://growjob.com)
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of "Nette Tester" nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

This software is provided by the copyright holders and contributors "as is" and
any express or implied warranties, including, but not limited to, the implied
warranties of merchantability and fitness for a particular purpose are
disclaimed. In no event shall the copyright owner or contributors be liable for
any direct, indirect, incidental, special, exemplary, or consequential damages
(including, but not limited to, procurement of substitute goods or services;
loss of use, data, or profits; or business interruption) however caused and on
any theory of liability, whether in contract, strict liability, or tort
(including negligence or otherwise) arising in any way out of the use of this
software, even if advised of the possibility of such damage.



GNU General Public License
--------------------------

GPL licenses are very very long, so instead of including them here we offer
you URLs with full text:

- [GPL version 2](http://www.gnu.org/licenses/gpl-2.0.html)
- [GPL version 3](http://www.gnu.org/licenses/gpl-3.0.html)
200 changes: 13 additions & 187 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,204 +1,30 @@
MetisFW/PayPal
======
# MetisFW/PayPal

[![Build Status](https://travis-ci.org/MetisFW/PayPal.svg?branch=master)](https://travis-ci.org/MetisFW/PayPal)
[![Downloads this Month](https://img.shields.io/packagist/dm/metisfw/paypal.svg)](https://packagist.org/packages/metisfw/paypal)
[![Latest stable](https://img.shields.io/packagist/v/metisfw/paypal.svg)](https://packagist.org/packages/metisfw/paypal)

About
------------
PayPal payment integration to Nette framework.
Internally use [paypal/PayPal-PHP-SDK](https://github.com/paypal/PayPal-PHP-SDK) for api requests.
## About

Inspired by [Kdyby/PayPalExpress](https://github.com/Kdyby/PayPalExpress)

Requirements
------------
MetisFW/PayPal requires PHP 5.3.2 or higher with curl, json and openssl (for lower PHP version) extensions.

- [Nette Framework](https://github.com/nette/nette)
PayPal payment integration to Nette framework. Internally use [paypal/PayPal-PHP-SDK](https://github.com/paypal/PayPal-PHP-SDK) for api requests.

Inspired by [Kdyby/PayPalExpress](https://github.com/Kdyby/PayPalExpress)

Installation
------------
1) The best way to install MetisFW/PayPal is using [Composer](http://getcomposer.org/):
## Installation
The best way to install is using [Composer](http://getcomposer.org/):

```sh
$ composer require metisfw/paypal
```

2) Register extension
```
extensions:
payPal: MetisFW\PayPal\DI\PayPalExtension
```

3) Set up extension parameters

```neon
payPal:
clientId: AUqne4ywvozUaSQ1THTZYKFr88bhtA0SS_fXBoJTfeSTIasDBWuXLiLcFlfmSXRfL-kZ3Z5shvNrT6rP
secret: EDGPDc3a65JBBY7-IKkNak7aGTVTvY-NhJgfhptegSML58fWjfp89U7UKNgGk9UI-UEZ-btfaE2sGST1
currency: EUR
sdkConfig:
mode: sandbox
log.Enabled: true
log.FileName: '%tempDir%/PayPal.log'
log.LogLevel: DEBUG
validation.level: log
cache.enabled: true
# 'http.CURLOPT_CONNECTTIMEOUT' => 30
# 'http.headers.PayPal-Partner-Attribution-Id' => '123123123'/
```

sdkConfig is config to [paypal/PayPal-PHP-SDK](https://github.com/paypal/PayPal-PHP-SDK)
see [sdk-config-sample](https://github.com/paypal/PayPal-PHP-SDK/blob/master/sample/sdk_config.ini)

Usage
------------
##### Sample usage of `PaymentControl`

###### In Presenter

```php
use \MetisFW\Paypal\Payment\SimplePaymentOperation;
use \MetisFW\PayPal\UI\PaymentControl;
use PayPal\Api\Payment;
use Nette\Application\UI\Presenter;

class MyPresenter extends Presenter {

public function createComponentPayPalPaymentButton(SimplePaymentOperationFactory $factory) {
$operation = $factory->create('Coffee', 5);
$control = new PaymentControl($operation);

//set different template if u want to use own
$control->setTemplateFilePath(__DIR__ . './myPayPalButton.latte');

//called before redirect to paypal after first api call, which create payment
$control->onCheckout[] = function(PaymentControl $control, Payment $created) {
//something
};

//called after successfully completed payment proccess
$control->onSuccess[] = function(PaymentControl $control, Payment $paid) {
//something
};

//called when user cancelled payment process
$control->onCancel[] = function(PaymentControl $control) {
//something
};

return $control;
}
}
```

###### In latte

```latte
#just
{control payPalPaymentButton}
#or
#cannot use attributes directly in control
# see http://doc.nette.org/en/2.3/default-macros#toc-component-rendering
{var attributes = array('class' => 'paypal-payment-button')}
{control payPalPaymentButton $attributes, 'Pay me now!'}
```

##### Sample usage of `SimplePaymentOperation`

```php
public function createComponentPayPalpaymentButton(SimplePaymentOperationFactory $factory) {
$operation = $factory->create('Coffee', 10);
$control = new PaymentControl($operation);
return $control;
}
```

##### Sample usage of `PlainPaymentOperation`

```php
use PayPal\Api\Transaction;

public function createComponentPayPalpaymentButton(PlainPaymentOperationFactory $factory) {
$transactions = array();
$transaction = new Transaction();
//setup transaction - see paypal-php-sdk


$operation = $factory->create($transactions);
$control = new PaymentControl($operation);
return $control;
}
```

##### Sample usage of own descendant `\MetisFW\PayPal\Payment\BasePaymentOperation`

```php
<?php

namespace MetisApp\Components\Payment;

use MetisFW\PayPal\Payment\BasePaymentOperation;
use MetisFW\PayPal\PayPalContext;
use PayPal\Api\Amount;
use PayPal\Api\Details;
use PayPal\Api\Item;
use PayPal\Api\ItemList;
use PayPal\Api\Transaction;

class OrderPayPalOperation extends BasePaymentOperation {

/** @var mixed */
private $order;

/**
* @param PayPalContext $context
* @param mixed $order some data - object/array/...
*/
public function __construct(PayPalContext $context, $order) {
parent::__construct($context);
$this->order = $order;
}

/**
* @return array array of PayPal\Api\Transaction
*/
protected function getTransactions() {
$transactions = array();
$transaction = new Transaction();

//setup transaction via data passed in constructor

$transactions[] = $transaction;
return $transactions;
}

}

```

###### Events in Operation
```php
public function createComponentPayPalPaymentButton(FactorType $factory) {
$operation = $factory->create();
$operation->onReturn[] = function($operation, Payment $paid) {
//something
}
$operation->onCancel[] = function($operation) {
//something
}

...
}
```
## Documentation

Learn more in the [documentation](https://github.com/MetisFW/PayPal/blob/master/docs/en/index.md).

There are other classes in this package that are not documented here.
This is because the package is a Nette wrapper of [the official PayPal PHP SDK](https://github.com/paypal/PayPal-PHP-SDK).

-----
## License

Homepage [MetisFW](https://github.com/MetisFW) and repository [MetisFW/PayPal](https://github.com/MetisFW/PayPal).
You may use this package under the terms of either
the New BSD License or the GNU General Public License (GPL) version 2 or 3.
27 changes: 10 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,23 @@
"name": "metisfw/paypal",
"type": "library",
"description": "PayPal SDK integration for Nette Framework",
"keywords": [
"nette",
"paypal",
"pay",
"checkout",
"payment"
],
"keywords": ["nette", "paypal", "pay", "checkout", "payment"],
"homepage": "https://github.com/MetisFW",
"license": [
"BSD-3-Clause",
"GPL-2.0",
"GPL-3.0"
],
"license": ["BSD-3-Clause", "GPL-2.0", "GPL-3.0"],
"authors": [
{
"name": "GrowJOB s.r.o",
"email": "[email protected]"
},
{
"name": "Hynek Vilímek",
"email": "h.vilimek@gmail.com"
"email": "hynek.vilimek@growjob.com"
}
],
"support": {
"email": "[email protected]",
"issues": "https://github.com/MetisFW/PayPal/issues"
},
"require": {
"php": ">=5.3.0",
"ext-curl": "*",
Expand Down Expand Up @@ -58,13 +52,12 @@
"nette/tester": "@dev",
"mockery/mockery": "^0.9.4"
},
"support": {
"email": "[email protected]",
"issues": "https://github.com/MetisFW/PayPal/issues"
},
"autoload": {
"psr-0": {
"MetisFW\\PayPal\\": "src/"
}
},
"archive": {
"exclude": ["tests", ".travis.yml"]
}
}
Loading

0 comments on commit 6ed6cfa

Please sign in to comment.