Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/.idea/
/composer.lock
/composer.phar
/vendor/
63 changes: 32 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,35 @@
# UnitPay PHP-SDK
Php sdk for [UnitPay ](https://unitpay.ru)
Php sdk for [UnitPay](https://unitpay.ru)

Documentation https://unitpay.ru/doc

## Examples ##
These are just some quick examples. Check out the samples in [`/sample`](https://github.com/unitpay/php-sdk/blob/master/sample).
## Installation

The preferred way to install this extension is through [composer](https://getcomposer.org/download/).

Either run

```bash
$ php composer.phar require unitpay/php-sdk
```

or add

```
"unitpay/php-sdk": "^1.0"
```

to the ```require``` section of your `composer.json` file.


## Examples

These are just some quick examples. Check out the samples in [`/examples`](https://github.com/unitpay/php-sdk/blob/master/examples).

### Payment integration using UnitPay Form
```php
<?php
include ('../UnitPay.php');
require_once('vendor/autoload.php');

// Project Data
$secretKey = '9e977d0c0e1bc8f5cc9775a8cc8744f1';
Expand All @@ -24,14 +44,14 @@ $orderSum = 900;
$orderDesc = 'Payment for item "' . $itemName . '"';
$orderCurrency = 'RUB';

$unitPay = new UnitPay($secretKey);
$unitPay = new unitpay\UnitPay($secretKey);

$unitPay
->setBackUrl('http://domain.com')
->setCustomerEmail('customer@domain.com')
->setCustomerPhone('79001235555')
->setCashItems(array(
new CashItem($itemName, 1, $orderSum)
new unitpay\CashItem($itemName, 1, $orderSum)
));

$redirectUrl = $unitPay->form(
Expand All @@ -58,7 +78,7 @@ header('Content-Type: text/html; charset=UTF-8');
* @link https://unitpay.ru/doc#initPayment
*/

include ('../UnitPay.php');
require_once('vendor/autoload.php');

// Project Data
$projectId = 1;
Expand All @@ -73,7 +93,7 @@ $orderSum = 900;
$orderDesc = 'Payment for item "'.$itemName.'"';
$orderCurrency = 'RUB';

$unitPay = new UnitPay($secretKey);
$unitPay = new unitpay\UnitPay($secretKey);

/**
* Base params: account, desc, sum, currency, projectId, paymentType
Expand Down Expand Up @@ -134,7 +154,7 @@ if (isset($response->result->type)
*
* @link https://unitpay.ru/doc#confirmPayment
*/
include ('../UnitPay.php');
include ('vendor/autoload.php');

// Project Data
$projectId = 1;
Expand All @@ -149,7 +169,7 @@ $orderSum = 900;
$orderDesc = 'Payment for item "' . $itemName . '"';
$orderCurrency = 'RUB';

$unitPay = new UnitPay($secretKey);
$unitPay = new unitpay\UnitPay($secretKey);

try {
// Validate request (check ip address, signature and etc)
Expand Down Expand Up @@ -189,25 +209,6 @@ try {
}
```

## Installation

### Install composer package
Set up `composer.json` in your project directory:
```
{
"require":{"unitpay/php-sdk":"dev-master"}
}
```

Run [composer](http://getcomposer.org/doc/00-intro.md#installation):
```sh
$ php composer.phar install
```

### Direct download

Download [last version ](https://github.com/unitpay/php-sdk/archive/master.zip) , unzip and copy to your project folder.

## Contributing ##
## Contributing

Please feel free to contribute to this project! Pull requests and feature requests welcome!
Please feel free to contribute to this project! Pull requests and feature requests welcome!
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
}
],
"require":{
"php":">=5.3.0"
"php":">=5.4.0"
},
"autoload":{
"classmap":[
"./UnitPay.php"
]
"psr-4": {
"unitpay\\": "src"
}
}
}
4 changes: 2 additions & 2 deletions sample/handler.php → examples/handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
*/

require_once('./orderInfo.php');
require_once('../UnitPay.php');
require_once('../vendor/autoload.php');

$unitPay = new UnitPay($secretKey);
$unitPay = new unitpay\UnitPay($secretKey);

try {
// Validate request (check ip address, signature and etc)
Expand Down
4 changes: 2 additions & 2 deletions sample/initPaymentApi.php → examples/initPaymentApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
*/

require_once('./orderInfo.php');
require_once('../UnitPay.php');
require_once('../vendor/autoload.php');

$unitPay = new UnitPay($secretKey);
$unitPay = new unitpay\UnitPay($secretKey);

/**
* Base params: account, desc, sum, currency, projectId, paymentType
Expand Down
4 changes: 2 additions & 2 deletions sample/initPaymentForm.php → examples/initPaymentForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
*/

require_once('./orderInfo.php');
require_once('../UnitPay.php');
require_once('../vendor/autoload.php');

$unitPay = new UnitPay($secretKey);
$unitPay = new unitpay\UnitPay($secretKey);

$redirectUrl = $unitPay->form(
$publicId,
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions sample/paymentInfo.php → examples/paymentInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
*/

require_once('./orderInfo.php');
require_once('../UnitPay.php');
require_once('../vendor/autoload.php');

$unitPay = new UnitPay($secretKey);
$unitPay = new unitpay\UnitPay($secretKey);

$response = $unitPay->api('getPayment', [
'paymentId' => 3403575
Expand Down
72 changes: 72 additions & 0 deletions src/CashItem.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php
/**
* UnitPay Payment Module
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* @category UnitPay
* @package unitpay/unitpay
* @version 1.0.0
* @author UnitPay
* @copyright Copyright (c) 2015 UnitPay
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*
* EXTENSION INFORMATION
*
* UNITPAY API https://unitpay.ru/doc
*
*/

namespace unitpay;

/**
* Value object for paid goods
*/
class CashItem
{
private $name;

private $count;

private $price;

/**
* @param string $name
* @param int $count
* @param float $price
*/
public function __construct($name, $count, $price)
{
$this->name = $name;
$this->count = $count;
$this->price = $price;
}

/**
* @return string
*/
public function getName()
{
return $this->name;
}

/**
* @return int
*/
public function getCount()
{
return $this->count;
}

/**
* @return float
*/
public function getPrice()
{
return $this->price;
}
}
51 changes: 2 additions & 49 deletions UnitPay.php → src/UnitPay.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,54 +21,7 @@
*
*/


/**
* Value object for paid goods
*/
class CashItem
{
private $name;

private $count;

private $price;

/**
* @param string $name
* @param int $count
* @param float $price
*/
public function __construct($name, $count, $price)
{
$this->name = $name;
$this->count = $count;
$this->price = $price;
}

/**
* @return string
*/
public function getName()
{
return $this->name;
}

/**
* @return int
*/
public function getCount()
{
return $this->count;
}

/**
* @return float
*/
public function getPrice()
{
return $this->price;
}
}
namespace unitpay;

/**
* Payment method UnitPay process
Expand Down Expand Up @@ -343,4 +296,4 @@ public function getErrorHandlerResponse($message)
)
));
}
}
}