$cartItem->timeHedge = "Normal";
$cartItem->type = "AdultContent";
$cartItem->velocityHedge = "High";
$cartItem->passenger = $passenger;
array_push($cartItems, $cartItem);
$cart->items = $cartItems;
$fraudAnalysis->browser = $browser;
$fraudAnalysis->cart = $cart;
$sale->payment->fraudAnalysis = $fraudAnalysis;
$api = new BraspagApiServices();
$result = $api->createSale($sale);
if (is_a($result, 'BraspagSale')) {
    /*
     * In this case, you made a succesful call to API and receive a Sale object in response
     */
    echo "<ul><li><a href=\"example_credit_capture.php?paymentId={$sale->payment->paymentId}\" target=\"_blank\">Capture Card</a></li>";
    echo "<li><a href=\"example_credit_void.php?paymentId={$sale->payment->paymentId}\" target=\"_blank\">Void Card</a></li>";
    echo "<li><a href=\"example_all_get.php?paymentId={$sale->payment->paymentId}\" target=\"_blank\">Get Card</a></li></ul>";
    BraspagUtils::debug($sale, "Card Success!");
} elseif (is_array($result)) {
    /*
     * In this case, you made a Bad Request and receive a collection with all errors
     */
    BraspagUtils::debug($result, "Bad Request Auth!");
} else {
    /*
     * In this case, you received other error, such as Forbidden or Unauthorized
     */
    BraspagUtils::debug($result, "HTTP Status Code!");
}
l;
 /**
  * Deactivate one recurrent payment
  * @param mixed $recurrentId 
  */
 public function reactivate($recurrentId, $amount)
 {
     $uri = BraspagApiConfig::apiUri . "RecurrentPayment/{$recurrentId}/Reactivate";
     $response = \Httpful\Request::put($uri)->addHeaders($this->headers)->addHeader("content-type", "text/json")->send();
     if ($response->code == BraspagHttpStatus::BadRequest) {
         return BraspagUtils::getBadRequestErros($response->body);
     }
     return $response->code;
 }
Example #3
0
 private function parseCreditAndDebitPayment($payment, $apiPayment, $card)
 {
     $payment->authenticationUrl = BraspagUtils::getResponseValue($apiPayment, 'AuthenticationUrl');
     $payment->authorizationCode = BraspagUtils::getResponseValue($apiPayment, 'AuthorizationCode');
     $payment->acquirerTransactionId = BraspagUtils::getResponseValue($apiPayment, 'AcquirerTransactionId');
     $payment->proofOfSale = BraspagUtils::getResponseValue($apiPayment, 'ProofOfSale');
     $payment->eci = BraspagUtils::getResponseValue($apiPayment, 'Eci');
     $parsedCard = new BraspagCard();
     $parsedCard->brand = $card->Brand;
     $parsedCard->cardNumber = $card->CardNumber;
     $parsedCard->expirationDate = $card->ExpirationDate;
     $parsedCard->holder = $card->Holder;
     $payment->creditCard = $parsedCard;
 }
<?php

header('Content-Type: text/html; charset=utf-8');
include $_SERVER['DOCUMENT_ROOT'] . "/src/BraspagApiIncludes.php";
$paymentId = $_GET['paymentId'];
$api = new BraspagApiServices();
$result = $api->get($paymentId);
if (is_a($result, 'BraspagSale')) {
    /*
     * In this case, you made a succesful call to API and receive a Sale object in response
     */
    BraspagUtils::debug($result, 'Success:');
} elseif (is_array($result)) {
    /*
     * In this case, you made a Bad Request and receive a collection with all errors
     */
    BraspagUtils::debug($result, 'Bad Request:');
} else {
    /*
     * In this case, you received other error, such as Forbidden or Unauthorized
     */
    BraspagUtils::debug($result, 'HTTP Status Code:');
}