#ryan-connect-direct

1 messages · Page 1 of 1 (latest)

grim sandalBOT
candid rune
#

Hey @shadow stone I'm happy to help, but I can't write the code for you or do pairing or anything like this. This Discord server is for developers to ask questions about their own integration/code. If you want to explain the issue and are the developer owning the code then I'm happy to help

shadow stone
#

HI

candid rune
#

@shadow stone I deleted all your messages

shadow stone
#

Sorry I am here. I was putting too much in the main chat sorry

candid rune
#

all good

shadow stone
#

@candid rune

candid rune
#

please read what I said above, this server is for developers, you don't seem to be the developer

shadow stone
#

do you need me to post again?

candid rune
#

No I think you need to go to our support team for help, or get your developer to ask questions here

shadow stone
#

My developer cannot connect. he has been waiting for 4 hours for verification emaio

#

email

#

I have him in skype and I will relay text to him and him back to you. Here is his message

#

Hello

i am able to create payment method with connected account
as well create customer with connect account
as well payment intent with connect account

but when i try to make payment then it says payment method not avaiable
after many time tries i am able to make payment.

#

if you can verify his email he is free right now.

candid rune
#

no I am sorry I won't debug through you, this will never work

shadow stone
#

ok how can I get him here. he is not getting email verificaiton

candid rune
#

I don't know sorry.

shadow stone
#

I got help this way before and it worked fine

#

I am more than capable

#

I am a junior dev on my site for 8 years

candid rune
#

Okay so what is your exact and clear question about the issue, your code and the error you get? Please don't send many short sentences in a row, take a few minutes to clearly summarize what you are asking all in one message

shadow stone
#

ok got it

#

i am able to create payment method with connected account
as well create customer with connect account
as well payment intent with connect account

but when i try to make payment then it says payment method not avaiable
after many time tries i am able to make payment.

candid rune
#

@shadow stone I would recommend watching https://www.youtube.com/watch?v=dCL9adgdP0A first.
It explains exactly how Direct Charges work and where the objects need to live.

Right now you explained a bit of the context, hinted at an error instead of giving the real error, no example object ids, no error request ids, no code shared, no info about how you integrate, etc.
Unfortunately with so little data there isn't much I can do to help yet

#

ryan-connect-direct

shadow stone
#

Here is the error message

candid rune
#

That is a picture

#

We're both developers, you can find the exact error from your code, find the logs, debug it and give me all the relevant information (code + request id + other object ids)

shadow stone
#

yes I will get it

candid rune
#

deleted the image again since there's a real email in it

shadow stone
#

ok got it. Sending error in a few

#

Payment Failed ( No such PaymentMethod: 'pm_1NuHkLHyN94ZYD9BIP50FCbq'; It's possible this PaymentMethod exisits on one of your connected accounts, in which case you should retry this request on that connected account. Learn more at https://stripe.com/docs/connect/authentication).Refresh and try again

#

we are getting payment method not available error may times and some time it works fine when make payment

With direct charge option

candid rune
#

Okay that's still one small bit of the info I need from you. Where does the error happen? Client-side or server-side? What code causes it?

#

Where does that PaymentMethod id come from? It doesn't exist in our systems

shadow stone
#

Client side. Payment method is from credit card token generate

candid rune
#

Are you understanding all of this or repeating what your developer says? Because that sentence doesn't really make sense. There's no "card token generate" when you create a PaymentMethod and that id doesn't exist either

shadow stone
#

I am typing and understanding and from what see that is it. Payment method id generate when we create payment method using credit debit card token

candid rune
#

we create payment method using credit debit card token
what does that mean? Can you share the exact relevant code?

shadow stone
#

we wrote a whole plugin I cannot share that but let me get the snippet that refers to exactly that.

candid rune
#

All I want is the 5 or 10 lines of code that are relevant really.

shadow stone
#

understood. will get it now

#

$intent = \Stripe\PaymentIntent::create( $payment_intent_args , array(
'stripe_account' => $this->eh_stripe_partner_account_id,
'idempotency_key' => $wc_order->get_order_key().'-'.$payment_method
));

candid rune
#

That's a PAymentIntent creation. What are you passing in that $payment_intent_args?

shadow stone
#

here

#

$charge = array(
'payment_method' => $token,
'amount' => $amount,
'currency' => $currency,
//'transfer_group' => 'ORDER_'.$wc_order->get_order_number(),
'application_fee_amount' => $application_fees,
'automatic_payment_methods' => ['enabled' => true, 'allow_redirects' => 'never'],
//'transfer_data' => ['destination' => $this->eh_stripe_partner_account_id],
'metadata' => array(
'order_id' => $wc_order->get_order_number(),
'Total Tax' => $wc_order->get_total_tax(),
'Total Shipping' => $wc_order->get_total_shipping(),
'Customer IP' => $client['IP'],
'Agent' => $client['Agent'],
'Referer' => $client['Referer'],
'WP customer #' => (WC()->version < '2.7.0') ? $wc_order->user_id : $wc_order->get_user_id(),
'Billing Email' => (WC()->version < '2.7.0') ? $wc_order->billing_email : $wc_order->get_billing_email()
),
'description' => wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) . ' Order #' . $wc_order->get_order_number(),
);

