PHP code example of jerfeson / omnipay-pagseguro

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

    

jerfeson / omnipay-pagseguro example snippets


// purchase
    
$params = $this->getParams();
$gateway = $this->getGateway();

$items = [];
foreach ($params->items as $item) {
    $items[] = [
        'number' => $item->id, // 1, 2
        'quantity' => $item->quantity, // 10, 20
        'name' => $item->name, // sample product 1, sample product 2
        'description' => $item->description, // sample description 1, sample description 2
        'price' => $item->price, // 10.00, 40.00
        'weight' => $item->weight // 1, 1
    ];
}

$response = $gateway->purchase(
    [
        'transactionId' => $params->id, // 1
        'amount' => $params->value, //50.00
        'currency' => $params->currency, //BRL
        'returnUrl' => 'http://example.com/return',
        'cancelUrl' => 'http://example.com/cancel',
        'NotifyUrl' => 'http://example.com/notify',
        'items' => $items
    ]
)->send();