PHP code example of mramitict / coinpayment

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

    

mramitict / coinpayment example snippets


// add directly from the app 
$app->register(\Mramitict\LaravelCoinpayments\Providers\LaravelCoinpaymentsServiceProvider::class);

'providers' => [
    // Other Service Providers

    \Mramitict\LaravelCoinpayments\Providers\LaravelCoinpaymentsServiceProvider::class,
],


return array(

    // prefix to each of the tables in the database
    'database_prefix' => env('COINPAYMENTS_DB_PREFIX', 'cp_'),

    'merchant_id' => env('COINPAYMENTS_MERCHANT_ID'),

    // Your API public key associated with your coinpayments account
    'public_key' => env('COINPAYMENTS_PUBLIC_KEY'),

    // Your API private key associated with your coinpayments account
    'private_key' => env('COINPAYMENTS_PRIVATE_KEY'),

    // This is used to verify that an IPN is from us, use a good random string nobody can guess.
    'ipn_secret' => env('COINPAYMENTS_IPN_SECRET'),

    // URL for your IPN callbacks. If not set it will use the IPN URL in your Edit Settings page if you have one set.
    'ipn_url' => env('COINPAYMENTS_IPN_URL'),

    // The format of response to return, json or xml. (default: json)
    'format' => env('COINPAYMENTS_API_FORMAT', 'json'),

    // ALL logs all requests, ERROR logs only errors, and NONE never
    'log_level' => Log::LEVEL_ERROR,
);



\Coinpayments::createTransactionSimple($cost, $currency_base, $currency_received, $extra_details);


try {
    \Coinpayments::validateIPNRequest($request);
    
    // do soemthing with the completed transaction
} catch (\Exception $e) {
    
    // transaction not completed.
}
shell
php artisan migrate