My QuickBooks Online Application needs to create a Service Item in a QuickBooks Account.
When creating a Service Item through QBO API, I need to query the account for ExpenseAccountRef.Name, ExpenseAccountRef.Value, IncomeAccountRef.Name and IncomeAccountRef.Value first. How can this be done?
I have tried running the following query first but it simply:
$table = "Account";
$entities = $dataService->Query("Select * from $table");
$error = $dataService->getLastError();
if ($error) {
echo "The Status code is: " . $error->getHttpStatusCode() . "\n";
echo "The Helper message is: " . $error->getOAuthHelperError() . "\n";
echo "The Response message is: " . $error->getResponseBody() . "\n";
exit();
}
But it does not provide any of the fields I need listed above.
Related
I'm fetching a Webhook that is coming from Braintree. The Webhook is return a success and also creates the log file. This is the code I'm using:
if( isset($_POST["bt_signature"]) && isset($_POST["bt_payload"])){
$webhookNotification = \Braintree_WebhookNotification::parse(
$_POST["bt_signature"], $_POST["bt_payload"]
);
$message = "[Webhook Received "
. $webhookNotification->timestamp->format('Y-m-d H:i:s') . "] "
. "Kind: " . $webhookNotification->kind . " | "
. "Payment ID: " . $webhookNotification->localPaymentCompleted->paymentId . "\n";
file_put_contents("/tmp/webhook.log", $message, FILE_APPEND);
// if everything went fine, send confirmation to the buyer
$this->artikelRepository->sendConfirmationAction(null, $webhookNotification->localPaymentCompleted->paymentId);
}
To confirm the payment I need the paymentId of the local payment. I tried with various methods, but this should work: $webhookNotification->localPaymentCompleted->paymentId according to the test file.
The log file returns this, though:
How am I able to retrieve the Payment ID of a local payment inside the webhook function?
Update: I just noticed that we used a totally outdated SDK. The functions we tried to use were not even added in the old version.
I'm trying to login to the following URL: pitangui.amazon.com
I have tried using cURL as well as libraries like https://barebonescms.com/documentation/ultimate_web_scraper_toolkit/
However, I'm getting the following error using the webscraper via Amazon:
This is my PHP code:
<?php
require_once "support/http.php";
require_once "support/web_browser.php";
require_once "support/simple_html_dom.php";
$url = "https://pitangui.amazon.com";
$web = new WebBrowser(array("extractforms" => true));
$result = $web->Process($url);
if (!$result["success"]) echo "Error retrieving URL. " . $result["error"] . "\n";
else if ($result["response"]["code"] != 200) echo "Error retrieving URL. Server returned: " . $result["response"]["code"] . " " . $result["response"]["meaning"] . "\n";
else
{
$form = $result["forms"][0];
$form->SetFormValue("email", "myemail#gmail.com");
$form->SetFormValue("password", "mypass");
$result2 = $form->GenerateFormRequest("signIn");
$result = $web->Process($result2["url"], "auto", $result2["options"]);
if (!$result["success"]) echo "Error retrieving URL. " . $result["error"] . "\n";
else if ($result["response"]["code"] != 200) echo "Error retrieving URL. Server returned: " . $result["response"]["code"] . " " . $result["response"]["meaning"] . "\n";
else
{
// Do something with the results page here...
print_r($result);
}
}
?>
I'm first trying to get the login working, then I will grab the cookie via $_SERVER['Cookie']
add
$form->SetFormValue("create","0");
I think this is a problem we Web Designers are going to run into frequently working with CMS scripts.
and with all the new shopping carts and eCommerce Payment Gateways coming out.
I have a Component with a newer shopping cart running on Joomla that generates a Unique
URL for each order. Need to process it in Authorize.net SIM
compatible Gateway. (Hosted Payment Page)
I used a 2 Form solution to get the correct information to the Gateway, and payment can be made successfully.
Now I have to get the data back to Validate the payment and update the shopping cart.
I need to move the response code data to a dynamic URL.
The Gateway only posts to a static URL.
They suggested I have the Gateway post back to a static page that then auto posts to the correct unique generated URL.
They advise that the static page will pick up the response elements the shopping cart requires in the database, and then push the information to the second URL that is unique to the Individual transaction.
Also advise redirect be Auto Post or Post.
The Developer kindly wrote a snippet of code that is supposed to pick up the unique identifier for the order, generate the correct URL and to act as the Redirect,
<?php
if($_POST || $_GET) {
$vik = explode('_', $_REQUEST['x_fp_sequence']);
$querystring = '';
foreach($_REQUEST as $k=>$v) {
$querystring .= '&'.$k.'='.$v;
}
header('Location: http://allstoplimo.com/reservations/index.php?option=com_vikrentcar&task=notifypayment&sid='.$vik[0].'&ts='.$vik[1].$querystring);
}
?>
Which I have tried to combine with static standard static receipt page example provided by the Gateway:
<?php
if ($_REQUEST['x_response_code'] == '1') {
echo "<p>";
echo "Your order was processed successfully. Here is your receipt.";
echo "Your order will be shipped in two business days.";
echo "</p>";
echo "<pre>";
echo $_REQUEST["exact_ctr"];
echo "</pre>";
if (!empty($_REQUEST["exact_issname"])) {
echo "<p>";
echo "Issuer: " .$_REQUEST["exact_issname"] . "<br/>";
echo "Confirmation Number: " . $_REQUEST["exact_issconf"];
echo "</p>";
}
echo "<p>";
$track_url = "http://allstoplimo.com/reservations/" . $_REQUEST["x_invoice_num"];
echo "You can track it at <a href=\"" . $track_url . "\">" .
$track_url . "</a>";
echo "</p>";
} elseif ($_REQUEST['x_response_code'] == '2') {
echo "<p>";
echo "Your payment failed.";
echo "Here is your receipt.";
echo "</p>";
echo "<pre>";
echo $_REQUEST["exact_ctr"];
echo "</pre>";
} else {
echo "<p>";
echo "An error occurred while processing your payment.";
echo "Please try again later.";
echo "</p>";
}
?>
The receipt info is posting to the static page but
Of course it is not redirecting anywhere???
Any suggestions on an alternative?
Anyone know the proper way to authenticate and publish directly to a calendar without relying on a currently logged in user? Several weeks ago I built a calendar that used the standard Oauth 2.0 protocol but this relied sessions stored by a user's we browser. I have one calendar that I want to pass events to from an application I am writing with a basic PHP framework. I'm more concerned with what are the best practices that others are using. Your answer could be simply, don't do it. Thanks alot.
Use OAuth 2 and the Authorization Code flow (web server flow), with offline enabled. Store the refresh tokens (which last indefinitely until the user has revoked), and you'll be able to upload events to Google Calendar even when the user isn't currently logged in.
More info:
https://developers.google.com/accounts/docs/OAuth2WebServer#offline
try Zend_Gdata_Calendar with this library you are able to insert or get events from any user(with the right username and password obviously) from google calendar and integrate with your own calendar or display it..here a short example:
$service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME;
$client = Zend_Gdata_ClientLogin::getHttpClient('gmail#user.com', 'gmailpassword', $service);
$service = new Zend_Gdata_Calendar($client);
$query = $service->newEventQuery();
$query->setUser('default');
$query->setVisibility('private');
try {
$eventFeed = $service->getCalendarEventFeed($query);
} catch (Zend_Gdata_App_Exception $e) {
echo "Error: " . $e->getMessage();
}
echo "<ul>";
foreach ($eventFeed as $event) {
echo "<li>" . $event->title . " (Event ID: " . $event->id . ")</li>";
}
echo "</ul>";
$eventURL = "http://www.google.com/calendar/feeds/default/private/full/Dir0FthEpUbl1cGma1lCalendAr";
try {
$event = $service->getCalendarEventEntry($eventURL);
echo 'Evento: ' . $event->getTitle() .'<br>';
echo 'detalles: ' . $event->getContent().'<br>';
foreach ($event->getWhen() as $dato)
{
echo 'inicia: ' . substr($dato->startTime, 0,-19) . ' a las: ' . substr($dato->startTime, 11,-10) .'<br>';
echo 'termina: ' .substr($dato->endTime,0,-19) . ' a las: ' . substr($dato->endTime,11,-10) .'<br>';
}
} catch (Zend_Gdata_App_Exception $e) {
echo "Error: " . $e->getMessage();
}
with this you can add, update, edit or delete events from calendar form any user with mail and password...
I'm creating a module for joomla that lists the the contents of a given folder. This module works as a service, so no OAuth should be required.
I'm stuck since every request I make has the same answer, no items. So I would like to know if I'm creating the client/service in a wrong way or I may have registered the application in a wrong way.
Here is the code:
// this class is where I have all the IDs from the google console
require_once(dirname(__FILE__) . '/gdrive/config.php');
require_once(dirname(__FILE__) . '/gdrive/gd-v2-php/apiClient.php');
require_once(dirname(__FILE__) . '/gdrive/gd-v2-php/contrib/apiDriveService.php');
$client = new apiClient();
$key = file_get_contents(Config::KEY_FILE);
$client->setClientId(Config::CLIENT_ID);
$client->setUseObjects(true);
$client->setAssertionCredentials(new apiAssertionCredentials(
Config::SERVICE_ACCOUNT_NAME,
array('https://www.googleapis.com/auth/drive'), $key)
);
$service = new apiDriveService($client);
try {
$parameters = array();
$parameters['maxResults'] = $maxResults;
$files = $service->files->listFiles($parameters);
$items = $files->getItems();
var_dump($items);
$pageToken = $files->getNextPageToken();
} catch (apiServiceException $e) {
print "Error code :" . $e->getCode() . "\n";
// Error message is formatted as "Error calling <REQUEST METHOD> <REQUEST URL>: (<CODE>) <MESSAGE OR REASON>".
print "Error message: " . $e->getMessage() . "\n";
} catch (apiException $e) {
// Other error.
print "An error occurred: (" . $e->getCode() . ") " . $e->getMessage() . "\n";
} catch (Exception $e) {
print "Cannot retrieve the files";
print($e->getMessage());
}
Sorry to ask such a noob question but this is driving me crazy
Thanks
P.S. just for the record, I followed this google-api-php-client/wiki/OAuth2#Service_Accounts
After having a second look to the documentation I found that Google Drive does not support service accounts. I don't know if this is going to change but, with the requirements I have (I need to show in the web is what an end user uploads to a folder (which is public) using the desktop app) I think I cannot use google drive as a valid solution.
I found a solution but I don't like to much since I should have to refresh the token forever Google Drive SDK Service Account Error