Zoho Invoice API not working - zoho

I am trying three Zoho Invoice API's but they are not working.
The Invoice API's are:
List Contacts(Get Method)
List Customer Payments(Get Method)
Create a Customer Payment(Post Method)
List Contacts(Get Method)
For List Contacts I have used the url as
https://invoice.zoho.com/api/contacts/?authtoken=&scope=invoiceapi
but my response is
<Response status="0">
<Code>5</Code>
<Message>
<![CDATA[ Invalid URL Passed ]]>
</Message>
</Response>
List Customer Payments(Get Method)
For List Customer Payments I have used URL as
https://invoice.zoho.com/api/customerpayments?authtoken=&scope=invoiceapi
My response is
<Response status="0">
<Code>5</Code>
<Message>
<![CDATA[ Invalid URL Passed ]]>
</Message>
</Response>
Create a Customer Payment(Post Method)
To create a customer Payment I am using create map fields and Post URL method like below
<%{
map1 = map();
map1.put("date", "2014-3-24");
map1.put("amount", "10100");
map1.put("customer_id", "<my custome ID>");
map1.put("invoice_id", "<my Invoice ID>");
map1.put("authtoken", "<my authtoken>");
map1.put("scope", "invoiceapi");
post = postUrl("https://invoice.zoho.com/api/customerpayments", map1,false);
PostResponseCode=post.get("responseCode");
PostResponseText=post.get("responseText");%>
<%=PostResponseCode%><br/>
<%=PostResponseText%>
<%}%>
but my Response is
500
The server encountered an unexpected condition which prevented it from fulfilling the request
Can anyone please help me with this

This is Reshma from Zoho Invoice Team. We recently launched our REST API for Zoho Invoice and Zoho Books. What I would suggest you to do is , include the tag V3 in your URL so the api call looks like the one shown below:
https://invoice.zoho.com/api/v3/entity_name?authtoken=*************&organization_id=******
You'll find answers to most of your questions on our API documentation here . Also you can always reach us out at support#zohoinvoice.com
Let me know if this worked out for you.
Regards,
Reshma

Related

How to get payer email after a success payment wit paypal API (Laravel paypal/rest-api-sdk-php)?

I'm using the paypal API with Laravel, everything works fine. I just need to find the way to get the user email address and name.
$payment = Payment::get($payment_id, $this->_api_context);
$execution = new PaymentExecution();
$execution->setPayerId( $request->query('PayerID') );
$result = $payment->execute($execution, $this->_api_context);
if ($result->getState() == 'approved') {
// I should get the info about the payer here
}
The v1/payments PayPal-PHP-SDK is deprecated, you should not use it for any new integration.
The current supported SDK is the v2/checkout/orders Checkout-PHP-SDK, which you should use instead.
You can try the srmklive package "v3" if you like, otherwise integrate directly.
You should be able to create two routes, one for 'Create Order' and one for 'Capture Order', documented here. These routes should return only JSON data (no HTML or text). Pair those two routes with the following approval flow: https://developer.paypal.com/demo/checkout/#/pattern/server
The capture order response may have details about the payer and payment, if not use can do a 'Get' API call on the order ID for this information. Store it in your database before returning the JSON to the client code.

Formatting XML for Twilio Response

I am attempting to receive a fax in my Laravel app, but I can't seem to format the XML properly.
Since I am just setting this up for the first time, I tried to emulate the basic how-to in the Twilio Quickstart guide.
Using the Twilio dashboard, I have set a webhook address of myapp.com/fax/sent to be notified when an incoming fax is attempting to be sent:
public function sent()
{
$twimlResponse = new SimpleXMLElement("<Response></Response>");
$recieveEl = $twimlResponse->addChild('Receive');
$receiveEl->addAttribute('action', '/fax/received');
return response($twimlResponse->asXML())
->header('Content-Type', 'text/xml');
}
The error that I get from Twilio is essentially empty:
Error 12100 Document parse failure
The Twilio error request inspector shows no head or body.
I have also tried to return a hard-coded view file in place of building the xml:
view fax.sent:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Receive action="/fax/received" />
</Response>
and then changed the sent function to:
public function sent()
{
return View::make('fax.sent')->header('Content-Type', 'text/xml');
}
This returns the same error message.
Make sure your twiML URL is externally accessible to Twilio (no firewall/IP restrictions, etc) and that it is valid XML with the correct Content-Type.

Adwords API getting customerId

