#dhruv8901

1 messages · Page 1 of 1 (latest)

hasty totemBOT
spare lynx
#

I don't quite understand your question, can you break down your sentence and explain again?

verbal mango
#

sure wait i will explain whole scenario

#

I have two users and those two users have card details so now can i do a payment through one user's card details and send them to another user through their card details? means the sender and receiver have both card details only so can i do a payment in the receiver id from their card details?

spare lynx
#

Are these users connected accounts of your platform?

verbal mango
#

yes

#

are you getting my point?

spare lynx
verbal mango
#

in chat gpt i found this solution is it working currently or not?

#

const stripe = require('stripe')('YOUR_STRIPE_SECRET_KEY');

// Step 1: Collect Card Details

// Assuming you have the card details for both users
const payerCardDetails = {
number: '4242424242424242',
exp_month: 12,
exp_year: 2024,
cvc: '123'
};

const recipientCardDetails = {
number: '4111111111111111',
exp_month: 12,
exp_year: 2024,
cvc: '123'
};

// Step 2: Create Customer Profiles

// Create a customer for the payer (user making the payment)
const payerCustomer = await stripe.customers.create({
email: 'payer@example.com',
source: payerCardDetails
});

// Create a customer for the recipient (user receiving the payment)
const recipientCustomer = await stripe.customers.create({
email: 'recipient@example.com',
source: recipientCardDetails
});

// Step 3: Initiate Payment

// Create a payment intent using the payer's customer ID
const paymentIntent = await stripe.paymentIntents.create({
amount: 1000, // Payment amount in cents
currency: 'usd',
customer: payerCustomer.id,
payment_method_types: ['card'],
transfer_data: {
destination: recipientCustomer.id,
},
});

// Step 4: Transfer Funds

// Execute the payment intent
const paymentResult = await stripe.paymentIntents.confirm(paymentIntent.id);

// If the payment succeeded, you can initiate a transfer to the recipient's Stripe account
if (paymentResult.status === 'succeeded') {
const transfer = await stripe.transfers.create({
amount: paymentIntent.amount,
currency: paymentIntent.currency,
destination: recipientCustomer.id,
});

console.log('Payment and transfer completed successfully.');
} else {
console.log('Payment failed.');
}

spare lynx
#

I'm not sure whether the ChatGPT generated code would, have you tried?

verbal mango
#

no because if stripe is not allowed this type of payment like destination.

spare lynx
#

I'd suggest you to go through the doc that I sent earlier, and come back if you have a specific question.

verbal mango
#

but creating connect account is a too long process so if stripe support direct card to card payments then is easy for developing

hasty totemBOT
plush wigeon
#

Hey, taking over here. Let me know if there's any follow-up Qs I can answer!