How to add or remove Free Shipping option to a Mercadolivre product? - rest

I need to add or remove the Free Shipping option/flag to a Mercadolivre product using the REST API, but I can´t figure how to do it.
I read the whole API documentation and found nothing on how to set this flag. Any one has this figured out?
I have tried so far:
PUT request to https://api.mercadolibre.com/items/MLBXXXXXXXXXX with:
{"shipping": {"free_shipping": false}}
Result: no error but flag doesn´t change.
PUT request to https://api.mercadolibre.com/items/MLBXXXXXXXXXX/shipping with:
{
"marketplace": {"free_shipping": false},
"mshops": {"free_shipping": false}
}
Result: This method works for changing 'mshops' free shipping option, but not for the Mercadolivre website 'marketplace'

Related

Where to enter paypal IPN url and how to pass custom data?

This seems a very naive set of questions, but I really couldn't find it.
Question 1) I am trying to implement IPN for PayPal. I want to enter The listener URL, but I couldn't find where. I've searched the internet and all the responses are old. Where could I put it?
Question 2) I am using the following code and I want to pass custom data so that when IPN sends me back the transaction message, It will have that custom data in it. I need to pass 2 custom data. How is this possible for the following code? I really couldn't find this one in the docs too.
<template>
<div id="paypal-button-container"></div>
</template>
<script>
export default {
props: ["amount"],
mounted() {
let self = this;
paypal
.Buttons({
createOrder: function(data, actions) {
// Set up the transaction
return actions.order.create({
purchase_units: [
{
amount: {
value: self.amount,
}
}
],
});
},
onApprove: function(data, actions) {
// Capture the funds from the transaction
return actions.order.capture().then(function(details) {
// Show a success message to your buyer
console.log(details);
self.$emit("paypalPaySuccess", {
order_id: details.id,
})
alert("Transaction completed by " + details.payer.name.given_name);
}).catch((err)=>{
})
}
})
.render("#paypal-button-container");
}
};
</script>
Addition of some questions
I am using all the events in dashboard.
I need to add some more questions, because I can't find the information I need.
Question 3) In client-side, I make action.orders.capture().then . which means that I capture funds immediatelly. When webhooks come to my back-end, there're 2 webhooks that come for single payment . (PAYMENT.CAPTURE.PENDING and CHECKOUT.ORDER.APPROVED) . a) why doesn't PAYMENT.CAPTURE.COMPLETED arrive as webhook event? b) what if I want to get DENIED events? If PAYMENT.CAPTURE.COMPLETED doesn't arrive, PAYMENT.CAPTURE.DENIED won't arrive too.
Question 4) As I said, there're 2 webhook events appearing for single payment on my back-end. The first one has id in it. Let's say I store this in my database as id and status(PENDING). Then another event came which is CHECKOUT.ORDER.APPROVED. Now, this one has different id then the previous one. So I can't really go back to database and update the status as this has different id. What should I do? One thing I noted is that the second came event has also another id (the previous came event) somewhere in captured object. is this what i should use it? which one is the final transaction_id?
Question 5) Turns out invoice_id should be unique each time. So I wanted to pass user_id but i guess i also should generate random string and append it to user_id something like this: invoice_id: '7,randomstring'. right?
Question 6) Same event sometimes comes twice. Why is that? Should I return status 200 in order for that same event not to come again? When will it be good to return that status? I guess after I update the database, right?
Q1: IPN is deprecated. You should be using webhooks, such as CHECKOUT.ORDER.APPROVED
Q2: There does not appear to be any specific way to pass custom data.
Option 1:
What I ended up doing was using the invoice_id field in purchase_units. I tested and found that I could pass a reasonably long string of characters and they did not have to be unique. It seems a bit of a hack but it works.
When you implement the CHECKOUT.ORDER.APPROVED webhook, you can then parse the data in purchase_unit invoice_id.
Option 2:
Another idea I considered which doesn't need to hack the invoice_id, is to send data to the server using the details from the capture event in the javascript, store that custom information, along with the order id in the database, and then when the webhook occurs, cross-match the order id to the saved one to retrieve the information.
I prefer option 1, but your needs may vary.
It's pretty indicative though of how poorly designed the whole PayPal API is. There are huge gaps in the implementation, very little documentation, and zero support.
I had to implement Stripe as well. The entire implementation took me 3 days. The same PayPal implementation took me over 3 weeks! The lack of documentation, having to constantly just try things out, and the inconsistency of the sandbox implementation were real time killers.

