PHP code example of terminal42 / swissbilling-api

1. Go to this page and download the library: Download terminal42/swissbilling-api 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/ */

    

terminal42 / swissbilling-api example snippets


use Terminal42\SwissbillingApi\Client;
use Terminal42\SwissbillingApi\Api\ApiFactory;
use Terminal42\SwissbillingApi\Type\Debtor;
use Terminal42\SwissbillingApi\Type\Merchant;
use Terminal42\SwissbillingApi\Type\InvoiceItem;
use Terminal42\SwissbillingApi\Type\Transaction;
use Terminal42\SwissbillingApi\Type\TransactionStatus;

$client = new Client(new ApiFactory());

$merchant = new Merchant('user', 'password', 'success_url', 'cancel_url', 'error_url');

$transaction = new Transaction();
// fill in the 

$merchant = new Merchant('user', 'password', 'success_url', 'cancel_url', 'error_url');
$client = new Client(new ApiFactory(), $merchant);

// No need to pass the merchant anymore
$status = $client->request($transaction, $debtor, $items);