#qadeer_code

1 messages ยท Page 1 of 1 (latest)

ebon pawnBOT
#

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

๐Ÿ“ 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.

cosmic plinth
#

๐Ÿ‘‹ happy to help

shy smelt
#

hello

cosmic plinth
#

would you mind sharing the request ID that failed?

shy smelt
#

I am creating payment method and assigning it to customer. When i assign paymentId to customer i get error no payment id exist

#

yes

#

I am gettig object from createPaymentmethod api
{
"id": "pm_1QKJfiAL2DaIkOXQ6jIFXdrZ",
"object": "payment_method",
"allow_redisplay": "unspecified",
"billing_details": {
"address": {
"city": null,
"country": "PK",
"line1": null,
"line2": null,
"postal_code": null,
"state": null
},
"email": "raxi@mailinator.com",
"name": "Tatiana Snyder",
"phone": null
},
"card": {
"brand": "visa",
"checks": {
"address_line1_check": null,
"address_postal_code_check": null,
"cvc_check": null
},
"country": "US",
"display_brand": "visa",
"exp_month": 3,
"exp_year": 2033,
"funding": "credit",
"generated_from": null,
"last4": "4242",
"networks": {
"available": [
"visa"
],
"preferred": null
},
"three_d_secure_usage": {
"supported": true
},
"wallet": null
},
"created": 1731416298,
"customer": null,
"livemode": false,
"radar_options": {},
"type": "card"
}

#

and i pas this id to attach payment to customer
if (paymentMethod) {
attachCardResponse = await api.post(apiRoutes.ATTACH_CARD_CUSTOMER, {
email: user.email,
name: user.name,
paymentId: paymentMethod.id,
});

cosmic plinth
shy smelt
#

const newUserSubscription = new UserSubscription();

const { name, email, paymentId } = request.body;
const customers = await stripe.customers.search({
  query: `email:'${email}'`,
});


if (customers.data.length) {
  return sendErrorResponse(
    response,
    "customer already exist with this email",
    404
  );
}
const customer = await stripe.customers.create({
  name: name,
  email: email,
});


const result = await stripe.paymentMethods.attach(paymentId, {
  customer: customer.id,
});
await stripe.customers.update(customer.id, {
  invoice_settings: {
    default_payment_method: paymentId,
  },
});

This is my api that attach payment id to costomer

#

I did not get this. This is not the soltuion. If i change the stripe account same this piece of code works

cosmic plinth
#

you should follow the code I sent you

#

and use the SetupIntent instead of the attach PM API

shy smelt
#

But could you tell me the why should not i use PM API and why it's working for other stripe account

cosmic plinth
#

I need to see the request ID to know exactly what's happening

shy smelt
#

Here whenever i try to attach payment id this api crash

cosmic plinth
#

please share the request ID req_xxx

shy smelt
#

req_A0jdgMf6acZcJ7

cosmic plinth
#

ok so basically you're creating the PaymentMethod on the frontend using the acct_1ODrzaAL2DaIkOXQ's publishable key

#

which is your US account

shy smelt
#

Yes i am creating paymentMethod on frontEnd

cosmic plinth
#

and in the backend you're trying to attach it to a customer created using the acct_1Q7u7iA5VZGs0nQZ's secret key

#

which is you AU account

#

the resource_missing is in that case expected since the PM you created on your US account is not accessible by the AU account

shy smelt
#

I am using the secret key and publishable key from same account that were created in AU.

#

It's strange

cosmic plinth
#

not on your frontend

#

please double check

shy smelt
#

I checked it and it's test mode publishable key

cosmic plinth
#

of the US account

shy smelt
#

Could it be that first time i used the publishable key of us

#

and now it's no accepting it ?

cosmic plinth
shy smelt
#

How can i delete the payment method

cosmic plinth
#

it's in test mode so no need to delete anything

shy smelt
#

But still i cannot asign payment method to client because they are of different countries

cosmic plinth
#

you need to change the publishable key on your frontend

shy smelt
#

let me double check

#

Keys are good
const options: StripeElementsOptionsMode = {
mode: "setup",
currency: "usd",
paymentMethodCreation: "manual",
paymentMethodTypes: ["card"],
};
could it be because of currency: "usd", ?

cosmic plinth
#

no not related to the currency

#

how are you setting your key?

#

is it hardcoded in the code, or in an environment variable? are you testing this locally or on a public server?

shy smelt
#

i am setting them in env and testng locally

cosmic plinth
#

pk_test_51Q7u7iA************E00v6YmsbaL

#

is this the one?

shy smelt
#

Yes this is on frontend

cosmic plinth
#

ok please restart your frontend server

ebon pawnBOT
cosmic plinth
#

changing environment variables while the server is running doesn't reflect the changes

shy smelt
#

i restarted it couple of times

#

let me try it again

cosmic plinth
#

could you create a new PM and send me the PM ID pm_xxx

shy smelt
#

'pm_1QKK9HAL2DaIkOXQbTmypYkA'
Here i just created now

#

Also i just using this endpoint to see if endpoint was created or not. It's returing me empty array
const paymentMethodsLit = await stripe.paymentMethods.list()

sleek folio
#

Yes, because that endpoint is for fetching payment methods related to Treausry. There's no API to list unattached payment methods

sleek folio
#

So your code that initialises Stripe.js is using keys from a different account, as my colleague has explained

shy smelt
#

I already got your point. But i am not getting it's creating payment method in my different stripe account

sleek folio
#

Not sure what else to say. The logs for the request that create the PM via Stripe.js indicate how and where the object was created

#

If I were you I'd reassess your code, specifically the part that initialises Stripe.js, and maybe see where the source of the pk_test_xxx key is. Try hard coding the key from the AU account instead of using an env variable

shy smelt
#

Okay thanks for this much help

sleek folio
#

Outside of that, we can't really help you I'm afraid. This is a integration issue in your code

shy smelt
#

Yup i got your point. readlly helpful

#

Thanks for the help