Is there a way to add an attachment to a payment for an invoice on xero? - xero-api

On the Xero UI, there is a way to go to the Payments made for an invoice, and add an attachment.
How to do this through an API?
If I try to add an attachment to the payment using the Attachments API -
https://api.xero.com/api.xro/2.0/Payments/{PaymentID}/Attachments/{Filename} ,
I get HTTPNotFound.
But, the Payment ID does exist, as I can see it on the Xero UI, and also get the payment details through the Payments API -
https://api.xero.com/api.xro/2.0/Payments/{PaymentID}
Edit :
I am using the Ruby Net::HTTP for making the API call.
It works when posting an attachment to invoices -
https://api.xero.com/api.xro/2.0/Invoices/{InvoiceID}/Attachments/{Filename}
I am aware that their documentation - https://developer.xero.com/documentation/api/attachments - does not mention the Payments endpoint for attachments. However, the UI allows it. So, I am wondering if there is some way to do it through the API.

You can use Xero's Files API to upload a file and create an association to a payment.
You'll need to upload the file first to https://api.xero.com/files.xro/1.0/Files - File Upload
...and then create the association by posting something like this to https://api.xero.com/files.xro/1.0/Files/{fileId}/Associations - File Associations:
{
"ObjectId":"{paymentid}",
"ObjectGroup":"Payment"
}

Unfortunately you can't upload attachments to payments via the API.

Related

Shopify - How to update inventory on the fly

So i have a customer that wants to keep his inventory in sync with the supplier (who has a stock API) in magento I wrote a plugin that on page load updated the inventory and then re-rendered the page showing the updated value.
I've seen that shopify has an API, but I couldn't see if what I wanted to do was do-able.
Has anyone got any thoughts?
I could hit the API every 15mins and updated all the products, but this seems like an overkill
You cannot update Shopify inventory in real-time without using an App. Install your custom App in your client store. That App can then securely call the supplier API and get values for inventory. Using your API permissions in the Shopify you can then update Shopify
As David said you need an app. It can be a custom app, that is an app that you don't think to put on the market place and that is only available on a particular store.
In particular, I don't think you need an embedded app, you just need to have the access token and make your REST calls.
You will need to create one webhook on Shopify and one webhook on Magento, to syncrhonize the two stocks.
I don't have any knowledege of Magento but on Shopify the webhook that I think you should use is inventory_levels/update that is triggered whenever the stock changes, and that also depends on the location of your products. The same you should do on Magento.
This is a python script that is doing the update when receiving the webhook
def sync_inventory():
inventory_request = app.current_request.json_body
inventory_id = inventory_request["inventory_item_id"]
location_id = inventory_request["location_id"]
if location_id not in WAREHOUSE_IDS or inventory_id not in INVENTORY_IDS:
# Discarded inventory event
return {}
return sync_inventory_data(inventory_id) # do your magento call here

Download pdf invoice from PayPal

Is it possible to script the download pdf invoices from PayPal?
My customer has many invoices, created via the REST invoice API and wants to archive them in his own offline archive. I found out how to show the pdf directly via its invoice id but it requires me to be logged in (login/session cookies):
https://www.paypal.com/invoice/actions/render-pdf/INV2-ABCD-1234-EFGH-IJKL
I want to script the download of hundreds of invoice pdfs, so I would need an API call instead. Is there something unofficial?

Does ebay API allows to create a listing draft?

I would like to create a listing ebay draft as it is possible to do manually using this flow:
Go to the new listing sell creation page
Choose category id
Put some random data (title, description, etc.)
Close tab
You will see now unfinished draft, when you go to the new listing sell creation page.
Can I do the same thing using eBay api?
The reason of it is that I don't want to implement all functionality of addItem, currently.
eBay API will not allow to create draft listing.
when you call API for creating new listing, API needs all required fields value.
eBay Listing API provide one attribute PrivateListing.it will hide your product for selling.
If PrivateListing is true, designates the listing as private.customer can't see private listing.
eBay Listing API provide one more attribute ScheduleTime.
When you export product in eBay via API you can give ScheduleTime as well, eBay will active product for selling based on ScheduleTime.
You can make product inactive/draft using this alternative way.
http://developer.ebay.com/devzone/xml/docs/Reference/eBay/AddItem.html#AddItem
You can refer above link for eBay API.
As of now, I can confirm eBay does provide the API to create listing draft, though it's in beta at the moment.
POST - /item_draft/
Official doc is here
To my knowledge this cannot be done, since there are some pretty strict constraints around using the addItem API call, and eBay will throw an error if you don't complete the all the required fields. The required fields of addItem are numerous enough that if you could populate these fields, then you are already 90% of the way to completing your listing anyways.
If you are using Selling Manager Pro, you can create product templates which may be a way to accomplish what you are looking for.

BigCommerce JavaScript API

In BigCommerce, can I access the current customer's record using JavaScript?
I want to change something on the product page based on the customer group that the current customer is in.
there is no JS SDK yet for Bigcommerce. However, because the APIs are restful, you should be able to execute a simple GET request to get a customer's record. The only challenge is that you need to get the customer ID/info when they login to the store and then get their record.
There is an example on Bigcommerce forums on using Javascript to hide pricing for customers who are not logged in.
http://forum.bigcommerce.com/f4/global-variable-for-current-user-s-group-1815/index2.html
This combined with GET request on the customer endpoint (http://developer.bigcommerce.com/api/customers) should get you moving in that direction.
Does this help? Are you looking for a code sample?
Use Javascript or jQuery to do the IF statement.
Then use Ajax to request the data that you want to display to the user.
So to answer your question, directly with Javascript you can't, but combine it with some PHP and then you use the API to do what you would like.
Hope this helps :)

How to complete purchase with eBay trading API

I was able to make an offer using PlaceOfferRequest (XML). What should I do in order to complete the purchase and update the shipping address to where he/she should ship the Item?
I'm using XML in order to post the request.
While I can't find any official resource stating that completing purchases isn't possible, I'm 99% sure that its simply not possible. All you can do is redirect the user to the payments page, using this template for the URL:
http://payments.${DOMAIN}/ws/eBayISAPI.dll?CheckoutProcessor&item=${Item.ItemID}&transactionId=${TransactionID}
Where DOMAIN could be, for example, "sandbox.ebay.de" or just "ebay.com".