PHP code example of purt09 / interkassa

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

    

purt09 / interkassa example snippets


{
    "  "purt09/interkassa": "@dev"
    },
}



// The following parameters are provided by interkassa
$shop_id    = '...';
$secret_key = '...';

// Create a shop
$shop = InterkassaShop::factory(array(
    'id'         => $shop_id,
    'secret_key' => $secret_key
));

// Create a payment
$payment_id     = '...'; // Your payment id
$payment_amount = '...'; // The amount to charge your shop's user
$payment_desc   = '...'; // Payment description

$payment = $shop->createPayment(array(
    'id'          => $payment_id,
    'amount'      => $payment_amount,
    'description' => $payment_desc
));



// ... create and configure the payment object




$payment = $shop->createPayment(array(
    // ... usual payment data
    'status_url' => 'http://example.com/ik-status.php'
));



// ... initialize library as usual

$shop = InterkassaShop::factory(array(
    'id'         => $shop_id,
    'secret_key' => $secret_key
));

try {
    $status = $shop->receiveStatus($_POST); // POST is used by default
} catch (InterkassaException $e) {
    // The signature was incorrect, send a 400 error to interkassa
    // They should resend payment status request until they receive a 200 status
    header('HTTP/1.0 400 Bad Request');
    exit;
}

$payment = $status->getPayment();