candid rune
#

Okay so 'payment_method' => $token,, this code, super confusing because I assume the variable called $token contains a PaymentMethod id pm_123 and not a Token id tok_123
Is that correct?

shadow stone
#

yes you are correct

#

it generates from stripeCard

candid rune
#

No idea what those words could mean and what a stripeCard could be

shadow stone
#

we get this from your documentation but here this is more clear for you

#

Payment _method => $token (generate from stripe card ) when create payment method using javascript

candid rune
#

none of those could be words from our docs. Like Payment _method isn't real code.

#

Anyways let's ignore this for a sec. How are you creating the PaymentMethod. Where does $token come from?

shadow stone
#

payment method is created from javascript with this following code

#

stripe.createPaymentMethod ({
type: 'card',
card: stripe_card,
billing_details: {
address
},
},
).then(function(result) {

                  if (result.error) {
                    $( document.body ).trigger( 'stripePaymentMethodError', result );
                    $('.stripe-source-errors').html(
                        '<ul class="woocommerce_error woocommerce-error eh-stripe-error"><li>'+ result.error.message +'</li></ul>');
                  } else {
#

$form.find( 'input.eh_stripe_pay_token' ).remove();
$form.find( 'input.eh_stripe_card_type' ).remove();
$form.find( 'input.eh_stripe_pay_currency' ).remove();

                    $form.append( '<input type="hidden" class="eh_stripe_pay_token" name="eh_stripe_pay_token" value="' + result.paymentMethod.id + '"/>' );
                    $form.append( '<input type="hidden" class="eh_stripe_pay_currency" name="eh_stripe_pay_currency" value="' + $data.data( 'currency' ) + '"/>' );
                    $form.append( '<input type="hidden" class="eh_stripe_pay_amount" name="eh_stripe_pay_amount" value="' + $data.data( 'amount' ) + '"/>' );
                    if(result.paymentMethod.type === "card")
                    {
                        $form.append( '<input type="hidden" class="eh_stripe_card_type" name="eh_stripe_card_type" value="' + result.paymentMethod.card.brand + '"/>' );
                    }
                    else
                    {
                        $form.append( '<input type="hidden" class="eh_stripe_card_type" name="eh_stripe_card_type" value="other"/>' );
                    }



                        eh_stripe_form.stripe_submit = true;
                        $form.submit();
                  }
                });
candid rune
#

Okay perfect we're getting there

shadow stone
#

great

candid rune
#

So the first bit is client-side code using Stripe.js right?

shadow stone
#

Yes

candid rune
#

Okay how are you initializing Stripe.js in that part of the code

shadow stone
#

jQuery( function( $ ) {
'use strict';

try {
var stripe = Stripe( eh_stripe_val.key, {apiVersion: eh_stripe_val.version} );
} catch( error ) {
console.log( error );
return;
}

var stripe_elements_options = Object.keys( eh_stripe_val.elements_options ).length ? eh_stripe_val.elements_options : {},
elements = stripe.elements( stripe_elements_options ),
stripe_card,
stripe_exp,
stripe_cvc;

candid rune
#

perfect

#

Okay so if you go back to your PHP code, you are creating the PaymentIntent on the connected account. You are passing stripe_account as an option in the second array right?

shadow stone
#

yes

candid rune
#

you see how all the objects like the PaymentIntent and the Charge live on the connected account?

shadow stone
#

yes

candid rune
#

So the problem is that the PaymentMethod pm_123 it also needs to live on the connected account for this to work. But your JS code created it on the platform. You never initialized Stripe.js with the info about about the connected account.

#

You basically need to make sure that both parts of your code (client and server) know where the payment is happening

shadow stone
#

Ok. Thank you very much for your time. I will review this and hope it fixes the issue. Thanks again

candid rune
#

Sure I'm around just try it and let me know, I'll keep the thread opened for a bit

shadow stone
#

ok thank you