- PHP 5.3.3 or greater
include 'azpay.php';
// Instantiate AZPay
$azpay = new AZPay('MERCHANT_ID', 'MERCHANT_KEY');
$azpay->config_order['reference'] = '123456789';
$azpay->config_order['totalAmount'] = '1000';
$azpay->config_billing['customerIdentity'] = '1';
$azpay->config_billing['name'] = 'Fulano de Tal';
$azpay->config_billing['address'] = 'Av. Federativa, 230';
$azpay->config_billing['address2'] = '10 Andar';
$azpay->config_billing['city'] = 'Mogi das Cruzes';
$azpay->config_billing['state'] = 'SP';
$azpay->config_billing['postalCode'] = '20031-170';
$azpay->config_billing['phone'] = '21 4009-9400';
$azpay->config_billing['email'] = 'fulanodetal@email.com';
$azpay->config_options['urlReturn'] = 'http://loja.exemplo.com.br';
$azpay->config_options['fraud'] = 'false';
$azpay->config_options['customField'] = '';
// Configure Creditcard
$azpay->config_card_payments['acquirer'] = Config::$CARD_OPERATORS['cielo']['modes']['store']['code'];
$azpay->config_card_payments['method'] = '1';
$azpay->config_card_payments['amount'] = '1000';
$azpay->config_card_payments['currency'] = Config::$CURRENCIES['BRL'];
$azpay->config_card_payments['numberOfPayments'] = '1';
$azpay->config_card_payments['groupNumber'] = '0';
$azpay->config_card_payments['flag'] = 'visa';
$azpay->config_card_payments['cardHolder'] = 'José da Silva';
$azpay->config_card_payments['cardNumber'] = '4000000000010001';
$azpay->config_card_payments['cardSecurityCode'] = '123';
$azpay->config_card_payments['cardExpirationDate'] = '201805';
$azpay->config_card_payments['saveCreditCard'] = 'true';
# Prepare authorization to transaction
$operation = $azpay->authorize();
# Prepare capture of transaction
$operation = $azpay->capture("TID");
# Prepare authorization and capture (direct sale), to transaction
$operation = $azpay->sale();
# Prepare cancel operation
$operation = $azpay->cancel("TID");
# Execute prepared operation
$operation->execute();
# Response
$xml_response = $azpay->response();
$azpay->config_boleto['acquirer'] = Config::$BOLETO_OPERATORS['bradesco']['code'];
$azpay->config_boleto['expire'] = date('Y-m-d', strtotime('today + 10 day'));
$azpay->config_boleto['nrDocument'] = '12345678';
$azpay->config_boleto['amount'] = '1000';
$azpay->config_boleto['currency'] = Config::$CURRENCIES['BRL'];
$azpay->config_boleto['instructions'] = 'Não aceitar pagamento em cheques. \n Percentual Juros Dia: 1%. Percentual Multa: 1%.';
# Prepare authorization to transaction
$operation = $azpay->boleto();
# Execute prepared operation
$operation->execute();
# Response
$xml_response = $azpay->response();
# Request informations about specific TID
$operation = $azpay->report('TID');
$operation->execute();
# Get XML generated by operation
$xml = $operation->getXml();
# Get cURL response, without XML format
$curl_response = $operation->getCurlResponse();
try {
# ...
} catch (AZPay_Error $e) {
# HTTP 409 - AZPay Error
$error = $azpay->responseError();
} catch (AZPay_Curl_Exception $e) {
# Connection Error
print($e->getMessage());
} catch (AZPay_Exception $e) {
# General Error
print($e->getMessage());
}