Skip to content

Commit fda38e1

Browse files
committed
Added start of API
1 parent 2f6eb38 commit fda38e1

14 files changed

+1154
-1
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/vendor/
2+
.idea
3+
.DS_Store

README.md

+84-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,85 @@
11
# multisafepay-php
2-
An unofficial wrapper for the MultiSafePay API.
2+
A wrapper for the MultiSafePay API.
3+
4+
## Installation
5+
6+
```
7+
composer require whitecube/multisafepay-php
8+
```
9+
10+
## Usage
11+
12+
You must specify two things before beginning to use the API:
13+
- The application environment (accepted values are `production` or `test`)
14+
- Your MultiSafepay API key
15+
16+
```php
17+
$client = new Whitecube\MultiSafepay\Client('production', 'your-api-key');
18+
19+
// Example: Get an existing order
20+
$order = $client->orders()->show('order-id');
21+
```
22+
23+
### Orders
24+
25+
The Orders API lives under the `orders` method on the client.
26+
```php
27+
$client->orders()->...
28+
```
29+
30+
#### Creating orders
31+
[See official docs.](https://docs.multisafepay.com/api/#create-an-order)
32+
Orders are represented by PHP Objects but can be submitted as regular associative arrays.
33+
34+
```php
35+
use Whitecube\MultiSafepay\Entities\Order;
36+
37+
$order = new Order('my-order-id')
38+
->type('redirect')
39+
->amount(20)
40+
->currency('EUR')
41+
->description('2 movie tickets')
42+
->paymentOptions([
43+
'notification_url' => 'http://www.example.com/client/notification?type=notification',
44+
'redirect_url' => 'http://www.example.com/client/notification?type=redirect',
45+
'cancel_url' => 'http://www.example.com/client/notification?type=cancel',
46+
'close_window' => ''
47+
]);
48+
49+
$client->orders()->create($order);
50+
51+
// Or as an associative array
52+
53+
$client->orders()->create([
54+
'order_id' => 'my-order-id',
55+
'type' => 'redirect',
56+
'amount' => 20,
57+
'currency' => 'EUR',
58+
'description' => '2 movie tickets',
59+
'payment_options' => [
60+
'notification_url' => 'http://www.example.com/client/notification?type=notification',
61+
'redirect_url' => 'http://www.example.com/client/notification?type=redirect',
62+
'cancel_url' => 'http://www.example.com/client/notification?type=cancel',
63+
'close_window' => ''
64+
]
65+
]);
66+
67+
```
68+
69+
#### Getting orders
70+
[See official docs.](https://docs.multisafepay.com/api/#retrieve-an-order)
71+
Fetch an existing order's information
72+
73+
```php
74+
$client->orders()->fetch('order-id');
75+
```
76+
77+
#### Updating orders
78+
[See official docs.](https://docs.multisafepay.com/api/#update-an-order)
79+
80+
```php
81+
$client->orders()->update('order-id', [
82+
'status' => 'completed',
83+
//...
84+
]);
85+
```

composer.json

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "whitecube/multisafepay-php",
3+
"description": "An unofficial wrapper for the MultiSafepay API.",
4+
"authors": [
5+
{
6+
"name": "Adrien Leloup",
7+
"email": "[email protected]"
8+
}
9+
],
10+
"require": {
11+
"php": ">=7.1.0",
12+
"guzzlehttp/guzzle": "^6.3",
13+
"php-http/message": "^1.8"
14+
},
15+
"autoload": {
16+
"psr-4": {
17+
"Whitecube\\MultiSafepay\\": "src/"
18+
}
19+
},
20+
"extra": {
21+
"laravel": {
22+
"providers": [
23+
"Whitecube\\MultiSafepay\\MultiSafepayServiceProvider"
24+
]
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)