How can I add unsubscribe links to my emails when sending via sendgrid/mail

I'm sending emails using: https://github.com/sendgrid/sendgrid-nodejs/tree/master/packages/mail
I have not been able to find out HOW I can add the Unsubscribe equivalent. This is documented in here: https://sendgrid.com/docs/Classroom/Basics/Marketing_Campaigns/unsubscribe_groups.html#-Using-a-Custom-Unsubscribe-Link
On the website, you just use a shortcode [Unsubscribe], this does not work when sending emails via the sendgrid/mail package.
One tip that would have saved me an hour or two is that:
It's possible to send the following in the api json along with other stuff:
"asm":{
"group_id":123,
"groups_to_display": [123],
}
then the following variables become available to use within the template:
<%asm_group_unsubscribe_raw_url%>
<%asm_preferences_raw_url%>
If you want to keep things simple don't include the following variable as it fiddles with too many things (this wasn't obvious from the documentation so obviously I did so and wasted time :( ):
"tracking_settings": {
"subscription_tracking": {
"enable": true,
"substitution_tag": "[unsubscribe_url]"
}
}
Just use them in their raw format and you shall be fine.
Since you're sending using code, it's a "transactional" type of message. You'll want to either turn on the Subscription Tracking filter at the account level (via [UI](subscription tracking setting) or API), or turn it on as you send the message, as part of the mail/send API call, under tracking_settings.
It's important to note that you can't mix those. If you define anything in the mail/send API call, you'll need to define everything for Subscription Tracking in that call. SendGrid won't look at some settings at the mail level, and some at the account level.
Most users will just set it at the account level. There, you can customize the HTML & Text of the Unsubscribe footer, customize the HTML of the landing page, or redirect landing to a URL of your choosing, which will send the recipient there with ?email=test#domain.com in the URL string for your system to catch. You can also define the "replacement tag" like [%unsubscribe%], so that you can place the URL wherever you want within your HTML.
https://app.sendgrid.com/ > Suppressions > Unsubscribe Groups > Create New Group
Note down group_id/ids. e.g 123 (Only number !Not string)
Send email using node.js
const sgMail = require('#sendgrid/mail');
sgMail.setApiKey(SENDGRID_API_KEY);
const tags = { invitedBy : Alex }
const msg = {
to: email,
from: { "email": SENDER_EMAIL,
"name": SENDER_NAME
},
templateId: TEMPLATE_ID,
dynamic_template_data: {
Sender_Name: name,
...tags
},
asm: {
group_id: 123,
groups_to_display: [
123
],
},
};
await sgMail.send(msg);
The best approach is to use Group Unsubscribes.
First create a group in Sendgrid:
Groups > Unsubscribe Groups > Create a group
Next, insert a module into the Sendgrid template that creates specific tags in your email, which are populated when you make an API request
Go to your template
Insert an unsubscribe module in an HTML block
Save
Finally make an API request and specify the group created in step 1:
"asm":{
"group_id":544,
"groups_to_display": [544, 788],
}
These will be inserted into the module mentioned in step 2 when the email is sent.
Unfortunately Sendgrid unsubscribe links are not as straightforward as they could be. They are explained in more detail here
The easiest way is to do this via the SendGrid GUI.
Go to Settings -> Tracking -> Subscription Tracking

Adding zip code and address to Coffee for Stripe payment

We have a Python app that takes payment via card, it has been hit hard be people with stolen cards. To help prevent this we want to add zip code and billing address to the payment info. From what I can figure out the StripeCheckout is configured in the Coffee script below. Adding data-zip-code: true and data-billing-address: true just makes the app fail. I'm not familiar with Stripe or Coffee and would appreciate some assistance on adding these variables to the config.
handler = StripeCheckout.configure
key: window.stripeKey
token: (token) ->
$('.token').val token.id
$('.buy-form').submit()
StripeCheckout Reference: https://stripe.com/docs/checkout#integration-simple-options
You're using the custom integration, so you shouldn't prefix the options with data- -- that prefix is only used when options as passed as HTML attributes in the simple integration.
I don't have much experience with Coffeescript, but this should work:
handler = StripeCheckout.configure
key: window.stripeKey
billingAddress: true
token: (token) ->
$('.token').val token.id
$('.buy-form').submit()
On a side note, zipCode: true isn't necessary as the ZIP/postal code will be collected as part of the billing address (i.e. it's implied by billingAddress: true.

Paypal REST SDK - Billing Plans no longer retrievable after being made ACTIVE

