#ryan-connect-direct
1 messages · Page 1 of 1 (latest)
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
HI
@shadow stone I deleted all your messages
Sorry I am here. I was putting too much in the main chat sorry
all good
@candid rune
please read what I said above, this server is for developers, you don't seem to be the developer
do you need me to post again?
No I think you need to go to our support team for help, or get your developer to ask questions here
My developer cannot connect. he has been waiting for 4 hours for verification emaio
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.
no I am sorry I won't debug through you, this will never work
Please work with our support team directly for help instead: https://support.stripe.com/contact
ok how can I get him here. he is not getting email verificaiton
I don't know sorry.
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
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
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.
@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
Here is the error message
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)
yes I will get it
deleted the image again since there's a real email in it
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
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
Client side. Payment method is from credit card token generate
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
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
we create payment method using credit debit card token
what does that mean? Can you share the exact relevant code?
we wrote a whole plugin I cannot share that but let me get the snippet that refers to exactly that.
All I want is the 5 or 10 lines of code that are relevant really.
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
));
That's a PAymentIntent creation. What are you passing in that $payment_intent_args?
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(),
);
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?
No idea what those words could mean and what a stripeCard could be
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
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?
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();
}
});
Okay perfect we're getting there
great
So the first bit is client-side code using Stripe.js right?
Yes
Okay how are you initializing Stripe.js in that part of the code
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;
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?
yes
Look at the new diagram https://stripe.com/docs/connect/direct-charges#flow-of-funds-with-fees
you see how all the objects like the PaymentIntent and the Charge live on the connected account?
yes
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.
What you want to do is what is here: https://stripe.com/docs/connect/authentication?client=create-client-js#adding-the-connected-account-id-to-a-client-side-application
You basically need to make sure that both parts of your code (client and server) know where the payment is happening
Ok. Thank you very much for your time. I will review this and hope it fixes the issue. Thanks again
Sure I'm around just try it and let me know, I'll keep the thread opened for a bit
ok thank you