Prv8 Shell
Server : Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/1.0.0-fips mod_auth_passthrough/2.1 mod_bwlimited/1.4
System : Linux server.jackjohnson.com 2.6.32-279.5.2.el6.x86_64 #1 SMP Fri Aug 24 01:07:11 UTC 2012 x86_64
User : jackjohn ( 502)
PHP Version : 5.3.17
Disable Function : NONE
Directory :  /home/jackjohn/public_html/cgi-bin/sc/scphp/v.zero/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/jackjohn/public_html/cgi-bin/sc/scphp/v.zero/transaction.php
<?php
require_once('BTlib.php');
header('Content-type: text/xml; charset=UTF-8');

$op = $_POST['op'];
function processResponse($result, $xml) {
  $success = $result->success;
  if($success)
  {
    $xml->writeElement('success','true');
    $trans = $result->transaction;
    $xml->writeElement('status',$trans->status);
    $xml->writeElement('transaction_id',$trans->id);
    $xml->writeElement('processor-response-code',$trans->processorResponseCode);
    $xml->writeElement('processor-response-text',$trans->processorResponseText);
    $xml->writeElement('payment-instrument-type',$trans->paymentInstrumentType);
    if($trans->paymentInstrumentType == Braintree_PaymentInstrumentType::CREDIT_CARD)
    {
      $xml->writeElement('credit-card-type',$trans->creditCardDetails->cardType);
      $xml->writeElement('credit-card-number',$trans->creditCardDetails->maskedNumber);
    }
    else if($trans->paymentInstrumentType == Braintree_PaymentInstrumentType::ANDROID_PAY_CARD)
    {
      $xml->writeElement('credit-card-number',$trans->androidPayCardDetails->sourceDescription);
    }
    else if($trans->paymentInstrumentType == Braintree_PaymentInstrumentType::APPLE_PAY_CARD)
    {
      $xml->writeElement('credit-card-number',$trans->applePayCardDetails->sourceDescription);
    }
    $info = $trans->avsPostalCodeResponseCode;
    if(!empty($info)) {
      $xml->writeElement('avs-postal-code-response',$info);
    }
    $info = $trans->avsStreetAddressResponseCode;
    if(!empty($info)) {
      $xml->writeElement('avs-street-address-response',$info);
    }
    $info = $trans->avsErrorResponseCode;
    if(!empty($info)) {
      $xml->writeElement('avs-error-code',$info);
    }
    $threeDSecure = $trans->threeDSecureInfo;
    if(!empty($threeDSecure))
    {
      $info = "{$threeDSecure->enrolled}|{$threeDSecure->status}|";
      $info .= sprintf("%s|%s",
        ($threeDSecure->liabilityShifted?'true':'false'),
        ($threeDSecure->liabilityShiftPossible?'true':'false'));
      $xml->writeElement('threeDSecure',$info); 
    }
  } else {
    $xml->writeElement('success','false');
    $xml->writeElement('message',$result->message);
    if($result->errors->deepSize() > 0)
    {
      $xml->startElement('errors');
      foreach($result->errors->deepAll() AS $error)
      {
        $xml->startElement('error');
        $xml->writeElement('attr',    $error->attribute);
        $xml->writeElement('code',    $error->code);
        $xml->writeElement('message', $error->message);
        $xml->endElement();
      }
      $xml->endElement();
    }
    if(isset($result->transaction) && isset($result->transaction->status))
    {
      $trans = $result->transaction;
      $xml->writeElement('status',$trans->status);
      if(isset($trans->id))
        $xml->writeElement('transaction_id',$trans->id);
      $xml->startElement('transaction_response');
      switch($trans->status) {
        case 'processor_declined':
          $xml->writeElement('code',$trans->processorResponseCode);
          $xml->writeElement('message',$trans->processorResponseText);
          break;

        case 'settlement_declined':
          $xml->writeElement('code',$trans->processorSettlementResponseCode);
          $xml->writeElement('message',$trans->processorSettlementResponseText);
          break;

        case 'gateway_rejected':
          $xml->writeElement('message',$trans->gatewayRejectionReason);
          break;
      }
      $xml->endElement();
    }
  }
}

$xml = new XMLWriter;
$xml->openMemory();
$xml->setIndent(false);
$xml->startDocument('1.0', 'UTF-8');
$xml->startElement('Braintree');

