|
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 {
if(isset($_POST['type'])){
$configType = $_POST['type'];
}
switch($configType) {
case "apple":
{
$domain = isset($_POST['domain'])?$_POST['domain']:null;
$result = $gateway->applePay()->registerDomain($domain);
if(!$result->success) {
$xml->writeElement('result','fail');
$xml->writeElement('error','Operation Failed');
} else {
$xml->writeElement('result','success');
}
break;
}
default:
$xml->writeElement('error','Unknown Config');
break;
}
} catch(Braintree_Exception_Authentication $e) {
$xml->writeElement('error', 'Authentication Error');
break;
} catch(Exception $e) {
$xml->writeElement('error', 'Config Failed');
break;
}
}while(0);
$xml->endElement();
$xml->endDocument();
echo $xml->outputMemory(true);