#GauravMavani
1 messages · Page 1 of 1 (latest)
hello! can you share the code snippet of how you're currently creating and attaching the payment method to the customer?
passing client secret to card
$intent = $request->user()->createSetupIntent([
'payment_method_types' => ['card'],
'usage' => 'on_session',
]);
echo $intent->client_secret;
form.addEventListener('submit', async (e) => {
e.preventDefault();
cardBtn.disabled = true;
const {
setupIntent,
error
} = await stripe.confirmCardSetup(clientSecret, {
payment_method: {
card: cardElement,
billing_details: {
address: {
city: $("input[name=city]").val(),
country: $("input[name=country]").val(),
line1: $("input[name=address_line1]").val(),
line2: $("input[name=address_line2]").val(),
postal_code: $("input[name=postal_code]").val(),
state: $("input[name=state]").val()
},
email: "<?php echo Auth::user()->email; ?>",
name: "<?php echo Auth::user()->name; ?>"
}
},
});
if (error) {
cardBtn.disabled = false;
} else {
console.log(setupIntent.payment_method);
let paymentMethod = document.createElement('input');
paymentMethod.setAttribute('type', 'hidden');
paymentMethod.setAttribute('name', 'paymentMethod');
paymentMethod.setAttribute('value', setupIntent.payment_method);
form.appendChild(paymentMethod);
form.submit();
}
});
$customer = $user->createOrGetStripeCustomer([
'email' => $user->email,
'name' => $user->name,
'address' => [
'line1' => $request->address_line1,
'line2' => $request->address_line2,
'city' => $request->city,
'country' => $request->country,
'state' =>$request->state,
'postal_code' => $request->postal_code,
],
]);
$user->updateDefaultPaymentMethod($payment_method_id,["customer"=>$customer->id]);
try{
$subscription = $user->newSubscription($plan->name,$plan->stripe_plan)
->create($payment_method_id,[
'email' => $user->email,
'name' => $user->name,
'on_session' => true,
]);
}catch(IncompletePayment $exception){
return redirect()->route(
'cashier.payment',
[$exception->payment->id, 'redirect' => route('upgrade-success')]
);
}
this method i am using but not working for 3d secure
can you also share the request id where you got that error message?
Try creating the SetupIntent with the customer id passed in as well : https://stripe.com/docs/api/setup_intents/create#create_setup_intent-customer
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
instead of attaching the PaymentMethod to a customer object later
so first i have to create again setup intent in payment function then this line
$user->updateDefaultPaymentMethod($payment_method_id,["customer"=>$customer->id]);
before this i have to create setupintent?
Hi there, @arctic dragon I'm taking over this thread
now below is my current code
$customer = $user->createOrGetStripeCustomer([
'email' => $user->email,
'name' => $user->name,
'address' => [
'line1' => $request->address_line1,
'line2' => $request->address_line2,
'city' => $request->city,
'country' => $request->country,
'state' =>$request->state,
'postal_code' => $request->postal_code,
],
]);
$setupIntent = SetupIntent::create([
'payment_method' => $payment_method_id,
'payment_method_types' => ['card'],
'customer' => $customer->id,
'usage' => 'off_session',
'confirm' => true,
]);
$user->updateDefaultPaymentMethod($payment_method_id,["customer"=>$customer->id]);
try{
$subscription = $user->newSubscription($plan->name,$plan->stripe_plan)
->create($payment_method_id,[
'email' => $user->email,
'name' => $user->name,
'off_session' => true,
]);
}catch(IncompletePayment $exception){
return redirect()->route(
'cashier.payment',
[$exception->payment->id, 'redirect' => route('upgrade-success')]
);
}
}
getting this error now
As the error message suggest, you need to attach the payment method to a customer first https://stripe.com/docs/api/payment_methods/attach?lang=curl#customer_attach_payment_method
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
like this??
$paymentMethod = PaymentMethod::retrieve($payment_method_id);
$paymentMethod->attach(['customer' => $customer->id]);
$setupIntent = SetupIntent::create([
'payment_method' => $paymentMethod->id,
'customer' => $customer->id,
'usage' => 'off_session',
]);
again same error
Hi! Can you share the request ID (req_xxx)? Here's how you can find it: https://support.stripe.com/questions/finding-the-id-for-an-api-request
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
OK, based on the doc (https://support.stripe.com/questions/guide-for-saving-cards-in-india) you need to use SetupIntent to collect a payment method, and you can't attach a customer to a payment method directly.
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
but this thing i have do then after i contacted you i have sent you code above
Do you have a SetupIntent ID that I can take a look?
Yes wait sending clientsecret
seti_1N8Hg5SDJsqi3ADzSckavYN0_secret_Nu5rv4j8VhjRjp7XQdTgCffnNGnlmZr
client secret
from below code
$intent = $request->user()->createSetupIntent([
'payment_method_types' => ['card'],
]);
echo $intent->client_secret;
this popup is also coming after click on complete giving me error
pm_1N8HgiSDJsqi3ADzQg5qndhl
this is paymentmethod id
pm_1N8HgiSDJsqi3ADzQg5qndhl
What error did you see?
payment method of type card cannot be atteched
as aboce
above*
let me record and send to you??
Which test card did you use?
this 1st one
4000000000003063
this card is working
but not above image once
any luck?
Thanks for waiting, so you've managed to confirm a setupIntent successfully?
customer is created successfully but while doiung this $user->updateDefaultPaymentMethod($payment_method_id,["customer"=>$customer->id]);
its giving error that PaymentMethods of type card cannot be attached to Customers directly without 3DS due to Indian payment regulations. Please instead provide the PaymentMethod and Customer alongside a SetupIntent or PaymentIntent with the setup_future_usage parameter.
What's the new SetupIntent ID?
i am creatting setupintent only once while passing secret key
$customer = $user->createOrGetStripeCustomer([
'email' => $user->email,
'name' => $user->name,
'address' => [
'line1' => $request->address_line1,
'line2' => $request->address_line2,
'city' => $request->city,
'country' => $request->country,
'state' =>$request->state,
'postal_code' => $request->postal_code,
],
]);
$user->updateDefaultPaymentMethod($payment_method_id,["customer"=>$customer->id]);
try{
$subscription = $user->newSubscription($plan->name,$plan->stripe_plan)
->create($payment_method_id,[
'email' => $user->email,
'name' => $user->name,
'off_session' => true,
]);
}catch(IncompletePayment $exception){
return redirect()->route(
'cashier.payment',
[$exception->payment->id, 'redirect' => route('upgrade-success')]
);
}
}
see this is my current code
I just need your setupIntent ID
You haven't confirmed this setupIntent, its status is still requires_payment_method and its payment_method is null
Yes just to give you id wait 1 minute
seti_1N8ISUSDJsqi3ADzzbYoM3pq
check for this id
seti_1N8IU5SDJsqi3ADzWHQoea0i
OK, I see that seti_1N8IU5SDJsqi3ADzWHQoea0i is succeeded . Can you try using its payment_method to create a subscription?
seti_1N8IWESDJsqi3ADzztFdEwEX what about this one
for above one i got this error: PaymentMethods of type card cannot be attached to Customers directly without 3DS due to Indian payment regulations. Please instead provide the PaymentMethod and Customer alongside a SetupIntent or PaymentIntent with the setup_future_usage parameter.
Strange, I do see that 3DS was completed successfully.
Send me the ID of the request where you get this error
Hmm, why don't you set the customer first when creating the SetupIntent, so that you don't need to explicity attach the payment method to a customer
YOU WANT THAT I CREATE CUSTOMER THEN SETUP INTENT SO I CAN PASS CUSTOMER ID TO SETUP INTENT?
There's no need to shout. As I explained earlier, you can't attach a payment method to a customer due to India payment regulations.
So you should use SetupIntent to collect a payment method, and Stripe would automatically attach the payment method to the customer.
i am not shouting by mistake capslock
hello
Hello
have you checked above conversation?
I have, did you read my colleague's message?
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
Yes, i have followed the steps but nothing seems to be working