#irisslee95

1 messages · Page 1 of 1 (latest)

weary zodiacBOT
wicked fractal
#

Hello @dire surge

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

wicked fractal
#

Yes. I'm using stripe connect. I create a source to create payment intent, then I retrieve the source for some check

dire surge
wicked fractal
#

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

dire surge
#

Sorry that the discord is busy now and I'll be stepping away! My coworker @eager pecan will be assisting you shortly

eager pecan
#

Hi @wicked fractal I'm taking over, give me a sec to catch up

wicked fractal
#

Thanks @eager pecan

eager pecan
#

Can you share with me the code you wrote?

wicked fractal
#

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

eager pecan
#

What's in the extra_details ?

wicked fractal
#

It's the order's customer informations.

#

It's also the card owner infomations

eager pecan
#

I mean what data do you put inside the extra_details ? can you do a console.log to print it out?

wicked fractal
#

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"
    }
}
eager pecan
#

OK. Can you share with me the PHP code?

wicked fractal
#

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 ) );
            }
        }
eager pecan
#

Thanks for waiting. Discord is busy today

wicked fractal
#

No problem

eager pecan
wicked fractal
#

Yes, thank you so much