#18thdtm_api

1 messages · Page 1 of 1 (latest)

remote vesselBOT
#

👋 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/1334532303262715977

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

pure canyon
#

Which event(s) are you listening to?

high fulcrum
#

@app.route('/payment', methods=['POST'])
def payment():
username = session.get('username')
# PaymentLinkの生成
payment_link = stripe.PaymentLink.create(
line_items=[
{
'price': 'price_1QkSR7EpGi2ke3Wdx9N24CBI',
'quantity': 1
}
],
metadata={'username': username} # メタデータにusernameを追加
)
# 支払いリンクをDiscord Webhookに送信
discord_message = {
"content": f"{username} の支払いリンクが作成されました: {payment_link.url}"
}
headers = {
'Content-Type': 'application/json'
}
response = requests.post(DISCORD_WEBHOOK_URL, data=json.dumps(discord_message), headers=headers)
return f'支払いリンクが作成され、Discordに送信されました: <a href="{payment_link.url}">{payment_link.url}</a>'

@app.route('/webhook', methods=['POST'])
def stripe_webhook():
data = request.json
print(json.dumps(data, indent=4)) # 受信したペイロードをログに出力

metadata = data['data']['object'].get('metadata', {})
username = metadata.get('username')
discord_message = {
    "content": f"{username} が支払いに成功しました!"
}
headers = {
    'Content-Type': 'application/json'
}
response = requests.post(DISCORD_WEBHOOK_URL, data=json.dumps(discord_message), headers=headers)
return 'OK', 200
#

I would like to know how to receive the metadata added to the payment link programmatically via webhook.

high fulcrum
pure canyon
#

The event type I mean. payment_intent.* or checkout.session.*. Which event type(s) is your webhook handling

high fulcrum
#

It's payment_intent.succeeded

remote vesselBOT
pure canyon
high fulcrum
#

Is this payment_intent_data.metadata?

#

How do I pass payment intent metadata to my payment link?

#

import stripe
stripe.api_key = "sk_test_09l3shTSTKHYCzzZZsiLl2vA"

stripe.PaymentLink.modify(
"plink_1MoC3ULkdIwHu7ixZjtGpVl2",
metadata={"order_id": "6735"},
)

void drift
#

Hey there, just taking over for ynnoj as they had to step away, give me a minute to review

#

You need to update payment_intent_data.metadata

#

the top level metadata will be applied to the Checkout session, not the payment intent

void drift
high fulcrum
#

I'll try to set up a checkout session. Please wait a moment.

#

Thank you! It worked! I was struggling with this for days and it really helped! Thank you so much!!