/home/desid573/public_html/payment/xero
Edit: /home/desid573/public_html/payment/xero/invoiceSend.php (10475B)
'51DABYIYXXBZDHAZTVAXBX6TU7T3AT',
'shared_secret' => 'RE390CCDJV1VD29SUZI9VBWTVUV7VF',
// API versions
'core_version' => '2.0',
'payroll_version' => '1.0',
'file_version' => '1.0'
);
if (XRO_APP_TYPE == "Private" || XRO_APP_TYPE == "Partner") {
$signatures ['rsa_private_key'] = BASE_PATH . '/certs/privatekey.pem';
$signatures ['rsa_public_key'] = BASE_PATH . '/certs/publickey.cer';
}
$XeroOAuth = new XeroOAuth ( array_merge ( array (
'application_type' => XRO_APP_TYPE,
'oauth_callback' => OAUTH_CALLBACK,
'user_agent' => $useragent
), $signatures ) );
include 'tests/testRunner.php';
$initialCheck = $XeroOAuth->diagnostics ();
$checkErrors = count ( $initialCheck );
function submitInvoice($name, $email, $date, $invDesc, $amount, $ref, $type, $tollsDesc, $driver_name) {
global $XeroOAuth;
if ($checkErrors > 0) {
// you could handle any config errors here, or keep on truckin if you like to live dangerously
foreach ( $initialCheck as $check ) {
echo 'Error: ' . $check . PHP_EOL;
}
} else {
$session = persistSession ( array (
'oauth_token' => $XeroOAuth->config ['consumer_key'],
'oauth_token_secret' => $XeroOAuth->config ['shared_secret'],
'oauth_session_handle' => ''
) );
$oauthSession = retrieveSession ();
if (isset ( $oauthSession ['oauth_token'] )) {
$XeroOAuth->config ['access_token'] = $oauthSession ['oauth_token'];
$XeroOAuth->config ['access_token_secret'] = $oauthSession ['oauth_token_secret'];
if(isset($name) && isset($date) && isset($invDesc) && isset($amount)) {
$dueDate = date("c", strtotime($date." + 14 days"));
if($type == "FC" OR $type == "FA" OR $type == "SA" OR $type == "SF" OR $type == "MA" OR $type == "MF" OR $type == "BA" OR $type == "BF" OR $type == "GC" OR $type == "GA") {
$theme = "f6369498-a39b-4f8a-aceb-b603392b1327";
$code = "FC";
$accountCode = "42000";
} else if($type == "DD") {
$theme = "ed5eea99-3c48-48e6-969d-3af875340a78";
$code = "DD";
$accountCode = "41000";
} else {
$theme = "1f1b02b8-1b00-4803-8b2e-e4ec4f578f27";
$code = $type;
if($type == "HK") {
$accountCode = "41600";
} else if ($type == "SI") {
$accountCode = "41500";
}
}
$total = $amount["total"];
$invDesc = str_replace( "\\r\\n", "
", $invDesc );
if($driver_name != "Shebah") {
if($type == "FC" OR $type == "FA" OR $type == "SA" OR $type == "SF" OR $type == "MA" OR $type == "MF" OR $type == "BA" OR $type == "BF" OR $type == "GC" OR $type == "GA") {
$total = $amount["total"] - $amount["levy"];
$levy = $amount["levy"];
}
}
$xml = "
ACCREC
".$name."
".$email."
".$date."
".$dueDate."
AUTHORISED
".$ref."
".$theme."
Inclusive
".$code."
".$invDesc."
".$total."
OUTPUT
".$accountCode."
1
";
if($type == "FC" OR $type == "FA" AND $driver_name != "Shebah") {
$xml = $xml."
WL
WA Taxi Plate Buyback Levy
".$levy."
OUTPUT
57777
1
";
} else if($type == "SA" OR $type == "SF" AND $driver_name != "Shebah") {
$xml = $xml."
SL
NSW Passenger Service Levy
".$levy."
OUTPUT
57778
1
";
} else if($type == "MA" OR $type == "MF" AND $driver_name != "Shebah") {
$xml = $xml."
ML
Commercial Passenger Vehicle Service Levy
".$levy."
OUTPUT
57778
1
";
} else if($type == "BA" OR $type == "BF" or $type == "GC" or $type == "GA") {
// $xml = $xml."
// SL
// Qld Passenger Service Levy
// ".$levy."
// BASEXCLUDED
// 57778
// 1
// ";
//$xml = "";
}
if($amount["tolls"] != null) {
$tollsDesc = "Tolls:\r\n".$tollsDesc;
$tollsDesc = str_replace( "\\r\\n", "
", $tollsDesc );
$xml = $xml."
TT
".$tollsDesc."
1
".$amount["tolls"]."
49999
OUTPUT
";
}
$xml = $xml."
";
$response = $XeroOAuth->request('PUT', $XeroOAuth->url('Invoices', 'core'), array(), $xml);
if ($XeroOAuth->response['code'] == 200) {
$invoice = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
if (count($invoice->Invoices[0])>0) {
return ["invoiceNumber" => $invoice->Invoices[0]->Invoice->InvoiceNumber[0], "invoiceID" => $invoice->Invoices[0]->Invoice->InvoiceID[0]];
}
} else {
outputError($XeroOAuth);
}
}
}
}
}
function submitPayment($invoiceID, $accountID, $date, $amount, $ref) {
global $XeroOAuth;
if ($checkErrors > 0) {
// you could handle any config errors here, or keep on truckin if you like to live dangerously
foreach ( $initialCheck as $check ) {
echo 'Error: ' . $check . PHP_EOL;
}
} else {
$session = persistSession ( array (
'oauth_token' => $XeroOAuth->config ['consumer_key'],
'oauth_token_secret' => $XeroOAuth->config ['shared_secret'],
'oauth_session_handle' => ''
) );
$oauthSession = retrieveSession ();
if (isset ( $oauthSession ['oauth_token'] )) {
$XeroOAuth->config ['access_token'] = $oauthSession ['oauth_token'];
$XeroOAuth->config ['access_token_secret'] = $oauthSession ['oauth_token_secret'];
$xml = "
".$invoiceID."
".$accountID."
".$date."
".$ref."
".$amount."
";
$response = $XeroOAuth->request('PUT', $XeroOAuth->url('Payments', 'core'), array(), $xml);
if ($XeroOAuth->response['code'] == 200) {
} else {
outputError($XeroOAuth);
}
}
}
}