do{
  if(isset($_POST['accessToken'])) {
    try{
      $gateway =  new Braintree_Gateway(['accessToken' => $_POST['accessToken']]);
    }
    catch(Braintree_Exception_Authentication $e) {
      $xml->writeElement('error', 'Authentication Error');
      $xml->writeElement('success','false');
      break;
    }
    catch(Exception $e) {
      $xml->writeElement('error', 'Authentication Error');
      $xml->writeElement('success','false');
      break;
    }
  } else {
    $xml->writeElement('error', 'Missing Parameters: accessToken');
    break;
  }

  switch($op)
  {
    case 'sale':
    case 'auth':
      {
        //Make a transaction
        if(!isset($_POST['payment_method_nonce'])
            || !isset($_POST['amount']))
        {
          $xml->writeElement('error', 'Missing Paramaters: payment_method_nonce or amount');
          $xml->writeElement('success','false');
          break;
        }
        try {
          $customer = [];
          if(isset($_POST['First'])) $customer['firstName'] = $_POST['First'];
          if(isset($_POST['Last'])) $customer['lastName'] = $_POST['Last'];
          if(isset($_POST['Company'])) $customer['company'] = $_POST['Company'];
          if(isset($_POST['Phone'])) $customer['phone'] = $_POST['Phone'];
          if(isset($_POST['Email'])) $customer['email'] = $_POST['Email'];
          $billing = [];
          if(isset($_POST['First'])) $billing['firstName'] = $_POST['First'];
          if(isset($_POST['Last'])) $billing['lastName'] = $_POST['Last'];
          if(isset($_POST['Company'])) $billing['company'] = $_POST['Company'];
          if(isset($_POST['Address'])) $billing['streetAddress'] = $_POST['Address'];
          if(isset($_POST['Address2'])) $billing['extendedAddress'] = $_POST['Address2'];
          if(isset($_POST['City'])) $billing['locality'] = $_POST['City'];
          if(isset($_POST['State'])) $billing['region'] = $_POST['State'];
          if(isset($_POST['Zip'])) $billing['postalCode'] = $_POST['Zip'];
          if(isset($_POST['Country'])) $billing['countryCodeAlpha2'] = $_POST['Country'];
          $shipping = [];
          if(isset($_POST['ShipFirst'])) $shipping['firstName'] = $_POST['ShipFirst'];
          if(isset($_POST['ShipLast'])) $shipping['lastName'] = $_POST['ShipLast'];
          if(isset($_POST['ShipCompany'])) $shipping['company'] = $_POST['ShipCompany'];
          if(isset($_POST['ShipAddress'])) $shipping['streetAddress'] = $_POST['ShipAddress'];
          if(isset($_POST['ShipAddress2'])) $shipping['extendedAddress'] = $_POST['ShipAddress2'];
          if(isset($_POST['ShipCity'])) $shipping['locality'] = $_POST['ShipCity'];
          if(isset($_POST['ShipState'])) $shipping['region'] = $_POST['ShipState'];
          if(isset($_POST['ShipZip'])) $shipping['postalCode'] = $_POST['ShipZip'];
          if(isset($_POST['ShipCountry'])) $shipping['countryCodeAlpha2'] = $_POST['ShipCountry'];
          $transaction = [
              'amount' => $_POST['amount'],
              'paymentMethodNonce' => $_POST['payment_method_nonce'],
              'channel' => 'ShopSite BT No Tiers_Cart',
              'options' => [
                'submitForSettlement' => ($op == 'sale' ? True : False)
              ]
          ];
          if(isset($_POST['merchantAccountId'])){
            $transaction['merchantAccountId'] = $_POST['merchantAccountId'];
          }
          if(isset($_POST['storeInVault'])){
            $transaction['options']['storeInVaultOnSuccess']=true;
            $transaction['options']['storeShippingAddressInVault']=true;
          }
          if(isset($_POST['device_data'])) $transaction['deviceData'] = $_POST['device_data'];

          if(count($customer) > 0) $transaction['customer'] = $customer;
          if(count($billing)  > 0) $transaction['billing']  = $billing;
          if(count($shipping) > 0) $transaction['shipping'] = $shipping;

          $result = $gateway->transaction()->sale($transaction);
        } catch(Braintree_Exception_Authentication $e) {
          $xml->writeElement('error', 'Authentication Error: ' . $e->getMessage());
          $xml->writeElement('success','false');
          break;
        } catch(Exception $e) {
          $xml->writeElement('error', 'Transaction Error: ' . $e->getMessage());
          $xml->writeElement('success','false');
          break;
        }
        processResponse($result, $xml);
        break;
      }

    case 'settle':
      {
        //Make a transaction
        if(!isset($_POST['transaction_id']))
        {
          $xml->writeElement('error', 'Missing Paramaters: transaction_id');
          $xml->writeElement('success','false');
          break;
        }
        try {
          $result = $gateway->transaction()->submitForSettlement($_POST['transaction_id']);
        } catch(Braintree_Exception_Authentication $e) {
          $xml->writeElement('error', 'Authentication Error: ' . $e->getMessage());
          $xml->writeElement('success','false');
          break;
        } catch(Exception $e) {
          $xml->writeElement('success','false');
          $xml->writeElement('error', 'Transaction Error: ' . $e->message());
          break;
        }
        processResponse($result, $xml);
        break;
      }

    default:
      $xml->writeElement('error','Unknown operation: ' . $op);
      $xml->writeElement('success','false');
  }

}while(0);

$xml->endElement();
$xml->endDocument();
echo $xml->outputMemory(true);

haha - 2025