Package Data | |
---|---|
Maintainer Username: | modugno |
Maintainer Contact: | modugnoguilherme@gmail.com (Guilherme Modugno) |
Package Create Date: | 2017-05-18 |
Package Last Update: | 2017-05-19 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2025-01-25 15:04:44 |
Package Statistics | |
---|---|
Total Downloads: | 19 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 3 |
Total Forks: | 0 |
Total Open Issues: | 0 |
composer require gmodugno/azpaylaravel
Abra o arquivo config/app.php
e adicione ao Array providers
a seguinte instrução:
AzPayLaravel\AzPay\AzPayServiceProvider::class,
Ainda no arquivo config/app.php
adicione no Array aliases
a seguinte instrução:
'AZPay' => AzPayLaravel\AzPay\Facades\AZPay::class,
Digite o seguinte comando no seu Terminal
php artisan vendor:publish --tag=config
Pronto, se tudo deu certo, irá paracer a seguinte mensagem
Copied File [/vendor/gmodugno/azpaylaravel/src/AzPay/Config/azpay.php] To [/config/azpay.php]
Abra o arquivo config/azpay.php
e coloque suas credenciais da AzPay.
return [
'merchant_id' => 'MERCHANT_ID',
'merchant_key' => 'MERCHANT_KEY'
];
$azpay = AZPay::init();
// Order
$azpay->setOrder([
'reference' => '123456789',
'totalAmount' => '1000'
]);
// Billing
$azpay->setBilling([
'customerIdentity' => '1',
'name' => 'Fulano de Tal',
'address' => 'Av. Federativa, 230',
'address2' => '10 Andar',
'city' => 'Mogi das Cruzes',
'state' => 'SP',
'postalCode' => '20031-170',
'phone' => '21 4009-9400',
'email' => 'fulanodetal@email.com'
]);
// Options
$azpay->setOptions([
'urlReturn' => 'http://loja.exemplo.com.br',
'fraud' => 'false',
'customField' => ''
]);
// CreditCard
$azpay->setCardPayment([
'acquirer' => AZPay::getCardOperators()['cielo']['modes']['store']['code'],
'method' => '1',
'amount' => '1000',
'currency' => AZPay::getCurrencies('BRL'),
'numberOfPayments' => '1',
'groupNumber' => '0',
'country' => 'BRA',
'flag' => 'visa',
'cardHolder' => 'José da Silva',
'cardNumber' => '4012001037141112',
'cardSecurityCode' => '123',
'cardExpirationDate' => '201805',
'saveCreditCard' => 'true'
]);
// Try
try {
// venda direta
$azpay->sale()->execute();
$xml_request = $azpay->response();
return $xml_request;
} catch (AzPayLaravel\AzPay\SDK\AZPay_Error $e) {
# HTTP 409 - AZPay Error
$error = $azpay->responseError();
dd($error);
} catch (AzPayLaravel\AzPay\SDK\AZPay_Curl_Exception $e) {
# Connection Error
dd($e->getMessage());
} catch (AzPayLaravel\AzPay\SDK\AZPay_Exception $e) {
# General Error
dd($e->getMessage());
}