<?php

include __DIR__ . '/../../vendor/autoload.php';
include "credentials.php";
//App url
$appUrl = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$returnUrl = $appUrl;
$cancelUrl = $appUrl;
$logoUrl = '';
//Create Checkout
$request = new \easyPaypal\Request(true, $creed['username'], $creed['password'], $creed['signature'], $returnUrl, $cancelUrl, $logoUrl);
$nvp = new \easyPaypal\Checkout();
$nvp->setRequest($request);
//Create sellers
$seller = new \easyPaypal\Seller();
//Add itens to sellers
$item1 = new \easyPaypal\Item('Texugo', 'um texugo', 40.0, 1);
$item2 = new \easyPaypal\Item('Texugo 2', 'outro texugo', 40.0, 1);
$seller->addItem($item1);
$seller->addItem($item2);
//Set request
$nvp->setParams($seller);
//If theres token do getExpressCheckoutDetails and doExpressCheckoutPayment
if (isset($_GET['token'])) {
    //getExpressCheckoutDetails
    $nvp->setToken($_GET['token']);
    $nvp->setMethod('getExpressCheckoutDetails');
    $response = $nvp->send();
    //doExpressCheckoutPayment
    if (isset($response['ACK']) && $response['ACK'] == 'Success') {
        $nvp->setPayerId($response['PAYERID']);
示例#2
0
 * É seu identificador interno, que pode ser utilizado para a PayPal para ajudá-lo a
 * identificar as transações durante as notificações.
 *
 * Defina a referencia ao criar um objeto Seller senão será usado uma String aleatória
 *
 */
//Referencia
$ref = null;
//App url
$appUrl = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$returnUrl = $appUrl;
$cancelUrl = $appUrl;
$logoUrl = '';
//Create Checkout
$request = new \easyPaypal\Request(true, $creed['username'], $creed['password'], $creed['signature'], $returnUrl, $cancelUrl, $logoUrl);
$checkout = new \easyPaypal\Checkout('expressCheckout');
$checkout->setRequest($request);
//set notify url
//$checkout->setNotifyUrl('url');
//Create sellers
$seller = new \easyPaypal\Seller();
$seller2 = new \easyPaypal\Seller();
//Add itens to sellers
$item1 = new \easyPaypal\Item('Texugo', 'um texugo', 40.0, 1);
$item1->setCategory('Digital');
$item2 = new \easyPaypal\Item('Texugo 2', 'outro texugo', 40.0, 1);
$seller->addItem($item1);
$seller2->addItem($item2);
$sellers = array($seller, $seller2);
//Set params
$checkout->setParams($seller);