PHP code example of whitecube / multisafepay-php

1. Go to this page and download the library: Download whitecube/multisafepay-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

whitecube / multisafepay-php example snippets


$client = new Whitecube\MultiSafepay\Client('production', 'your-api-key');

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

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

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


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

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

composer