I have an adwords user's Oauth credentials, and I'm able to successfully make an API call to download a report, but I had to hard-code in the customerId as I couldn't figure out how to get it.
The get() method of the CustomerService in the API should return the customer ID, but what are the parameters to pass to it?
I tried a GET request to this URL
without any header params or body params, to which it returns:
"<html><body>No service was found.</body></html>".
I also tried with an Authorization and developerToken defined in the headers, but got the same response.
I also tried the python library, and defined an instance of AdWordsClient like this, but it's client_customer_id variable ends up as None:
from googleads.adwords import AdWordsClient
oauth_client = GoogleRefreshTokenClient(environ.get('GOOGLE_CLIENT_ID'), environ.get('GOOGLE_CLIENT_SECRET'), oauth_record.refresh_token)
adwords_client = AdWordsClient(environ.get('ADWORDS_DEVELOPER_TOKEN'), oauth_client, user_agent='agent'))
customer_id = adwords_client.client_customer_id
print 'customer_id:' + str(customer_id)
Unlike this question, I don't care about adding the user to my MCC account.
Here is how to get the customer ID with the googleads-python-lib library:
oauth_client = GoogleRefreshTokenClient(environ.get('GOOGLE_CLIENT_ID'), environ.get('GOOGLE_CLIENT_SECRET'), oauth_record.refresh_token)
adwords_client = AdWordsClient(environ.get('ADWORDS_DEVELOPER_TOKEN'), oauth_client, user_agent='your_user_agent_here')
customer = adwords_client.GetService('CustomerService').get()
customer_id = customer['customerId']
from googleads import oauth2, adwords
oauth_client = oauth2.GoogleRefreshTokenClient(GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, refresh_token)
adwords_client = adwords.AdWordsClient(ADWORDS_DEVELOPER_TOKEN, oauth_client, user_agent='your_user_agent')
customers = adwords_client.GetService('CustomerService', version='v201809').getCustomers()
print(customers['customer_id'])

EWS Edit Attachments in a Forward Email

I'm working on an application that let users manage their emails from a website.
The user can reply to an email as well as forward a an email etc....
My problem is that I want to give the users the ability to remove attachments from
a forward instance of an existing email before sending it.
ResponseMessage response;
response = OriginalEmail.CreateForward(); // create response
ForwardEmail = response.Save(WellKnownFolderName.Drafts);
The ForwardEmail doesn't contain any attachment in the attachments collection.
However when using
ResponseMessage response;
response = this.Email.CreateForward(); // create response
this.Response = response.Save(WellKnownFolderName.Drafts);
this.Response.ToRecipients.Add("me", "me#gmail.com");
this.Response.Send();
I'm getting the attachments in the destination email.
How can I edit the attachments before forwarding?
Thanks in advance
After you call the Save method
ForwardEmail = response.Save(WellKnownFolderName.Drafts);
You should then do Load using a propertySet the specifies you want the attachments returned eg
PropertySet psPropset = new PropertySet(BasePropertySet.FirstClassProperties);
ForwardEmail.Load(psPropset);
That should then populate the Attachment Collection.
Cheers
Glen

Programmatically send email when shipping tracking number is set

