PHP Classes

File: samples/boleto.php

Recommend this page to a friend!
  Classes of Jonatas Matheus Gino de Souza   API Getnet PHP Client   samples/boleto.php   Download  
File: samples/boleto.php
Role: Example script
Content type: text/plain
Description: Example script
Class: API Getnet PHP Client
Access Getnet e-commerce Web services via its API
Author: By
Last change:
Date: 4 years ago
Size: 1,197 bytes
 

Contents

Class file image Download
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . '/GETNET-API-Client/Boleto.php';

$boleto = new Boleto();

$data = [
   
'amount' => '1000',
   
'name' => 'Payer Name',
   
'email' => 'payer@mail.com',
   
'document_type' => 'CPF', // CPF or CNPJ
   
'document_number' => '00000000000',
   
'phone_number' => '99999999999',
   
'street' => 'Street name',
   
'number' => '22',
   
'complement' => 'complement',
   
'district' => 'district name',
   
'city' => 'city name',
   
'state' => 'state name',
   
'country' => 'Brazil',
   
'postal_code' => 'postal_code',
   
'cardholder_name' => 'cardholder name',
   
'security_code' => 'security code',
   
'brand' => 'brand',
   
'expiration_date' => '12/23',
   
'card_number' => 'card number'
];

$retData = $boleto->doPayment($data);

$err = false;
$message = '';
if(!empty(
$retData['payment_id'])) {
   
$message = '<b>The billing was successfully generated! <br> You can download your billing by clicking ate the following link: <b> <br><br>';
   
$message .= '<a href="' . $boleto->getServer(). $retData['boleto']['_links'][0]['href'] . '" target="_BLANK"> Download! </a>';
}
else {
   
$message = 'Payment unauthorized';
}

echo
$message;