PHP code example of inttegro / sdk

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

    

inttegro / sdk example snippets




nttegro\APIError;
use Inttegro\Client;
use Inttegro\Money\Currency;
use Inttegro\Price\InlineParams;
use Inttegro\Product\Type;

$inttegro = new Client(getenv('INTTEGRO_API_KEY'));

try {
    $order = $inttegro->orders->create([
        'request_meta' => ['idempotency_key' => 'checkout-cart-123'],
        'customer_data' => [
            'name' => 'Akua Mensah',
            'email_address' => '[email protected]',
            'phone_number' => '+233544998605',
        ],
        'finalize' => true,
        'checkout_settings' => [
            'redirect_url' => 'https://example.com/orders/complete',
            'cancel_url' => 'https://example.com/cart',
        ],
        'line_items' => [[
            'type' => 'product',
            'product' => [
                'type' => Type::Digital->value,
                'name' => 'Monthly subscription',
                'quantity' => 1,
                'price' => new InlineParams(
                    currency: Currency::GHS,
                    value: 5000,
                ),
            ],
        ]],
    ]);

    $checkoutUrl = $order->invoice?->format?->web?->url
        ?? throw new RuntimeException('Order did not 

$inttegro = new Client(
    apiKey: getenv('INTTEGRO_API_KEY'),
    tracerProvider: $tracerProvider,
    propagator: $propagator,
);

use Inttegro\Client;
use Inttegro\ErrorReport;

$inttegro = new Client(
    apiKey: getenv('INTTEGRO_API_KEY'),
    errorReporter: static fn (ErrorReport $report) => $errorCollector->enqueue($report),
);

use Inttegro\Order\Order;
use Inttegro\Payment\Payment;
use Inttegro\Payment\Status as PaymentStatus;
use Inttegro\Product\Product;
use Inttegro\Product\Type as ProductType;

$order = $inttegro->orders->lookup($orderId);
$product = $inttegro->products->lookup($productId);

assert($order instanceof Order);
assert($product instanceof Product);
assert($order->payment === null || $order->payment instanceof Payment);

if ($order->payment?->status === PaymentStatus::Paid->value) {
    // Fulfill the order.
}

if ($product->type === ProductType::Digital->value) {
    // Deliver the digital product.
}

$paymentId = $transaction->paymentId;

$order = $inttegro->orders->pay([
    'order_id' => $orderId,
    'payment_method_id' => $paymentMethodId,
]);
bash
sha256sum --check SHA256SUMS
gh attestation verify inttegro-sdk-php-7.0.0.tar.gz \
  --repo inttegro/inttegro-sdk-php