-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f7d062e
commit 17c3c2f
Showing
66 changed files
with
1,784 additions
and
2,949 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,5 @@ | |
.DS_Store | ||
.swp | ||
composer.lock | ||
phpunit.xml | ||
build | ||
vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,55 @@ | ||
<?php | ||
|
||
date_default_timezone_set( 'America/Sao_Paulo' ); | ||
date_default_timezone_set('America/Sao_Paulo'); | ||
|
||
require __DIR__ . '/../vendor/autoload.php'; | ||
require __DIR__ . '/logger.php'; | ||
|
||
use RodrigoPedra\ClearSaleID\Service\Analysis; | ||
use RodrigoPedra\ClearSaleID\Service\Connector; | ||
use RodrigoPedra\ClearSaleID\Environment\Sandbox; | ||
use RodrigoPedra\ClearSaleID\Service\Integration; | ||
use RodrigoPedra\ClearSaleID\Entity\Request\Item; | ||
use RodrigoPedra\ClearSaleID\Entity\Request\Order; | ||
use RodrigoPedra\ClearSaleID\Entity\Request\Phone; | ||
use RodrigoPedra\ClearSaleID\Entity\Request\AbstractCustomer; | ||
use RodrigoPedra\ClearSaleID\Entity\Request\Address; | ||
use RodrigoPedra\ClearSaleID\Entity\Request\Payment; | ||
use RodrigoPedra\ClearSaleID\Entity\Request\Passenger; | ||
use RodrigoPedra\ClearSaleID\Entity\Request\Connection; | ||
use RodrigoPedra\ClearSaleID\Entity\Request\FingerPrint; | ||
use RodrigoPedra\ClearSaleID\Entity\Request\AbstractCustomer; | ||
use RodrigoPedra\ClearSaleID\Entity\Request\CustomerBillingData; | ||
use RodrigoPedra\ClearSaleID\Entity\Request\CustomerShippingData; | ||
use RodrigoPedra\ClearSaleID\Entity\Request\FingerPrint; | ||
use RodrigoPedra\ClearSaleID\Entity\Request\Item; | ||
use RodrigoPedra\ClearSaleID\Entity\Request\Order; | ||
use RodrigoPedra\ClearSaleID\Entity\Request\Passenger; | ||
use RodrigoPedra\ClearSaleID\Entity\Request\Payment; | ||
use RodrigoPedra\ClearSaleID\Entity\Request\Phone; | ||
use RodrigoPedra\ClearSaleID\Environment\Sandbox; | ||
use RodrigoPedra\ClearSaleID\Service\Analysis; | ||
use RodrigoPedra\ClearSaleID\Service\Connector; | ||
use RodrigoPedra\ClearSaleID\Service\Integration; | ||
|
||
try { | ||
// Dados da Integração com a ClearSale | ||
$entityCode = '<CLEARSALE_ENTITY_CODE>'; | ||
|
||
// ambiente | ||
$environment = new Sandbox( $entityCode, new ExampleLogger ); | ||
$environment->setDebug( true ); | ||
$environment = new Sandbox($entityCode, new ExampleLogger()); | ||
$environment->setDebug(true); | ||
|
||
// serviços | ||
$connector = new Connector( $environment ); | ||
$integration = new Integration( $connector ); | ||
$clearSale = new Analysis( $integration ); | ||
$connector = new Connector($environment); | ||
$integration = new Integration($connector); | ||
$clearSale = new Analysis($integration); | ||
|
||
// Dados do Pedido | ||
$fingerPrint = new FingerPrint( createSessionId() ); | ||
$orderId = createOrderId(); | ||
$date = new \DateTime(); | ||
$email = '[email protected]'; | ||
$totalItems = 10.0; | ||
$totalOrder = 17.5; | ||
$fingerPrint = new FingerPrint(createSessionId()); | ||
$orderId = createOrderId(); | ||
$date = new \DateTime(); | ||
$email = '[email protected]'; | ||
$totalItems = 10.0; | ||
$totalOrder = 17.5; | ||
$quantityInstallments = 1; | ||
$ip = '127.0.0.1'; | ||
$origin = 'WEB'; | ||
$customerBillingData = createCustomerBillingData(); | ||
$ip = '127.0.0.1'; | ||
$origin = 'WEB'; | ||
$customerBillingData = createCustomerBillingData(); | ||
$customerShippingData = createCustomerShippingData(); | ||
$item = Item::create( 1, 'Adaptador USB', 10.0, 1 ); | ||
$payment = Payment::create( Payment::BOLETO_BANCARIO, new \DateTime(), 17.5 ); | ||
$item = Item::create(1, 'Adaptador USB', 10.0, 1); | ||
$payment = Payment::create(Payment::BOLETO_BANCARIO, new \DateTime(), 17.5); | ||
|
||
$passenger = Passenger::create( 'Fulano da Silva', Passenger::DOCUMENT_TYPE_CPF, '63165236372' ); | ||
$passenger = Passenger::create('Fulano da Silva', Passenger::DOCUMENT_TYPE_CPF, '63165236372'); | ||
$connection = createConnection(); | ||
|
||
// Criar Pedido | ||
|
@@ -72,7 +72,7 @@ | |
); | ||
|
||
// Enviar pedido para análise | ||
$response = $clearSale->analysis( $order ); | ||
$response = $clearSale->analysis($order); | ||
|
||
// Resultado da análise | ||
switch ($response) { | ||
|
@@ -91,10 +91,10 @@ | |
echo 'Erro' . PHP_EOL; | ||
} | ||
|
||
if ($clearSale->updateOrderStatus( $orderId, Analysis::UPDATE_ORDER_STATUS_ORDER_APPROVED ) === true) { | ||
if ($clearSale->updateOrderStatus($orderId, Analysis::UPDATE_ORDER_STATUS_ORDER_APPROVED) === true) { | ||
echo 'Status do pedido atualizado'; | ||
} | ||
} catch ( Exception $e ) { | ||
} catch (Exception $e) { | ||
echo 'ERRO', PHP_EOL, PHP_EOL; | ||
|
||
// Erro genérico da análise | ||
|
@@ -103,22 +103,22 @@ | |
|
||
function createOrderId() | ||
{ | ||
return sprintf( 'TEST-%s', createSessionId() ); | ||
return \sprintf('TEST-%s', createSessionId()); | ||
} | ||
|
||
function createSessionId() | ||
{ | ||
return md5( uniqid( rand(), true ) ); | ||
return \md5(\uniqid(\rand(), true)); | ||
} | ||
|
||
function createCustomerBillingData() | ||
{ | ||
$id = '1'; | ||
$id = '1'; | ||
$legalDocument = '63165236372'; | ||
$name = 'Fulano da Silva'; | ||
$address = createAddress(); | ||
$phone = Phone::create( Phone::COMERCIAL, '11', '37288788' ); | ||
$birthDate = new \DateTime( '1980-01-01' ); | ||
$name = 'Fulano da Silva'; | ||
$address = createAddress(); | ||
$phone = Phone::create(Phone::COMERCIAL, '11', '37288788'); | ||
$birthDate = new \DateTime('1980-01-01'); | ||
|
||
return CustomerBillingData::create( | ||
$id, | ||
|
@@ -133,11 +133,11 @@ function createCustomerBillingData() | |
|
||
function createCustomerShippingData() | ||
{ | ||
$id = '1'; | ||
$id = '1'; | ||
$legalDocument = '63165236372'; | ||
$name = 'Fulano da Silva'; | ||
$address = createAddress(); | ||
$phone = Phone::create( Phone::COMERCIAL, '11', '37288788' ); | ||
$name = 'Fulano da Silva'; | ||
$address = createAddress(); | ||
$phone = Phone::create(Phone::COMERCIAL, '11', '37288788'); | ||
|
||
return CustomerShippingData::create( | ||
$id, | ||
|
@@ -151,27 +151,27 @@ function createCustomerShippingData() | |
|
||
function createAddress() | ||
{ | ||
$street = 'Rua José de Oliveira Coutinho'; | ||
$number = 151; | ||
$county = 'Barra Funda'; | ||
$street = 'Rua José de Oliveira Coutinho'; | ||
$number = 151; | ||
$county = 'Barra Funda'; | ||
$country = 'Brasil'; | ||
$city = 'São Paulo'; | ||
$state = 'SP'; | ||
$zip = '01144020'; | ||
$city = 'São Paulo'; | ||
$state = 'SP'; | ||
$zip = '01144020'; | ||
|
||
return Address::create( $street, $number, $county, $country, $city, $state, $zip ); | ||
return Address::create($street, $number, $county, $country, $city, $state, $zip); | ||
} | ||
|
||
function createConnection() | ||
{ | ||
$company = 'TAM'; | ||
$flightNumber = '3356'; | ||
$flightDate = new \DateTime( '2015-09-14 11:55:00' ); | ||
$class = 'Econômica'; | ||
$from = 'GRU'; | ||
$to = 'JPA'; | ||
$departureDate = new \DateTime( '2015-09-14 11:55:00' ); | ||
$arrivalDate = new \DateTime( '2015-09-14 15:33:00' ); | ||
$company = 'TAM'; | ||
$flightNumber = '3356'; | ||
$flightDate = new \DateTime('2015-09-14 11:55:00'); | ||
$class = 'Econômica'; | ||
$from = 'GRU'; | ||
$to = 'JPA'; | ||
$departureDate = new \DateTime('2015-09-14 11:55:00'); | ||
$arrivalDate = new \DateTime('2015-09-14 15:33:00'); | ||
|
||
return Connection::create( | ||
$company, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,51 @@ | ||
<?php | ||
|
||
date_default_timezone_set( 'America/Sao_Paulo' ); | ||
date_default_timezone_set('America/Sao_Paulo'); | ||
|
||
require __DIR__ . '/../vendor/autoload.php'; | ||
require __DIR__ . '/logger.php'; | ||
|
||
use RodrigoPedra\ClearSaleID\Service\Analysis; | ||
use RodrigoPedra\ClearSaleID\Service\Connector; | ||
use RodrigoPedra\ClearSaleID\Environment\Sandbox; | ||
use RodrigoPedra\ClearSaleID\Service\Integration; | ||
use RodrigoPedra\ClearSaleID\Entity\Request\Item; | ||
use RodrigoPedra\ClearSaleID\Entity\Request\Order; | ||
use RodrigoPedra\ClearSaleID\Entity\Request\Phone; | ||
use RodrigoPedra\ClearSaleID\Entity\Request\Address; | ||
use RodrigoPedra\ClearSaleID\Entity\Request\Payment; | ||
use RodrigoPedra\ClearSaleID\Entity\Request\FingerPrint; | ||
use RodrigoPedra\ClearSaleID\Entity\Request\AbstractCustomer; | ||
use RodrigoPedra\ClearSaleID\Entity\Request\Address; | ||
use RodrigoPedra\ClearSaleID\Entity\Request\CustomerBillingData; | ||
use RodrigoPedra\ClearSaleID\Entity\Request\CustomerShippingData; | ||
use RodrigoPedra\ClearSaleID\Entity\Request\FingerPrint; | ||
use RodrigoPedra\ClearSaleID\Entity\Request\Item; | ||
use RodrigoPedra\ClearSaleID\Entity\Request\Order; | ||
use RodrigoPedra\ClearSaleID\Entity\Request\Payment; | ||
use RodrigoPedra\ClearSaleID\Entity\Request\Phone; | ||
use RodrigoPedra\ClearSaleID\Environment\Sandbox; | ||
use RodrigoPedra\ClearSaleID\Service\Analysis; | ||
use RodrigoPedra\ClearSaleID\Service\Connector; | ||
use RodrigoPedra\ClearSaleID\Service\Integration; | ||
|
||
try { | ||
// Dados da Integração com a ClearSale | ||
$entityCode = '<CLEARSALE_ENTITY_CODE>'; | ||
|
||
// ambiente | ||
$environment = new Sandbox( $entityCode, new ExampleLogger ); | ||
$environment->setDebug( true ); | ||
$environment = new Sandbox($entityCode, new ExampleLogger()); | ||
$environment->setDebug(true); | ||
|
||
// serviços | ||
$connector = new Connector( $environment ); | ||
$integration = new Integration( $connector ); | ||
$clearSale = new Analysis( $integration ); | ||
$connector = new Connector($environment); | ||
$integration = new Integration($connector); | ||
$clearSale = new Analysis($integration); | ||
|
||
// Dados do Pedido | ||
$fingerPrint = new FingerPrint( createSessionId() ); | ||
$orderId = createOrderId(); | ||
$date = new \DateTime(); | ||
$email = '[email protected]'; | ||
$totalItems = 10.0; | ||
$totalOrder = 17.5; | ||
$fingerPrint = new FingerPrint(createSessionId()); | ||
$orderId = createOrderId(); | ||
$date = new \DateTime(); | ||
$email = '[email protected]'; | ||
$totalItems = 10.0; | ||
$totalOrder = 17.5; | ||
$quantityInstallments = 1; | ||
$ip = '127.0.0.1'; | ||
$origin = 'WEB'; | ||
$customerBillingData = createCustomerBillingData(); | ||
$ip = '127.0.0.1'; | ||
$origin = 'WEB'; | ||
$customerBillingData = createCustomerBillingData(); | ||
$customerShippingData = createCustomerShippingData(); | ||
$item = Item::create( 1, 'Adaptador USB', 10.0, 1 ); | ||
$payment = Payment::create( Payment::BOLETO_BANCARIO, new \DateTime(), 17.5 ); | ||
$item = Item::create(1, 'Adaptador USB', 10.0, 1); | ||
$payment = Payment::create(Payment::BOLETO_BANCARIO, new \DateTime(), 17.5); | ||
|
||
// Criar Pedido | ||
$order = Order::createEcommerceOrder( | ||
|
@@ -64,7 +64,7 @@ | |
$item | ||
); | ||
|
||
$response = $clearSale->analysis( $order ); | ||
$response = $clearSale->analysis($order); | ||
|
||
// Resultado da análise | ||
switch ($response) { | ||
|
@@ -83,10 +83,10 @@ | |
echo 'Erro' . PHP_EOL; | ||
} | ||
|
||
if ($clearSale->updateOrderStatus( $orderId, Analysis::UPDATE_ORDER_STATUS_ORDER_APPROVED ) === true) { | ||
if ($clearSale->updateOrderStatus($orderId, Analysis::UPDATE_ORDER_STATUS_ORDER_APPROVED) === true) { | ||
echo 'Status do pedido atualizado'; | ||
} | ||
} catch ( Exception $e ) { | ||
} catch (Exception $e) { | ||
echo 'ERRO', PHP_EOL, PHP_EOL; | ||
|
||
// Erro genérico da análise | ||
|
@@ -95,22 +95,22 @@ | |
|
||
function createOrderId() | ||
{ | ||
return sprintf( 'TEST-%s', createSessionId() ); | ||
return \sprintf('TEST-%s', createSessionId()); | ||
} | ||
|
||
function createSessionId() | ||
{ | ||
return md5( uniqid( rand(), true ) ); | ||
return \md5(\uniqid(\rand(), true)); | ||
} | ||
|
||
function createCustomerBillingData() | ||
{ | ||
$id = '1'; | ||
$id = '1'; | ||
$legalDocument = '63165236372'; | ||
$name = 'Fulano da Silva'; | ||
$address = createAddress(); | ||
$phone = Phone::create( Phone::COMERCIAL, '11', '37288788' ); | ||
$birthDate = new \DateTime( '1980-01-01' ); | ||
$name = 'Fulano da Silva'; | ||
$address = createAddress(); | ||
$phone = Phone::create(Phone::COMERCIAL, '11', '37288788'); | ||
$birthDate = new \DateTime('1980-01-01'); | ||
|
||
return CustomerBillingData::create( | ||
$id, | ||
|
@@ -125,11 +125,11 @@ function createCustomerBillingData() | |
|
||
function createCustomerShippingData() | ||
{ | ||
$id = '1'; | ||
$id = '1'; | ||
$legalDocument = '63165236372'; | ||
$name = 'Fulano da Silva'; | ||
$address = createAddress(); | ||
$phone = Phone::create( Phone::COMERCIAL, '11', '37288788' ); | ||
$name = 'Fulano da Silva'; | ||
$address = createAddress(); | ||
$phone = Phone::create(Phone::COMERCIAL, '11', '37288788'); | ||
|
||
return CustomerShippingData::create( | ||
$id, | ||
|
@@ -143,15 +143,15 @@ function createCustomerShippingData() | |
|
||
function createAddress() | ||
{ | ||
$street = 'Rua José de Oliveira Coutinho'; | ||
$number = 151; | ||
$county = 'Barra Funda'; | ||
$street = 'Rua José de Oliveira Coutinho'; | ||
$number = 151; | ||
$county = 'Barra Funda'; | ||
$country = 'Brasil'; | ||
$city = 'São Paulo'; | ||
$state = 'SP'; | ||
$zip = '01144020'; | ||
$city = 'São Paulo'; | ||
$state = 'SP'; | ||
$zip = '01144020'; | ||
|
||
return Address::create( $street, $number, $county, $country, $city, $state, $zip ); | ||
return Address::create($street, $number, $county, $country, $city, $state, $zip); | ||
} | ||
|
||
exit; |
Oops, something went wrong.