It looks like in Stripe you can retrieve a promo code by id:
Stripe::PromotionCode.retrieve(
'promo_1Hd0sBG03p6y1vChab7Jh6Zs',
)
However, I can not see a way to retrieve this by the actual customer facing code ex FIFTYOFF. Is there any way to do this?
It doesn't seem to make sense this is not possible, since this is all the data the user would have. I would need to either keep a local database duplicate of each Promo code and correlate with the customer facing code, or lookup all of my codes and iterate over them to find the actual promo code id.
The easiest solution is to use the List Promotion Codes API and pass the code parameter. This will return a list of Promotion Codes with that code and since it has to be unique, the list will only contain one element which is what you are after:
promotion_codes = Stripe::PromotionCode.list({
code: 'FIFTYOFF',
})
promotion_code_id = promotion_codes.data[0].id
Related
Our Dashboard have dropdown which consist of more than 8k products and we have such 4-5 dropdowns.
I want to filter data based on this dropdowns.
But if I selecting all products then restful api url is breaking.
Can i use azure bus service or similar message broker service to pass this complex and multiple parameters via service and which then consumed by all apis??
While I do understand what your need is I will suggest to re-think your approach as that will lead to a better user experience.
I will use a first drop down, completely empty, that will fill in options while the user types in whatever product list you have, that way, there is only a group of items that are filled in that the user is interested in.
I will also suggest not to load anything on that drop down until the user has entered, let's say, 5 characters.
After that let the user select an item from the dropdown, and filter the second drop down and continue to use the same technique with all drop downs you have.
Let me know if you have any questions around this approach and I will be more than happy to provide an example if you don't know how to do it.
Edit:
Including samples for load dropdown lists dynamically and also another post with an example on how to return some JSON from an Azure Function that can return the data in a dynamic way like you need.
From what I can see I think it'll be helpful for you to go through several different examples that can bring you progressive knowledge to what you need to achieve, first of all it'll be nice if you know how to load items dynamically on a dropdown list:
That is a nice example, you can have an entry where the user can type
whatever products you have and then they type, lets say, more than 5
characters go and search for that data.
https://www.codebyamir.com/blog/populate-a-select-dropdown-list-with-json
This other example shows you how to return data from an azure function
with the data that you need to show the users. This is not exactly
what you need as you need to receive a parameter with what the user
typed and search in your database for the items that match that search
and return that data in a JSON format so you can use it on your web
page to show the dropdown list. I will suggest to initially hard code
a few items and return those to check that the functionality is there
and once you have that up and running move to get the actual data from
the database.
How to return a JSON object from an Azure Function with Node.js
Please bear with me because I'm new to eBay APIs but basically I'm trying to:
Get a list of item IDs which are Active
Get a list of item IDs which are Unsold
So the problem is pretty straightforward and I'm currently using the GetMyeBaySelling API call with an XML input that looks like this:
<?xml version="1.0" encoding="utf-8"?>
<GetMyeBaySellingRequest xmlns="urn:ebay:apis:eBLBaseComponents">
<RequesterCredentials>
<eBayAuthToken>{eBayAuthToken}</eBayAuthToken>
</RequesterCredentials>
<DetailLevel>ReturnAll</DetailLevel>
</GetMyeBaySellingRequest>
Again, very simple. I understand that I will get the list of all Active items, the list of all Unsold/Sold items, etc. because I've set the <DetailLevel> field to ReturnAll in the input XML above
The problem is that for some reason, for one account that I'm testing this call on, it doesn't return the list of unsold items, as in, it doesn't return the container in the XML response, I'm talking about this one:
<UnsoldList> .... </UnsoldList>
This is weird because that one particular eBay account has more than 20 unsold items in it
Now this is where things get really weird, if I tested the API call on other eBay accounts, it works just fine and returns the list of all Unsold items with no problem 😕
Did I do something wrong here or is there some kind of bug in this eBay API call?
SOLVED!
It turns out that we have to specify
<DurationInDays>{numberOfDays}</DurationInDays>
Where {numberOfDays} is an integer value which represents how far back in the past do the unsold listings we want to extract have to be?
In this case, we can specify 60, which is the maximum number of days accepted by the GetMyeBaySelling API to indicate that we want all unsold listings which ended within the past 60 days.
So what happened was that on this one particular account, all of the unsold listings ended on 5th of December 2020. Whatever the default {numberOfDays} for DurationInDays value set by eBay is, it's clearly not big enough to cover these listings which ended on 5th of December 2020. Hence, by specifying it to 60 days, I got all of the unsold listings just fine :)
So for whoever out there who's facing a similar problem, remember this field, it could very well fix the problem that you have (if it's anything similar to mine).
I have a workflow script that transforms a sales order into an item fulfillment when the order is approved.
I can create a subrecord for inventory detail no problem, but in some cases Netsuite will automatically set the inventory detail. In these cases, when I go to add a subrecord, I receive an error on fulfillment submit record.
I have tried for 2 hours and cannot seem to find a way only to verify if the inventory detail is existing. I tried using the examples from the documentation
var invDetailSubrecord = fulfillment.editCurrentLineItemSubrecord('item', 'inventorydetail');
var invDetailSubrecord = fulfillment.viewCurrentLineItemSubrecord('item', 'inventorydetail');
fulfillment.removeCurrentLineItemSubrecord('item', 'inventorydetail');
None of the above commands do anything and are ignored. I don't see any way possible to verify that inventory detail is set before creating it. Viewing the actual data isn't necessary.
You can use nlapiGetLineItemCount on inventory-details subrecord(I am using the same in SuiteScript2.0 and it works) before setting/updating records manually and if you get line count greater than 0, you can safely assume inventory details already exists for the line.
You can check this out for further reading.
I have a SSP script that is attempting to create an invoice for an existing customer with a fee determined by what they applied for. I've set up the fee items under the noninventory items and I have a query which successfully gets the internal ID of the desired item. Next the script attempts to create an invoice and in doing so I am attempting to add the existing item using the internal ID that I have found. The problem is I can't get my head around how this relates, the schema browser shows a field called itemlist which is of type InvoiceItemlist which is made up of invoiceItems.
I take that to mean that I'm working with a sublist but there isn't an invoiceitem sublist type so I'm assuming I'm working with items. So, I've tried various ways to create a new sublist record but most of the examples I can find are how to create a new sublist record where as I just want to instantiate one of the existing items. I've included the snippet of code with my current attempt which isn't working.
var recNewInvoice = nlapiCreateRecord('invoice', {recordmode:'dynamic'});
recNewInvoice.setFieldValue('customform', '104');
recNewInvoice.setFieldValue('entity', stCustId);
// Add Item to invoice
_AddItem(recNewInvoice, stFeeId);
if (stDiscountId) {
_AddItem(recNewInvoice, stDiscountId);
}
try {
objDataResponse.Invoice.Id = nlapiSubmitRecord(recNewInvoice, true, true);
}
catch (ex) {
throw nlapiCreateError('WRITE_FAILED','nlapiSubmitRecord for invoice failed.' + ex.message);
}
// further down I define the function
function _AddItem(recInvoice, ItemID){
recInvoice.selectNewLineItem('item');
recInvoice.setCurrentLineItemValue('item','item',ItemID);
recInvoice.setCurrentLineItemValue('item','quantity',1);
recInvoice.commitLineItem('item', false);
};
I'm using a function for _AddItem because I'm may be adding a discount as well as the fee and I believe they are handled the same. When I run the code with a test case that returns a valid stFeeId I get the following error in the SSP execution log:
nlapiSubmitRecord for invoice failed.Please choose an item to add
*edit added error
*edit: I've updated the code portion to show the changes I've made based on different resources I've found. The original error isn't being generated but I'm getting this new error:
nlapiSubmitRecord for invoice failed.Items you have requested in the record have been deleted since you retrieved the form
When facing a problem like this one, what I generally do is try to create the same record I'm trying to create using the script with the exact same values and by setting the fields exactly in the same order of the scripts.
I do this because, like in your case here, the order is crucial : when creating an invoice, setting the entity will impact what you can use in the other fields, including the Items : so if it is possible that you are trying to use Item1 with an EntityX and Item1 can't be chosen for that EntityX, so the item field will remain empty and you will get that error.
So try creating the Invoice from the UI and see if you can select your item after selecting your entity: if not, then you must fix your configuration, and once you are able to fully create your invoice from UI, you will be able to do so from Script.
I am using "http://www.amazon.de/dp/{ASIN}" to get product info.
But after getting response it doesn't return product "SellerSKU"
Is there any way that I can get "SellerSKU" of a product specified by "ASIN"?
I also had same situation.
And I found that there is only some limited way to get it.
https://mws.amazonservices.com/FulfillmentInventory/2010-10-01?Action=ListInventorySupply
ListInventorySupply api of Fulfillment Inventory lists returns information about the availability of a seller's inventory.
Request parameter includes SellerSKUs, QueryStartDateTime, MarketplaceId, ResponseGroup
Here you can omit SellerSKUs, and you can pass QueryStartDateTime.
Then you will get InventorySupplyList including SellerSKU and ASIN matches.
You should find the product's SellerSKU in this list.
But the problem is that it returns only available inventory list.
It will not work when product you are finding is not in available inventory list.
In this case you should make the user manually add SellerSKU in your application.
For more information, please take a look at http://docs.developer.amazonservices.com/en_US/fba_inventory/FBAInventory_ListInventorySupply.html
Hope this would help you.