#lordstar7_code
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can 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/1256070620958167111
đ Have more to share? Add 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.
- lordstar7_api, 1 day ago, 35 messages
- lordstar7_api, 2 days ago, 25 messages
You can always update the PaymentIntent to the Customer. But keep in mind that will only marks the connection between PI <> Customer. If you want the Customer to have the Payment Method saved, you will need additional steps
it has the right payment method so that should be ok... I just need to associate the customer?
stripe payment_intents update pi_3PQtzEGEfs7cZv8K1TkA4udJ --customer="cus_QKAD9KD2SUxHfI"
awesome, thanks
that worked
quick question
why does Jose have two transactions?
but when I go in there, there is only one?
it has the right payment method.
But that PaymentMethod still not belongs to the Customer. You will need to
- Attach t he PM to the Customer
- Set the PM as the Customer's
invoice_settings.default_payment_method
So next time you charge the Customer it can use that PaymentMethod
ok, will associate the PM as the customer
stripe customers update cus_QKAD9KD2SUxHfI -d "invoice_settings[default_payment_method]=pm_1PQu0xGEfs7cZv8KCgMHoGNh"
{
"error": {
"message": "The customer does not have a payment method with the ID pm_1PQu0xGEfs7cZv8KCgMHoGNh. The payment method must be attached to the customer.",
"param": "payment_method",
"request_log_url": "https://dashboard.stripe.com/logs/req_eOkN8zp5hkJp8H?t=1719543034",
"type": "invalid_request_error"
}
}
Yes you need to call the Attach Payment Method first
I see
stripe payment_methods attach pm_1PQu0xGEfs7cZv8KCgMHoGNh --customer="cus_QKAD9KD2SUxHfI"
{
"error": {
"message": "This PaymentMethod was previously used without being attached to a Customer or was detached from a Customer, and may not be used again.",
"request_log_url": "https://dashboard.stripe.com/logs/req_ynnlOd6a3zJRGo?t=1719544061",
"type": "invalid_request_error"
}
}
Oh that's right! Sorry yes I overlook this case. It's because the Paymentmethod was used previously without setup_future_usage
In short: You can create and confirm a PI, then later create a Customer and attach the previously used PM to it only if the first PI was created with setup_future_usage
Example flow (in Ruby)
pi2 = Stripe::PaymentIntent.create({
amount: 2000,
currency: 'jpy',
setup_future_usage: 'off_session',
payment_method_types: ['card'],
})
cpi2 = Stripe::PaymentIntent.confirm(
pi2.id,
{
payment_method: 'pm_card_visa'
},
)
p cpi2.id
p cpi2.payment_method
cus2 = Stripe::Customer.create({})
Stripe::PaymentMethod.attach(
cpi2.payment_method,
{customer: cus2.id},
)
pm2 = Stripe::PaymentMethod.retrieve(cpi2.payment_method)
p pm2
note the setup_future_usage: 'off_session'
Future<Map<String, dynamic>?> createPaymentIntent({
required double amount,
String? customerId,
}) async {
Map<String, dynamic> map = {};
map['amount'] = calculateAmount(amount);
map['currency'] = 'USD';
map['payment_method_types[]'] = 'card';
map['capture_method'] = 'manual';
if (customerId != null) map['customer'] = customerId;
debugPrint("_environment?.stripeSecretkey ::${_environment?.stripeSecretkey}");
try {
var response = await http.post(
Uri.parse('https://api.stripe.com/v1/payment_intents'),
headers: {
'Authorization': 'Bearer ${_environment?.stripeSecretkey}',
'Content-Type': 'application/x-www-form-urlencoded',
},
body: map,
);
// log('Payment Intent Body->>> ${response.body.toString()}');
return jsonDecode(response.body);
} on StripeException catch (ex) {
// SnackBarAlerts.warningAlert(message: "Error Occurred while Paying.");
// log('Inside Intent Catch Statement: ${ex.toString()}');
return null;
}
}
so in my flutter code, I should simply add the
setup_future_usage: 'off_session',
or
map['setup_future_usage'] = 'on_session';
ok, I'll change the code and confirm that this is on
stripe payment_methods retrieve pm_1PQu0xGEfs7cZv8KCgMHoGNh
results
{
"id": "pm_1PQu0xGEfs7cZv8KCgMHoGNh",
"object": "payment_method",
"allow_redisplay": "unspecified",
"billing_details": {
"address": {
"city": null,
"country": "US",
"line1": null,
"line2": null,
"postal_code": "80134",
"state": null
},
"email": null,
"name": null,
"phone": null
},
"card": {
"brand": "amex",
"checks": {
"address_line1_check": null,
"address_postal_code_check": "pass",
"cvc_check": "pass"
},
"country": "US",
"display_brand": "american_express",
"exp_month": 1,
"exp_year": 2026,
"fingerprint": "X9bQGPpDpxAcWYnp",
"funding": "credit",
"generated_from": null,
"last4": "3009",
"networks": {
"available": [
"amex"
],
"preferred": null
},
"three_d_secure_usage": {
"supported": true
},
"wallet": null
},
"created": 1718209631,
"customer": null,
"livemode": true,
"metadata": {},
"type": "card"
}
this is the payment method in question, I don't see the setup_future_usage
It's on the PaymentIntent object
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
setup_future_usage is null here
oh, checking now
so instead of null it should be off_session?
what is the different between off_session & on_session?
It's about next time when you charge your Customer. If you anticipate they are offline -> use off_session
ie. you Charge them on the fly, on your server
so going back to this...
how do I rectify this?
it should say $210 for Jose, and $0 for guest
Can you open Joe 2 transactions? What is his customer id?
Can you paste here the Customer Id? cus_xxx
cus_QKAD9KD2SUxHfI
And which screen is this?
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
I believe that's the group of the Guest Customer we detected using the same card info
Do you mean you want the Customer only display $210?