-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 08c5336
Showing
17 changed files
with
747 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/vendor | ||
/examples/authentication.json | ||
composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 Satispay <business@satispay.com> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Satispay GBusiness API PHP SDK | ||
[![Packagist Version](https://img.shields.io/packagist/v/satispay/gbusiness-api-php-sdk.svg?style=flat-square)](https://packagist.org/packages/satispay/gbusiness-api-php-sdk) | ||
[![Packagist Downloads](https://img.shields.io/packagist/dt/satispay/gbusiness-api-php-sdk.svg?style=flat-square)](https://packagist.org/packages/satispay/gbusiness-api-php-sdk) | ||
|
||
## Installation | ||
Run the following command: | ||
|
||
```bash | ||
composer require satispay/gbusiness-api-php-sdk | ||
``` | ||
|
||
If you do not wish to use Composer, import the `init.php` file. | ||
|
||
```php | ||
require_once("/path/init.php"); | ||
``` | ||
|
||
## Documentation | ||
https://developers.satispay.com | ||
|
||
## Authenticate with RSA Signature | ||
Sign in to your [Dashboard](https://business.satispay.com) at [business.satispay.com](https://business.satispay.com), click "Negozi Online" or "Negozi Fisici", and then click on "Genera un token di attivazione" to generate an activation token. | ||
|
||
Use the activation token with the `authenticateWithToken` function to generate and exchange a pair of RSA keys. | ||
|
||
Save the keys in your database or in a **safe place** not accesibile from your website. | ||
```php | ||
// Authenticate and generate the keys | ||
$authentication = \SatispayGBusiness\Api::authenticateWithToken("XXXXXX"); | ||
|
||
// Export keys | ||
$publicKey = $authentication->publicKey; | ||
$privateKey = $authentication->privateKey; | ||
$keyId = $authentication->keyId; | ||
``` | ||
|
||
Reuse the keys after authentication. | ||
```php | ||
// Keys variables | ||
$publicKey = "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhk..."; | ||
$privateKey = "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBg..."; | ||
$keyId = "ldg9sbq283og7ua1abpj989kbbm2g60us6f18c1sciq..."; | ||
|
||
// Set keys | ||
\SatispayGBusiness\Api::setPublicKey($publicKey); | ||
\SatispayGBusiness\Api::setPrivateKey($privateKey); | ||
\SatispayGBusiness\Api::setKeyId($keyId); | ||
|
||
// Test the authentication | ||
\SatispayGBusiness\Api::testAuthentication(); | ||
``` | ||
|
||
## Enable Sandbox | ||
To enable sandbox use `setSandbox` function. | ||
```php | ||
\SatispayGBusiness\Api::setSandbox(true); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"name": "satispay/gbusiness-api-php-sdk", | ||
"description": "Satispay GBusiness API PHP SDK", | ||
"license": "MIT", | ||
"keywords": [ | ||
"satispay", | ||
"gbusiness", | ||
"api", | ||
"php", | ||
"sdk" | ||
], | ||
"homepage": "https://www.satispay.com", | ||
"version": "1.0.0", | ||
"authors": [ | ||
{ | ||
"name": "Satispay", | ||
"homepage": "https://www.satispay.com" | ||
} | ||
], | ||
"require": { | ||
"php": ">=5.4.0", | ||
"ext-curl": "*", | ||
"ext-json": "*", | ||
"ext-mbstring": "*" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"SatispayGBusiness\\": "lib/" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
require_once("../init.php"); | ||
|
||
\SatispayGBusiness\Api::setSandbox(true); | ||
|
||
$authentication = \SatispayGBusiness\Api::authenticateWithToken("WG5MUC"); | ||
|
||
$publicKey = $authentication->publicKey; | ||
$privateKey = $authentication->privateKey; | ||
$keyId = $authentication->keyId; | ||
|
||
file_put_contents("authentication.json", json_encode(array( | ||
"public_key" => $publicKey, | ||
"private_key" => $privateKey, | ||
"key_id" => $keyId | ||
), JSON_PRETTY_PRINT)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
require_once("../init.php"); | ||
|
||
\SatispayGBusiness\Api::setSandbox(true); | ||
|
||
$authData = json_decode(file_get_contents("authentication.json")); | ||
|
||
\SatispayGBusiness\Api::setPublicKey($authData->public_key); | ||
\SatispayGBusiness\Api::setPrivateKey($authData->private_key); | ||
\SatispayGBusiness\Api::setKeyId($authData->key_id); | ||
|
||
$payment = \SatispayGBusiness\Payment::create(array( | ||
"flow" => "MATCH_CODE", | ||
"amount_unit" => 199, | ||
"currency" => "EUR" | ||
)); | ||
|
||
var_dump($payment); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
require_once("../init.php"); | ||
|
||
\SatispayGBusiness\Api::setSandbox(true); | ||
|
||
$authData = json_decode(file_get_contents("authentication.json")); | ||
|
||
\SatispayGBusiness\Api::setPublicKey($authData->public_key); | ||
\SatispayGBusiness\Api::setPrivateKey($authData->private_key); | ||
\SatispayGBusiness\Api::setKeyId($authData->key_id); | ||
|
||
$consumer = \SatispayGBusiness\Consumer::get("+390000000000"); | ||
|
||
var_dump($consumer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
require_once("../init.php"); | ||
|
||
\SatispayGBusiness\Api::setSandbox(true); | ||
|
||
$authData = json_decode(file_get_contents("authentication.json")); | ||
|
||
\SatispayGBusiness\Api::setPublicKey($authData->public_key); | ||
\SatispayGBusiness\Api::setPrivateKey($authData->private_key); | ||
\SatispayGBusiness\Api::setKeyId($authData->key_id); | ||
|
||
$payment = \SatispayGBusiness\Payment::get("5f11eb3d-e442-441c-af7c-7c1d707e1f4e"); | ||
|
||
var_dump($payment); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
require_once("../init.php"); | ||
|
||
\SatispayGBusiness\Api::setSandbox(true); | ||
|
||
$authData = json_decode(file_get_contents("authentication.json")); | ||
|
||
\SatispayGBusiness\Api::setPublicKey($authData->public_key); | ||
\SatispayGBusiness\Api::setPrivateKey($authData->private_key); | ||
\SatispayGBusiness\Api::setKeyId($authData->key_id); | ||
|
||
$payments = \SatispayGBusiness\Payment::all(); | ||
|
||
var_dump($payments); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
require_once("../init.php"); | ||
|
||
\SatispayGBusiness\Api::setSandbox(true); | ||
|
||
$authData = json_decode(file_get_contents("authentication.json")); | ||
|
||
\SatispayGBusiness\Api::setSecurityBearer($authData->security_bearer); | ||
|
||
$result = \SatispayGBusiness\Api::testAuthentication(); | ||
|
||
var_dump($result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
require_once("../init.php"); | ||
|
||
\SatispayGBusiness\Api::setSandbox(true); | ||
|
||
$authData = json_decode(file_get_contents("authentication.json")); | ||
|
||
\SatispayGBusiness\Api::setPublicKey($authData->public_key); | ||
\SatispayGBusiness\Api::setPrivateKey($authData->private_key); | ||
\SatispayGBusiness\Api::setKeyId($authData->key_id); | ||
|
||
$result = \SatispayGBusiness\Api::testAuthentication(); | ||
|
||
var_dump($result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
require_once("../init.php"); | ||
|
||
\SatispayGBusiness\Api::setSandbox(true); | ||
|
||
$authData = json_decode(file_get_contents("authentication.json")); | ||
|
||
\SatispayGBusiness\Api::setPublicKey($authData->public_key); | ||
\SatispayGBusiness\Api::setPrivateKey($authData->private_key); | ||
\SatispayGBusiness\Api::setKeyId($authData->key_id); | ||
|
||
$payment = \SatispayGBusiness\Payment::create(array( | ||
"flow" => "MATCH_CODE", | ||
"amount_unit" => 199, | ||
"currency" => "EUR" | ||
)); | ||
|
||
var_dump($payment); | ||
|
||
$upayment = \SatispayGBusiness\Payment::update($payment->id, array( | ||
"action" => "CANCEL" | ||
)); | ||
|
||
var_dump($upayment); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
require_once(dirname(__FILE__) . "/lib/Api.php"); | ||
|
||
require_once(dirname(__FILE__) . "/lib/Payment.php"); | ||
require_once(dirname(__FILE__) . "/lib/Request.php"); | ||
require_once(dirname(__FILE__) . "/lib/Consumer.php"); |
Oops, something went wrong.