#davidstanton_api
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1339210377149546579
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- davidstanton_api, 6 days ago, 49 messages
๐
Could you please share more details ?
Ah I see, you are using product_data with Checkout Session
If you want to persist your products/prices and reuse them later, you need to create them separatly using Stripe APIs
i'm pushing this and it give a different productId every time'payment_method_types[0]': 'card',
'line_items[0][quantity]': '1',
'line_items[0][price_data][currency]': 'usd',
'line_items[0][price_data][unit_amount]': selectedPrice,
'line_items[0][price_data][recurring][interval]': 'month',
'line_items[0][price_data][recurring][interval_count]': paymentPeriod,
'line_items[0][price_data][product_data][name]': ${finalProductName}, for domain: ${domain},
'mode': 'subscription',
'success_url': 'http://127.0.0.1:5501/adysis-website/success.html',
'cancel_url': 'http://127.0.0.1:5501/adysis-website/floors.html',
'customer': stripeCustomerId,
'subscription_data[metadata][product]': finalProductName,
'subscription_data[metadata][domain]': domain,
'subscription_data[metadata][user_email]': customerEmail,
'subscription_data[description]': ${finalProductName}, Domain for this subscription is: ${domain},
'subscription_data[metadata][legal_entity]': 'Adysis is owned and operated by Spormeon Ltd, UK Reg. No: 07744269',
You are using dynamic pricing here. If you want to have always the same Product Id, you need to create it first separatly and then using with the Checkout Session
what mean by create first, its been created in the Ui?
You need first to create the product and the price using these APIs
Then create the Checkout Session using the returned
i cacnt just push something that tells it , "its related" to product_XXXX?
something like this:'line_items[0][product_data][productId]': 'pro_XXXXXXX', ?
After creating the price, you need to provide it when creating the Checkout Session:
https://docs.stripe.com/api/checkout/sessions/create#create_checkout_session-line_items-price
so this and it then relates it all to that actual price which is "in" a product and will return the "real" productId then?'line_items[0][price_data][price]': 'price_1Qpp6rE7dsAdGvZe236YrPGW',
line_items[0][price_data][price]': 'price_1Qpp6rE7dsAdGvZe236YrPGW',
No it's: > line_items[0][price]: 'price_1Qpp6rE7dsAdGvZe236YrPGW'
I strongly encourage you to follow the public doc I shared with you
You can check this guide in order to understand how price and products work actually
https://docs.stripe.com/products-prices/getting-started
๐ taking over for my colleague. Let me know if there's any follow-up Qs I can answer!
ok, i'm just trying it, hang on with me
its not liking this:body: new URLSearchParams({
'payment_method_types[0]': 'card',
'line_items[0][quantity]': '1',
'line_items[0][price_data][currency]': 'usd',
'line_items[0][price]': selectedPriceId,
'line_items[0][price_data][unit_amount]': selectedPrice,
'line_items[0][price_data][recurring][interval]': 'month',
'line_items[0][price_data][recurring][interval_count]': paymentPeriod,
'line_items[0][price_data][product_data][name]': ${finalProductName}, for domain: ${domain},
'mode': 'subscription',
'success_url': 'http://127.0.0.1:5501/adysis-website/success.html',
'cancel_url': 'http://127.0.0.1:5501/adysis-website/floors.html',
'customer': stripeCustomerId,
'subscription_data[metadata][product]': finalProductName,
'subscription_data[metadata][domain]': domain,
'subscription_data[metadata][user_email]': customerEmail,
'subscription_data[description]': ${finalProductName}, Domain for this subscription is: ${domain},
'subscription_data[metadata][legal_entity]': 'Adysis is owned and operated by Spormeon Ltd, UK Reg. No: 07744269',
for this part:'line_items[0][price]': selectedPriceId,
well why the hell didnt the other guy tell me that, err
so how can we do this then?
do what exactly?
right, start again is it
what?
i keep getting different productId's returned, not the product the price relates to
you either use a predefined price ID
or when creating a price_data you refer to the product ID that is already existing
so how do you "relate" to the product that already exists, asked the last guy this
in this code https://docs.stripe.com/payments/accept-a-payment?platform=web&ui=stripe-hosted#redirect-customers
you can see how to use price_data with product_data
if you want the price_data to be for a predefined product
then instead of passing product_data you pass the product ID
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
read the required conditionnally of each param
so this?'line_items[0][price_data][product]': 'prod_RePpvuRLNorRq9',
Hi ๐ jumping in as my teammate needs to step away soon. Yes, that approach looks right.
ok, let me try it, bare with me
thats dont work, you dont like [product] with [product_data][name]'line_items[0][price_data][product]': 'prod_RePpvuRLNorRq9',
'line_items[0][price_data][recurring][interval_count]': paymentPeriod,
'line_items[0][price_data][product_data][name]': ${finalProductName}, for domain: ${domain},
Correct, you either use price_data.product OR price_data.product_data, not both.
In general, use price_data or product_data if you want to create a Price or Product.
If you want to reference an existing object, then you use price or product instead.
is there no way around this, as we need to get the domain in the product name, so as it shows innportal, on invoices etc, but need it related to a "constant product"
That's not possible, unless the product name for the constant product is also constant.
Which it sounds like is not the case if you want the name on the Product object to be different for every customer. Product objects can only contain a single value for their name field.
umm , this is a right pain, as my product/s are tied to a domain
Okay, let's a take a step back. Right now it sounds like you want to use a Product object to represent a distinct domain, but primarily to get the name of that Product to bubble up through the Stripe UIs. Am I understanding correctly?
If so, I'm going to go do some testing and see if there is a different approach that I'd recommend for this.
ye basically, so the domain shows on everything such as these:
i also couldnt get it to "switch" products, as there are actualy 3 products, monthly, 6monthsd, 12 months, but if allow them to "deit subscriptions", they have the ability to switch to another product, where as they shouldnt
I think you're mixing up Products and Prices there.
so i turned that off and it works if i have a "contcat us", they tell me they want "Amazon floors" as well as "prebid floors" adn i do it manually in the subscription in back end
i need a "constant" for my backend, so i can "tie a domain to a product" and allow/ disallow access to a file based on it
e.g this is what they can have. Prebid monthly, Amazon monthly, tied to domain.com
Is something like this acceptable for your use case?
Where the Product is that you're offering domain hosting (or whatever your actual product that you're selling is), and you use the description field on the Subscription to hold the address of the domain being hosted?
it dont appear on invoice etc then though? i might have a "publisher" with 100 sites
And you would need each domain to be a single line item?
my current way, i get it all on the invoices, receipts etc
ye, they might cancel one domain, keep the other 99
Then you won't be able to use a single Product it sounds like, and instead will need to create a unique Product for each domain. Because in your case your product isn't "hosting a domain", it's "hosting this specific domain".
well we got a different of logic i guess "becasue" stripe dont support this abilty to add "info" on invoices
it is actually 1 product, the file they get is the same whatever the domain,
the snippet they get is tied to the cust number and i tie it to "origin" / referrer" in the background:<!-- <script>
const accountId = "cus_RddP5fcjeEBxf7"; // Your accountId for the domain where want to run floors
Amazon = active/inactive // use this to turn on amazon floors
const prebid_global = pbjs; // Enter your prebid global, must be var not const or let
window.prebid_global = prebid_global; // make pbjs globally availabe in the window, so we can pick it up
//console.log("prebid global", prebid_global);
//var pbjs = pbjs || {}; // insert your prebid "global" here = pbjs || {}; e.g. ABCD instead of pbjs
// floor script load, do not edit below
const script = document.createElement("script");
script.src = `https://floors.adysis.com/${accountId}`;
script.async = true;
//script.defer = true;
script.setAttribute("fetchpriority", "high");
document.head.appendChild(script);
</script> -->
but i need cus_RddP5fcjeEBxf7 is allowed for domain XXXXX.com, product:Prebid, Product:Amazon
cant have amazon unless they sub'ed to prebid
like im all over the shop here with productId's, as i'll need to do some if got Prebid productId, allow, if got Prebid productId & Amazon Id, allow both in the scripts:
Sorry, but I'm not sure I'm grasping what you're trying to ask now. I'm having a hard time telling whether your product is generic and can be applied to all of your customers, or if it's domain-specific and you will need a unique one for each subscription item.
it generic in the sense its the same file basically, but it has to be tied to a domain, so as i only allow the 1 file to be used on 1 site, or they could sign up once and then use across 100 sites
how do it get meta in here:
Personally, I'd model that as a single Product in Stripe, and then handle the domain tracking on your end. But, I'm getting the impression you're also trying to use Stripe objects for the domain management, in which case this gets much trickier to model.
evt_1QreJpE7dsAdGvZe5sTKBlZE
By setting metadata on the Price objects being used, either during creation, or by updating them:
https://docs.stripe.com/api/metadata
https://docs.stripe.com/metadata
https://docs.stripe.com/api/prices/create#create_price-metadata
https://docs.stripe.com/api/prices/update#update_price-metadata
You can't set metadata during adhoc Price creation if you're using price_data.
if i could get meta in theose. i could use: "prebidmonthly", prebid6months,"prebid12months"
'line_items[0][price_data][metadata]': 'PrebidMonthly', ?
No, as mentioned above, you can't set metadata during adhoc Price creation if you're using price_data.
But the recurring.interval_count field on the Price, in conjunction with recurring.interval, tells you the billing frequency for the recurring Price. Do you need to track that in metadata as well?
You can create the Price object first if those details are important to you
but your saying i cant have both, getting confused myself now
//'line_items[0][price]': selectedPriceId,
'line_items[0][price_data][unit_amount]': selectedPrice, this is a no go, so i cant get anything to meta
Not sure I'm following.
You can either use price_data to create a Price adhoc when creating the Checkout Session, in which case you have less fields that you're able to set.
OR
You can create the Price object first, by using the endpoint documented here:
https://docs.stripe.com/api/prices/create
which gives you access to all of the fields that can be set for a Price object.
Then, when you're creating the Checkout Session, instead of using price_data to create a new Price, you can pass the ID of the Price created previously to the price field.
price_data and product_data are sort of shortcuts to let you create Price and Product objects as part of a creation request for a different type of object. You can still always create Prices and Products first, as a separate request, rather than using the *_data hashes.
umm, that will make the checkout "processs" drag on for ages, create product/ price, wait for it to return, push product_data. they will prob be gone in that time, before i get their "mulla"
You wouldn't use product_data if you're creating the Prices and Products ahead of time.
i would to get the domain info on the invoices etc, its the only way to do that bit?