#irisslee95
1 messages · Page 1 of 1 (latest)
Hello @dire surge
Sorry that the discord server is busy now. Looking into it
Could you share what you're tying to do with this request?
There's no such GET API with /v1/customers/cus_xxx/sources/src_xxx
Yes. I'm using stripe connect. I create a source to create payment intent, then I retrieve the source for some check
You can use Source Retrieval API directly to check the source: https://stripe.com/docs/api/sources/retrieve
Hmm. I created a source on the front end using Stripe JS, then passed the source ID to the backend to retrieve customer source. Do I need to attach source to customer before returning it to the backend?
Hello @dire surge
Sorry that the discord is busy now and I'll be stepping away! My coworker @eager pecan will be assisting you shortly
Hi @wicked fractal I'm taking over, give me a sec to catch up
Thanks @eager pecan
Can you share with me the code you wrote?
Yes.
createSource: function() {
var extra_details = wcv_stripe_connect_form.getCustomerDetails();
// Create the Stripe source
stripe
.createSource(stripe_card, extra_details)
.then(wcv_stripe_connect_form.sourceResponse);
},
This is JS code on the frontend
What's in the extra_details ?
I mean what data do you put inside the extra_details ? can you do a console.log to print it out?
Yes this is extra_details object
{
"owner": {
"name": "Le Du",
"address": {
"line1": "Tam Binh",
"line2": "",
"state": "",
"city": "Vinh Long",
"postal_code": "",
"country": "VN"
},
"email": "customer1@localhost.test",
"phone": "0384926898"
}
}
OK. Can you share with me the PHP code?
Yes. here
// Attach the source to the customer.
if ( $customer_id && $source_id ) {
$customer_source = '';
try {
$customer_source = \Stripe\Customer::retrieveSource( $customer_id, $source_id );
} catch ( Exception $e ) {
WCV_SC_Logger::log( 'Customer Source Error: ' . $e->getMessage() );
}
if ( ! $customer_source ) {
$customer_source = \Stripe\Customer::createSource(
$customer_id,
array(
'source' => $source_id,
)
);
$source_object = $customer_source;
WCV_SC_Logger::log( sprintf( 'Created a new source: %s for customer', $source_object->id ) );
}
}
Thanks for waiting. Discord is busy today
No problem
https://stripe.com/docs/api/sources/retrieve?lang=node#retrieve_source based on the API reference, I don't think you need to specify a customer ID when retrieving a source
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Yes, thank you so much