Tray Checkout - PHP
Library PHP pra integrar com o Tray Checkout., (*1)
Instalação
Adiciona a linha abaixo no seu composer.json e execute um composer update., (*2)
"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., (*3)
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
- https://static.traycheckout.com.br/pdf/TrayCheckout-Manual-v1.0.pdf
Licença
MIT License., (*4)