#davidstanton_api

1 messages ยท Page 1 of 1 (latest)

tardy lanceBOT
#

๐Ÿ‘‹ 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.

swift lark
#

๐Ÿ‘‹
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

hollow tiger
#

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',

swift lark
#

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

hollow tiger
#

what mean by create first, its been created in the Ui?

swift lark
#

You need first to create the product and the price using these APIs

#

Then create the Checkout Session using the returned

hollow tiger
#

i cacnt just push something that tells it , "its related" to product_XXXX?

#

something like this:'line_items[0][product_data][productId]': 'pro_XXXXXXX', ?

swift lark
hollow tiger
#

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',

swift lark
#

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

tardy lanceBOT
swift lark
pure swallow
#

๐Ÿ‘‹ taking over for my colleague. Let me know if there's any follow-up Qs I can answer!

hollow tiger
#

ok, i'm just trying it, hang on with me

hollow tiger
#

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,

pure swallow
#

you can't have both price and price data

#

it's either one or the other

hollow tiger
#

well why the hell didnt the other guy tell me that, err

#

so how can we do this then?

pure swallow
#

do what exactly?

hollow tiger
#

right, start again is it

pure swallow
#

what?

hollow tiger
#

i keep getting different productId's returned, not the product the price relates to

pure swallow
#

you either use a predefined price ID

#

or when creating a price_data you refer to the product ID that is already existing

hollow tiger
#

so how do you "relate" to the product that already exists, asked the last guy this

pure swallow
#

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

#

read the required conditionnally of each param

hollow tiger
#

so this?'line_items[0][price_data][product]': 'prod_RePpvuRLNorRq9',

tardy lanceBOT
acoustic marsh
#

Hi ๐Ÿ‘‹ jumping in as my teammate needs to step away soon. Yes, that approach looks right.

hollow tiger
#

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},

acoustic marsh
#

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.

hollow tiger
#

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"

acoustic marsh
#

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.

hollow tiger
#

umm , this is a right pain, as my product/s are tied to a domain

acoustic marsh
#

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.

hollow tiger
#

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

acoustic marsh
#

I think you're mixing up Products and Prices there.

hollow tiger
#

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

acoustic marsh
#

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?

hollow tiger
#

it dont appear on invoice etc then though? i might have a "publisher" with 100 sites

acoustic marsh
#

And you would need each domain to be a single line item?

hollow tiger
#

my current way, i get it all on the invoices, receipts etc

#

ye, they might cancel one domain, keep the other 99

acoustic marsh
#

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".

hollow tiger
#

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:

acoustic marsh
#

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.

hollow tiger
#

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:

acoustic marsh
#

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.

hollow tiger
#

evt_1QreJpE7dsAdGvZe5sTKBlZE

acoustic marsh
hollow tiger
#

if i could get meta in theose. i could use: "prebidmonthly", prebid6months,"prebid12months"

#

'line_items[0][price_data][metadata]': 'PrebidMonthly', ?

acoustic marsh
acoustic marsh
hollow tiger
#

so its useles for dynamic then?

#

and nickname

acoustic marsh
#

You can create the Price object first if those details are important to you

hollow tiger
#

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

acoustic marsh
#

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.

tardy lanceBOT
hollow tiger
#

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"

acoustic marsh
#

You wouldn't use product_data if you're creating the Prices and Products ahead of time.

hollow tiger
#

i would to get the domain info on the invoices etc, its the only way to do that bit?

calm spire
#

toby had to step away, so I'm taking over

#

Can you clarify what you mean by the above?