escapework/tray-php

PHP 库,用于集成 Tray Checkout

0.1.2 2015-06-29 16:46 UTC

This package is auto-updated.

Last update: 2024-08-29 03:29:09 UTC


README

PHP 库,用于集成 Tray Checkout

安装

在您的 composer.json 文件中添加以下行,并执行 composer update

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

创建交易

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();

之后,您只需将用户重定向到 $redirectUrl

状态通知

$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();

参考

许可证

MIT 许可证。