PHP code example of zfr / zfr-paymill

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

    

zfr / zfr-paymill example snippets


$client = new PaymillClient('my-api-key');

$details = $client->createOffer(array(
    'name'     => 'MyOffer',
    'amount'   => 500,
    'currency' => 'EUR',
    'interval' => '1 MONTH'
));

try {
    $client->createTransaction(array(
        'amount'   => 4000,
        'currency' => 'EUR',
        'token'    => '1234'
    ));
} catch (\ZfrPaymill\Exception\TransactionErrorException $exception) {
    // Seems the transaction failed, let's see why:
    $why = $exception->getMessage();

    // Let's also get the response to have more info:
    $response = $exception->getResponse();
} catch (\Exception $exception) {
    // Catch any other exception...
}
sh
php composer.phar