#xarvoit
1 messages · Page 1 of 1 (latest)
Hello! We'll be with you shortly. 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.
- xarvoit-connect-intro, 20 hours ago, 9 messages
async function initPayment(data, isProd) {
try {
const stripe = new stripeModule.Stripe(secretKey(isProd), {
apiVersion: "2020-08-27",
});
// const customers = await stripe.customers.list({
// email: data.email,
// limit: 1,
// });
// var customer = customers.data[0];
// if (!customer) {
// customer = await stripe.customers.create({
// email: data.email,
// ...(data.name && { name: data.name }),
// }, {
// stripeAccount: data.vendorAccountId,
// });
// }
const customer = await stripe.customers.create();
const ephemeralKey = await stripe.ephemeralKeys.create(
{customer: customer.id},
{apiVersion: "2023-08-16"}
);
// Create a token to clone the payment method
const token = await stripe.tokens.create({
customer: customer.id,
}, {
stripeAccount: data.vendorAccountId,
});
// Attach the token to a customer on the connected account
const customerOnHostAccount = await stripe.customers.create({
source: token.id,
}, {
stripeAccount: data.vendorAccountId,
});
const paymentMethod = await stripe.paymentMethods.create({
customer: customer.id,
payment_method: customerOnHostAccount.pay
})
const paymentIntent = await stripe.paymentIntents.create(
{
amount: data.amount,
currency: 'usd',
customer: customerOnHostAccount.id,
description: data.description ?? "Empty",
application_fee_amount: data.amount * 0.02,
automatic_payment_methods: {
enabled: true,
}
},{
stripeAccount: data.vendorAccountId
}
);
return {
paymentId: paymentIntent.id,
paymentIntent: paymentIntent.client_secret,
ephemeralKey: ephemeralKey.id,
customer: customer.id,
success: true,
};
} catch (error) {
console.log(`Error: ${error}`);
return { success: false, error: userFacingMessage(error) };
}
}
you're not setting stripeAccount ID here
customer: customer.id,
payment_method: customerOnHostAccount.pay
})```
is there a specific guide you're following for this?
It’s been pretty all over the place
so after creating the payment method object do I need to do anything else?
I mean we don't know what flow you're building so can't tell if you need to do anything else or not.
Can you provide context on what you're trying to build?
Hi there
do I need to do anything else?
Do anything else to achieve what?
I don't understand
So I've been trying to process donations for my host accounts on my platform. I want to send the money while taking a fee. I believe direct charges is the correct way to do that in Stripe Connect.
for some time now I've been stuck at the Error: The customer must have an active payment source attached with no progress
Yeah so how are you collecting payment method details from them?
IDK
How can you create a payment method if you don't collect details from them?
Hold on I'm seriously not understanding the flow. Does the process start with a server request? The data that I'm sending to the server is: users, is email, name, currency, description, amount and the connectedAccountId. Which if succesful can be used to generate the client side payment window
Your code above is really strange
It's not what we recommend in our docs really
First of all, do you want a stripe-hosted payment page or do you plan on using the payment element on your page?
stripe-hosted payment page
So yeah you'd never create a payment intent or payment method explicitly if you want that flow
Recommend you follow this guide then: https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=checkout
That can be used with direct charges too
Are those requirements the same for Mobile as well?
I try to keep my questions lean but I'll just say that I'm using a low code Flutter tool and that most of the code comes from their stock implementation of payments. Which only handles naive Stripe use cases and nothing with Stripe Connect. So I'm building my own
So how do you want to implement a stripe-hosted flow?
Is this going to be in a webview?
Not an expert on Flutter but there is a custom API that seems to take care of it: https://docs.page/flutter-stripe/flutter_stripe/sheet
Yeah that's a 3rd party library so I can't comment on it
Nor can I support its use
We just help with our official libraries
right but it leverages some NodeJs for the server based stuff. It points to the ios tab https://stripe.com/docs/payments/accept-a-payment?platform=ios#add-server-endpoint. The server stuff is whats getting me I just need to get that working and return a paymentIntend.id, customerId, and ephemeralKey
Ok but why do you say you want a stripe-hosted page then?
That's a flow that uses mobile components in app
But if you do want to do it that way, you should just be able to copy that code
What you're doing in the above snippet at the top of this thread is completely different
Yeah I think I've realized that now
It might just be as simple at this:
const stripe = require('stripe')(secretKey, {
stripeAccount: data['vendorAccountId'],
});
const paymentIntent = await stripe.paymentIntents.create(
{
amount: data.amount,
currency: 'usd',
// customer: customerOnHostAccount.id,
description: data.description ?? "Empty",
application_fee_amount: data.amount * 0.02,
payment_method_types: ['card'],
},{
stripeAccount: data.vendorAccountId
}
);
return {
paymentId: paymentIntent.id,
paymentIntent: paymentIntent.client_secret,
customer: customer.id,
};
You said you needed customer and ephemeral key