Git Product home page Git Product logo

braspag's Introduction

Brapag PHP Library

Welcome

Braspag for PHP aims to make life easier for developers who need to use a Brazillian gateway called Braspag via WebService. Currently the library is only implemented with transactions via credit cards. Feedbacks and collaborations will be highly appreciated.

Usage example

Authorize and capture payment:

<?php

//Import Braspag library
require_once 'Braspag.php';

$Braspag = new Braspag('homologation');

///////////////
//Customer
///////////////
$Customer = new BraspagCustomerData();
$Customer->setName('Robson Morais');
$Customer->setID('1001');
$Customer->setEmail('[email protected]');

//Customer address (optional)
$AddressData = new BraspagAddressData();
$AddressData->Street = 'Blvd. 28 de Setembro';
$AddressData->Number = '389';
$AddressData->Complement = 'Sala 512';
$AddressData->District = 'Vila Isabel';
$AddressData->City = 'Rio de Janeiro';
$AddressData->State = 'RJ';
$AddressData->ZipCode = '20551030';
$AddressData->Country = 'BR';

//Set address data is optional
$Customer->setAddressData($AddressData);
$Customer->setDeliveryAddressData($AddressData);

///////////////
//Credit card
///////////////
$CreditCard = new BraspagCreditCardModel();

//Capture transaction after authorization
$CreditCard->setTransactionType(BraspagCreditCardModel::TRANSACTION_TYPE_AUTOCAPTURE);

//Testing
$CreditCard->setMethod(BraspagCreditCardModel::METHOD_HOMOLOGATION);

//Order and payment info
$CreditCard->setOrderId('3598754');
$CreditCard->setCardNumber('0000000000000001');
$CreditCard->setCardHolder("ROBSON M SANTOS");
$CreditCard->setCardExpirationDate('06', '2015');
$CreditCard->setCardSecurityCode('345');
$CreditCard->setCurrency('BRL');
$CreditCard->setCountry('BRA');
$CreditCard->setAmount(1500);
$CreditCard->setPaymentPlan(BraspagCreditCardModel::PAYMENT_PLAN_FINANCED_STORE);
$CreditCard->setNumberOfPayments(3);
$CreditCard->setSaveCreditCard(true);

//Execute transaction
$response = $Braspag->authorizeCreditCardTransaction($CreditCard, $Customer);

//Echoes result
$Braspag->dump($response);

?>

License

Except as otherwise noted, the Braspag for PHP is licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0.html).

braspag's People

Contributors

carneiro avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.