/home/desid573/public_html/payment/xero
Edit: /home/desid573/public_html/payment/xero/partner.php (4100B)
'——YOUR-CONSUMER-KEY—',
'shared_secret' => '——YOUR-CONSUMER-SECRET—',
// 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';
}
/* ENTRUST CERTIFICATE DEPRECATED
if (XRO_APP_TYPE == "Partner") {
$signatures ['curl_ssl_cert'] = BASE_PATH . '/certs/entrust-cert.pem';
$signatures ['curl_ssl_password'] = '1234';
$signatures ['curl_ssl_key'] = BASE_PATH . '/certs/entrust-private-nopass.pem';
}
*/
$XeroOAuth = new XeroOAuth ( array_merge ( array (
'application_type' => XRO_APP_TYPE,
'oauth_callback' => OAUTH_CALLBACK,
'user_agent' => $useragent
), $signatures ) );
$initialCheck = $XeroOAuth->diagnostics ();
$checkErrors = count ( $initialCheck );
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 {
$here = XeroOAuth::php_self ();
session_start ();
$oauthSession = retrieveSession ();
include 'tests/tests.php';
if (isset ( $_REQUEST ['oauth_verifier'] )) {
$XeroOAuth->config ['access_token'] = $_SESSION ['oauth'] ['oauth_token'];
$XeroOAuth->config ['access_token_secret'] = $_SESSION ['oauth'] ['oauth_token_secret'];
$code = $XeroOAuth->request ( 'GET', $XeroOAuth->url ( 'AccessToken', '' ), array (
'oauth_verifier' => $_REQUEST ['oauth_verifier'],
'oauth_token' => $_REQUEST ['oauth_token']
) );
if ($XeroOAuth->response ['code'] == 200) {
$response = $XeroOAuth->extract_params ( $XeroOAuth->response ['response'] );
$session = persistSession ( $response );
unset ( $_SESSION ['oauth'] );
header ( "Location: {$here}" );
} else {
outputError ( $XeroOAuth );
}
// start the OAuth dance
} elseif (isset ( $_REQUEST ['authenticate'] ) || isset ( $_REQUEST ['authorize'] )) {
$params = array (
'oauth_callback' => OAUTH_CALLBACK
);
$response = $XeroOAuth->request ( 'GET', $XeroOAuth->url ( 'RequestToken', '' ), $params );
if ($XeroOAuth->response ['code'] == 200) {
$scope = "";
// $scope = 'payroll.payrollcalendars,payroll.superfunds,payroll.payruns,payroll.payslip,payroll.employees,payroll.TaxDeclaration';
if ($_REQUEST ['authenticate'] > 1)
$scope = 'payroll.employees,payroll.payruns,payroll.timesheets';
print_r ( $XeroOAuth->extract_params ( $XeroOAuth->response ['response'] ) );
$_SESSION ['oauth'] = $XeroOAuth->extract_params ( $XeroOAuth->response ['response'] );
$authurl = $XeroOAuth->url ( "Authorize", '' ) . "?oauth_token={$_SESSION['oauth']['oauth_token']}&scope=" . $scope;
echo '
To complete the OAuth flow follow this URL: ' . $authurl . '
';
} else {
outputError ( $XeroOAuth );
}
}
testLinks ();
}