PHP code example of magus94 / multivis-payment

1. Go to this page and download the library: Download magus94/multivis-payment library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

magus94 / multivis-payment example snippets



Multivis\Multivis;

$clientId = 'YOUR_CLIENT_ID';
$clientSecret = 'YOUR_CLIENT_SECRET';

//Criando a instancia
$multiviz = new Multivis($clientId, $clientSecret, 'production');




ultivis\Resources\Payment;

$payment = new Payment();
$payment->setTransactionType('credit');
$payment->setAmount(1000);
$payment->setInstallments(1);
$payment->setCaptureType('ac');
$payment->setCurrencyCode('brl');
$payment->setProductType('avista');
$payment->setRecurrent(false);



Multivis\Resources\Card;
use Multivis\Resources\TokenCard;


$token = new TokenCard($multiviz);
$tokenNumber = $token->makeTokenCard('01212012000000000000');

$cardInfo = new Card();
$cardInfo->setNumberToken($tokenNumber);
$cardInfo->setCardholderName('JOSE SILVA');
$cardInfo->setSecurityCode('123');
$cardInfo->setBrand('visa');
$cardInfo->setExpirationMonth('12');
$cardInfo->setExpirationYear('22');



Multivis\Resources\SellerInfo;

$sellerInfo = new SellerInfo();
$sellerInfo->setOrderNumber('orderNumber');
$sellerInfo->setSoftDescriptor('TESTE');
$sellerInfo->setCavvUcaf('commerceauth');
$sellerInfo->setEci('05');
$sellerInfo->setXid('commerc');
$sellerInfo->setMid('XXXXXXXXXX');
$sellerInfo->setTid('BC038931');
$sellerInfo->setProgramProtocol('2.0.1');



// Para realizar a venda, passe os objetos criados anteriormente: Payment, Card e Seller
$response = $multiviz->paymentCard($payment, $cardInfo, $sellerInfo);

// O objeto de resposta conterá os dados de autorização da compra.



// Para cancelar uma venda, passe o ID da autorização, e o Valor a ser cancelado.
$cancel = $multiviz->cancelPayment('020000004906101633170000062686160000000000', 1000);