shopify price rules api , how to get only active discounts? - node.js

I'm working on a Shopify app using node js, and I need to get the list of discounts from merchants store, so I used the price rules admin API to get the list, but the problem is I'm getting all the discounts even inactive or expired discounts , can anyone help me to filter this , I searched a lot on Shopify documentation but I did not found any solution.

You can use "ends_at_min" param and set today's date (format 2017-03-25T16:15:47-04:00) in its value to get the active discounts only. Please check for the
Thanks

Related

Get purchased product from PaymentIntent

in my app i want to list past purchases for a stripe customer. So I was looking at the relevant API objects like PaymentIntents, Sessions or Charges. But they all do not seem to contain any reference to Product or Price, which I would need to list the purchased products.
Subscriptions contain a list of items that are contained in that subscription, so I was expecting PaymentIntents to have something like that too.
Does anyone has an idea how to archive my list of past purchases? Thanks!
I did some digging through the Stripe API docs[1] and, out of the three objects you referrenced (PaymentIntent, Session, Charges), the only one that I can see being able to trace back to a product is the Session.
Session objects have a line_items property[2] which can be followed all the way down to line_items.data.price.product[3]. To access this you’ll need to inlcude the expand=["data.line_items"] parameter to your call to list Checkout Sessions. You can read more about expanding API responses here[4]
So for all the charges to your customers that were done using Checkout Sessions, you could list them all, use the customer property to associate earch session with a customer in your application, traverse the the returned data, and then query the API for the product details. If you have a lot of customers & products these API calls will add up fast so I would store this data in your back-end to avoid hitting rate limits[5].
Alternatively, you could just save the product ID (either Stripe or your local version) as metadata[6] for any of the above Stripe payment objects listed. That would allow you to link any payment object you wish to a product.
https://stripe.com/docs/api
https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-line_items
https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-line_items-data-price-product
https://stripe.com/docs/expand
https://stripe.com/docs/rate-limits
https://stripe.com/docs/api/metadata
I had the same question I found a way to retrieve the products related to a specific PaymentIntent.
You need to get the sessions that was linked to PaymentIntent when the Checkout process was made.
I will give you the code (in PHP) that I use to to this.
\Stripe\Stripe::setApiKey(STRIPE_API_SECRET);
// Find the Session for that PaymentIntent
$sessions = \Stripe\Checkout\Session::all([
'payment_intent' => "pi_xxxxxxxxxx",
'expand' => ['data.line_items'],
]);
You will then have an key line_items that contain the products linked.
Enjoy

Receiving the Customer Summary

I hope things are going well.
Could you please help me with the following question.
Acumatica has the Customer Summary module. Link to the description - https://help-2017r2.acumatica.com/Wiki/ShowWiki.aspx?pageid=4d224cd8-6553-4930-872b-d667ddff891e
I want to receive all Customers from this summary and their Currency Ending Balance column.
But I cannot find the API to receive these Customers and their Currency Ending Balances.
Could you provide a link to the API?
Of course, if it is possible.
You need to extend the Default Endpoint or create a new one and add that page to the endpoint in the way shown below.
You can find the help articles on how to extend the endpoint by this link.
After adding the entity to the endpoint you can simply do a PUT request and retrieve the data that you need like below:

Query using SharePoint REST API using Author/EMail

I running into an issue with filtering using the Autor/EMail field in REST API. The query works fine when the List in Not Throttled. But we get Throttling exception when the List is throttled (>5000). The Created By Column is Indexed was well.
https://example.org/sites/dev/rnd/_api/web/lists/getbytitle('Favs')/items?$Select=ID,ItemId,ListName,Author/EMail&$Expand=Author&$Filter=Author/EMail eq 'john.smith#org.com'
After couple of trial and error I found that Author/Email is not the correct field to use. Instead we need to use Author/Id. The Id would the site user id and we can get the value from the property _spPageContextInfo.userId
Hope this helps somebody.

How can i get via AdSense Api the payment per Month and per Site

1) Hey i run API AdSense and im trying to get the total payment per month but filtered by site as well.
At the moment i can only extrect the amount of payment per month via https://www.googleapis.com/adsense/v1.4/accounts/accountId/payments but there is no way to filter there by Site
I can filter by site in this API https://www.googleapis.com/adsense/v1.4/accounts/accountId/reports but the payment that i get there are not accurate.
2) How can i get from the API the "InvalidTraffic" parameter per site ?
Thanks a lot in advance
1) Reporting is the correct way to get this information. Common causes of metric discrepancies are using the wrong time zone and using the wrong currency type. Also, be aware that "earnings up to yesterday are accurate, [but] more recent earnings are estimated due to the possibility of spam, or exchange rate fluctuations."
2) Invalid Traffic isn't exposed in the API.

Gravity Form Stripe trial + setup fee

I'm trying to build a subscription plan with free 30day period and a setup fee.
I'm using wordpress with Gravity Form and the Stripe add-on.
In the Stripe form settings the trial can be defined but If I enable the trial period I can't define the setup fee (there's a js hiding the input).
If I setup both of them (forcing the visibility of the field) and try out the form, I get the currency mismatching error (you cannot combine currencies on a single customer stripe). Removing the setup fee fix the error.
How can I solve? Anyone can give me some hint?
Many thanks
For anyone facing these problem: the solution is using the gform_stripe_customer_after_create hook:
https://docs.gravityforms.com/gform_stripe_customer_after_create/#1-create-invoice-item
Have a nice day :)

Resources