I am looking for a way to programmatically send an email to the user when a tracking number is assigned to an order. I need to be able to do this programmatically because I am using an outside source to populate the tracking information.
I guess what I am really looking for here is a specific trigger or event that I could use to fire off the email that would normally be sent when the admin clicks the "Send Tracking Information" button. I have skimmed through the core code and have not been able to put my finger on what action is actually being triggered when that button is pushed.
We are using a third party (eBridge) to connect with our sales tools. Once an order has been marked as shipped and a tracking number is input into the eBridge tool, it will talk to magento and input the tracking number into the order. The problem is that it doesn't tell magento to fire off an email to provide the customer with this newly inputted tracking number. What I am trying to do is, once the information is put into magento fire off an email from magentos side. Is this possible? What we want, in a nutshell, is to be able to have magento send off an email with the tracking information without having to manually go into each order and click the "Send Tracking Information" button.
When you add a new shipment to an order via the control panel you can tick a box to send the e-mail. If you need to send this programmatically, the controller for the admin area simply calls the sendEmail method on the Mage_Sales_Model_Order_Shipment.
UPDATE: If the tracking number is being adding to the shipment via the 'standard' method, which is to say the addTrack method of the shipment api, then you would be able to hook into the sales_order_shipment_track_save_after event. Adding an observer that does something along the lines of...
public function sendTrackEmail($observer)
{
$track = $observer->getEvent()->getTrack();
$shipment = $track->getShipment(true);
$shipment->sendEmail();
}
FYI there is an undocumented API call that does exactly this, sendInfo(). I don't know as of what version this was added in, as far as I can tell it's over a year old, I just had to solve this same problem myself and this is one of the first results on Google.
Note: If you're implementing this, you likely do not want to send the email flag to the sales_order_shipment.create() API call, as this will result in two emails going out for the same order, one without a tracking number, then one with it.
addTrack() is likely implemented already, you just need to follow it immediately with sendInfo().
sales_order_shipment.addTrack(sessionId, shipmentIncrementId, carrier, title, trackNumber)
sales_order_shipment.sendInfo(sessionId, comment)
The email sent out is the same that you would get by clicking the "Send Tracking Information" button in the Magento backend manually. Reference the Magento API for more explanation on addTrack and using the SOAP API in general.
As for sendInfo() specifically, take a look at the source code from magento/app/code/core/Mage/Sales/Model/Order/Shipment/Api.php for help:
/**
* Send email with shipment data to customer
*
* #param string $shipmentIncrementId
* #param string $comment
* #return bool
*/
public function sendInfo($shipmentIncrementId, $comment = '')
{
/* #var $shipment Mage_Sales_Model_Order_Shipment */
$shipment = Mage::getModel('sales/order_shipment')->loadByIncrementId($shipmentIncrementId);
if (!$shipment->getId()) {
$this->_fault('not_exists');
}
try {
$shipment->sendEmail(true, $comment)
->setEmailSent(true)
->save();
$historyItem = Mage::getResourceModel('sales/order_status_history_collection')
->getUnnotifiedForInstance($shipment, Mage_Sales_Model_Order_Shipment::HISTORY_ENTITY_NAME);
if ($historyItem) {
$historyItem->setIsCustomerNotified(1);
$historyItem->save();
}
} catch (Mage_Core_Exception $e) {
$this->_fault('data_invalid', $e->getMessage());
}
return true;
}
If you want an email containing the tracking informationto get sent when some program e.g. eBridge calls the salesOrderShipmentAddTrack V2 API, you can also extend Mage_Sales_Model_Order_Shipment_Api
e.g.
class PKS_Sales_Model_Order_Shipment_Api extends Mage_Sales_Model_Order_Shipment_Api
public function addTrack
by adding the call to send the email in the try block e.g.
try {
$shipment->save();
$track->save();
$shipment->sendEmail(true, '')
->setEmailSent(true)
->save(); /* added email with null comment */
}
You also have to provide an extension to the SOAP V2 e.g.
class PKS_Sales_Model_Order_Shipment_Api_V2 extends PKS_Sales_Model_Order_Shipment_Api
even if it has no methods :)
(example has my app/code/local/PKS/Sales module, substitute your company name for PKS, apologies re formatting)
app/code/local/PKS/Sales/etc/config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<PKS_Sales>
<version>4.0.0.0</version>
<depends>
<Mage_Sales />
</depends>
</PKS_Sales>
</modules>
<global>
<models>
<sales>
<rewrite>
<order_shipment_api>PKS_Sales_Model_Order_Shipment_Api</order_shipment_api>
<order_shipment_api_v2>PKS_Sales_Model_Order_Shipment_Api_V2</order_shipment_api_v2>
</rewrite>
</sales>
</models>
</global>
</config>
It took more time figuring out how to write the required PKS/Sales/etc/api.xml
(example has my app/code/local/PKS module, substitute your company name for PKS)
<config>
<api>
<resources>
<sales_order_shipment translate="title" module="PKS_Sales">
<title>Modified Shipment API</title>
<model>sales/order_shipment_api</model>
<acl>sales/order/shipment</acl>
<methods>
<addTrack translate="title" module="PKS_Sales">
<title>Add new tracking number</title>
<acl>sales/order/shipment/track</acl>
</addTrack>
</methods>
<faults module="PKS_Sales">
<not_exists>
<code>100</code>
<message>Requested shipment does not exist.</message>
</not_exists>
<filters_invalid>
<code>101</code>
<message>Invalid filters given. Details in error message.</message>
</filters_invalid>
<data_invalid>
<code>102</code>
<message>Invalid data given. Details in error message.</message>
</data_invalid>
<order_not_exists>
<code>103</code>
<message>Requested order does not exist.</message>
</order_not_exists>
<track_not_exists>
<code>104</code>
<message>Requested tracking does not exist.</message>
</track_not_exists>
<track_not_deleted>
<code>105</code>
<message>Tracking not deleted. Details in error message.</message>
</track_not_deleted>
</faults>
</sales_order_shipment>
</resources>
<resources_alias>
<order>sales_order</order>
<order_shipment>sales_order_shipment</order_shipment>
</resources_alias>
<v2>
<resources_function_prefix>
<order>salesOrder</order>
<order_shipment>salesOrderShipment</order_shipment>
</resources_function_prefix>
</v2>
</acl>
</api>
</config>
Please note that with this approach, and having System > Configuration > Sales > Sales Emails > Order and Shipment emails enabled, your customer will get
- one email confirming a new order
- a second email for the shipment with no tracking number
- a third email for the shipment with the tracking number, from your API extension.
I've tried commenting out the Api.php create function's
$shipment->sendEmail($email, ($includeComment ? $comment : ''));
but that second email just keeps getting sent.

Resources