|
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 : |
<?php
require_once('BTlib.php');
header('Content-type: text/xml; charset=UTF-8');
$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');
break;
} catch(Exception $e) {
$xml->writeElement('error', 'Authentication Error');
break;
}
} else {
$xml->writeElement('error', 'Missing Parameters: accessToken');
break;
}
try {
$options = [];
if(isset($_POST['merchantAccountId'])){
$options['merchantAccountId'] = $_POST['merchantAccountId'];
}
$clientToken = $gateway->clientToken()->generate($options);
} catch(Braintree_Exception_Authentication $e) {
$xml->writeElement('error', 'Authentication Error');
break;
} catch(Exception $e) {
$xml->writeElement('error', 'ClientToken Generation Failed');
break;
}
$xml->writeElement('ClientToken', $clientToken);
}while(0);
$xml->endElement();
$xml->endDocument();
echo $xml->outputMemory(true);