/home/desid573/public_html/verde/xero/XeroOAuth-PHP-master
Edit: /home/desid573/public_html/verde/xero/XeroOAuth-PHP-master/invoiceSend.php (4541B)
'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, $date, $invDesc, $amount, $ref, $email) {
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)) {
$date = date("c", strtotime($date));
$dueDate = date("c", strtotime($date." + 14 days"));
if($type == "FC" OR $type == "SA" OR $type == "SF") {
$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;
}
}
$xml = "
ACCREC
".$name."
".$email."
".$date."
".$dueDate."
AUTHORISED
".$_GET['reference']."
".$theme."
Inclusive
".$code."
".$invDesc."
1
".$amount[0]."
".$accountCode."
";
if($amount.length == 2) {
$xml = $xml."
TT
Tolls
1
".$amount[1]."
49999
";
}
$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']);
echo "" . count($invoice->Invoices[0]). " invoice created in this Xero organisation.";
if (count($invoice->Invoices[0])>0) {
echo "The first one is: ";
pr($invoice->Invoices[0]->Invoice);
}
} else {
outputError($XeroOAuth);
}
}
}
}
}