So I'm using the Paypal PHP SDK on Github, http://paypal.github.io/PayPal-PHP-SDK/ . Some strange behavior I've noticed which I'm not sure what's going on.
So let's say I create a billing plan, but don't touch it after creation, so that the state is simple CREATED. Everything is good, I can retrieve it from the list of plans. However, the moment I change the state to ACTIVE via a patch, I can see that it is in fact active, but only just once. Any subsequent attempts to see the list of plans no longer shows that plan. What's going on? I'm literally copy pasting the example source they give.
Edit - just to expand, I know the plan still exists, because I can subscribe users to it. Weirdly the paypal page where you click ok to subscribe is extremely non verbose... doesn't even say what the price is, just to approve paying my store. And yet the Agreement object that is returned by PayPal, which includes the approval url, has all this info. Weird.
If you are using the PayPal-PHP-SDK, you could assign more parameters to Plan::all() method.
As shown in the List Plan sample code, you could pass parameter 'status' as :
try {
// Get the list of all plans
// You can modify different params to change the return list.
// The explanation about each pagination information could be found here
// at https://developer.paypal.com/webapps/developer/docs/api/#list-plans
$params = array('page_size' => '20', 'page' => '98', 'status' => 'ACTIVE');
$planList = Plan::all($params, $apiContext);
} catch (Exception $ex) {
ResultPrinter::printError("List of Plans", "Plan", null, $params, $ex);
exit(1);
}
As in the case, you could change the status, and page along with page_size. This will help you get the active list of plans.
Actually, by default the list plan status is defaulted to CREATED.

Facebook Graph API event-id/comments?since=2014-02-01&until=2014-02-10 , Date filter has no effect

I am trying to bring comments made on a particular event by targeting this URL: https://graph.facebook.com/1466384840257158/comments
I am passing the user_access_token
I have two comments at present on this event made on the same
day(2014-03-29)
Now I try to pass a date which should bring an empty data result/object
like this: https://graph.facebook.com/1466384840257158/comments?since=2011-01-01&until=2014-01-10
This request has no effect, it still shows me the two comment made
on the 29th
I have tried the same kind of date range on my user-id/feed and it
gave me an empty data object.
Finally i tried event-id/feed (before trying date filter) and it
gave me the following error
.
{
"error": {
"message": "An unexpected error has occurred. Please retry your request later.",
"type": "OAuthException",
"code": 2
}
}
Could you please guide me about date filter on that particular query (point4) or if you have any other idea to use date filter on comments made for an event.
Comments use Cursor-based Pagination, so you cannot use since or until on the comments endpoint (these parameters would work f.ex. for the feed endpoint).
To get the comments in a time range you have to fetch all comments from NOW to the start of the time range, f.ex. with https://graph.facebook.com/1466384840257158/comments?filter=stream&limit=1000+paging (the filter=stream will order the result with the timestamp).
USING SINCE UNTIL FOR COMMENTS on GROUP
If you want to use since and until for comments, it is not possible directly for a group. So, First you can apply it for status(feed) and then get the comments for that feed.
This works for me:
{group_id}/?fields=feed.since(08/25/2016).until(08/31/2016){from,comments{from,message}}
Why don't you try first to filter by notifications?... notifications allows you to add parameters like since. For example (using Facebook pages):
https://graph.facebook.com/PAGEID?fields=notifications.since(2015-3-31 00:00:00).limit(250).include_read(true)&{id,created_time,updated_time,unread,object,link}&access_token=ACCESSTOKEN
Once you got the json data, loop through data, get the ID and send a second request but this time using the PAGEID_POSTID edge. Something like this:
https://graph.facebook.com/PAGEID_POSTID/comments?fields=id,from{name,id},message,can_remove,created_time&limit=1000
Voahla!... there's no need to read every comment!...
Note 1: A Page access token is required, along with the manage_pages permission
Note 2: Use the parameter/field include_read to get all the notifications, even the already readed
Note 3: In the second request, use the parameter/field "filter=stream" to order the posts and get the comments made in the name of your page
Note 4: Don't forget to control the asynchronicity once you loop!
Note 5: Notifications duplicate posts, use an array to avoid to read more than one time the postUse the parameter/field include_read to get all the notifications, even the already readed
I do not know if it's too late. But, Yeah it works in the graph api version 3.3.
for example: if you wanna get comments on a post of a Facebook page you can do it like this:
You have to use page Access-token
The get Graph Request : post_id/comments?since=some_date