A wrapper for the MultiSafePay API.
composer require whitecube/multisafepay-php
You must specify two things before beginning to use the API:
- The application environment (accepted values are
production
ortest
) - Your MultiSafepay API key
$client = new Whitecube\MultiSafepay\Client('production', 'your-api-key');
// Example: Get an existing order
$order = $client->orders()->fetch('order-id');
The Orders API lives under the orders
method on the client.
$client->orders()->...
See official docs.
Orders are represented by PHP Objects but can be submitted as regular associative arrays.
use Whitecube\MultiSafepay\Entities\Order;
$order = new Order('my-order-id')
->type('redirect')
->amount(20)
->currency('EUR')
->description('2 movie tickets')
->paymentOptions([
'notification_url' => 'http://www.example.com/client/notification?type=notification',
'redirect_url' => 'http://www.example.com/client/notification?type=redirect',
'cancel_url' => 'http://www.example.com/client/notification?type=cancel',
'close_window' => ''
]);
$client->orders()->create($order);
// Or as an associative array
$client->orders()->create([
'order_id' => 'my-order-id',
'type' => 'redirect',
'amount' => 20,
'currency' => 'EUR',
'description' => '2 movie tickets',
'payment_options' => [
'notification_url' => 'http://www.example.com/client/notification?type=notification',
'redirect_url' => 'http://www.example.com/client/notification?type=redirect',
'cancel_url' => 'http://www.example.com/client/notification?type=cancel',
'close_window' => ''
]
]);
See official docs. Fetch an existing order's information
$client->orders()->fetch('order-id');
$client->orders()->update('order-id', [
'status' => 'completed',
//...
]);