Skip to content

viniciusferreira/SDK-PHP

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AZPay SDK PHP

Requirements

  • PHP 5.3.3 or greater

Configurations

Init

include 'azpay.php';

// Instantiate AZPay
$azpay = new AZPay('MERCHANT_ID', 'MERCHANT_KEY');

Order

$azpay->config_order['reference'] = '123456789';
$azpay->config_order['totalAmount'] = '1000';

Billing

$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';

Options

$azpay->config_options['urlReturn'] = 'http://loja.exemplo.com.br';
$azpay->config_options['fraud'] = 'false';
$azpay->config_options['customField'] = '';

Creditcard

Config

// 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';

Use

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

Boleto

Config

$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%.';

Use

# Prepare authorization to transaction
$operation = $azpay->boleto();	

# Execute prepared operation
$operation->execute();

# Response
$xml_response = $azpay->response();

Report

# Request informations about specific TID
$operation = $azpay->report('TID');
$operation->execute();

Other methods

# Get XML generated by operation
$xml = $operation->getXml();

# Get cURL response, without XML format
$curl_response = $operation->getCurlResponse();

Exceptions

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

About

SDK PHP do AZPAY (Gateway de Pagamento - www.azpay.com.br)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%