whitecube/multisafepay-php

There is no license information available for the latest version (v0.1.0) of this package.

An unofficial wrapper for the MultiSafepay API.

v0.1.0 2019-09-09 09:35 UTC

This package is auto-updated.

Last update: 2024-12-12 05:57:49 UTC


README

A wrapper for the MultiSafePay API.

Installation

composer require whitecube/multisafepay-php

Usage

You must specify two things before beginning to use the API:

  • The application environment (accepted values are production or test)
  • Your MultiSafepay API key
$client = new Whitecube\MultiSafepay\Client('production', 'your-api-key');

// Example: Get an existing order
$order = $client->orders()->fetch('order-id');

Orders

The Orders API lives under the orders method on the client.

$client->orders()->...

Creating 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' => ''
    ]
]);

Getting orders

See official docs. Fetch an existing order's information

$client->orders()->fetch('order-id');

Updating orders

See official docs.

$client->orders()->update('order-id', [
    'status' => 'completed', 
    //...
]);