escapework/tray-php

Library PHP pra integrar com o Tray Checkout

0.1.2 2015-06-29 16:46 UTC

This package is auto-updated.

Last update: 2024-10-29 04:03:54 UTC


README

Library PHP pra integrar com o Tray Checkout.

Instalação

Adiciona a linha abaixo no seu composer.json e execute um composer update.

    "require": {
        "escapework/tray-php": "0.1.*"
    }

Criando transações

use EscapeWork\Tray\Transaction;

$transaction = new Transaction();
$transaction->setOrderNumber('seu-id-do-pedido');
$transaction->setPriceDiscount(0);
$transaction->setUrlSeller('http://seu-site.com/url-de-retorno');
$transaction->setUrlNotification('http://seu-site.com/url-de-notificacao');
$transaction->setPostalCodeSeller('91780010');
$transaction->setShippingType('Grátis');
$transaction->setShippingPrice(0);

# produtos
$transaction->addProduct(array(
    'code'        => 'your-product-code',
    'description' => 'your-product-description',
    'quantity'    => 1,
    'price_unit'  => 'your-product-price',
));

$transaction->create();

$redirectUrl = $transaction->getUrl() . $transaction->getTokenTransaction();

Depois disto, você só precisa redirecionar o usuário para a $redirectUrl.

Notificação de status

$transaction = new Transaction();
$transaction->setTokenTransaction('token-da-notificacao');
$transaction->notification();


# depois disso, você pode consultar tudo isto:
$transaction->getOrderNumber();
$transaction->getFree();
$transaction->getTransactionId();
$transaction->getStatusId();
$transaction->getStatusName();
$transaction->getTokenTransaction();

# payment
$transaction->payment->getPricePayment();
$transaction->payment->getPaymentResponse();
$transaction->payment->getUrlPayment();
$transaction->payment->getTid();
$transaction->payment->getSplit();
$transaction->payment->getPaymentMethodId();
$transaction->payment->getPaymentMethodName();
$transaction->payment->getLinhaDigitavel();

Referências

Licença

MIT License.