#iloveapplepie - Stripe.js Error

1 messages · Page 1 of 1 (latest)

small roost
#

Hello! Can you share the code you're using?

#

Here's how to format code in Discord:

Inline code
Wrap your inline code in backticks (`).

For example, if you type this:

This sentence has `code()` in it.

It will be formatted like this:

This sentence has code() in it.

Code blocks

  1. Start with three backticks (```) followed by an optional language identifer, like ```js or ```php
  2. Type several lines of code (while inside a code block you can hit return without sending the message)
  3. End the code block with three more backticks (```)

For example, if you type this:

```js
function example() {
var foo = bar();
}
```

It will be formatted like this:

function example() {
  var foo = bar();
}
strong ledge
#

stripe.confirmCardPayment(
'<?=$payment_intent->client_secret?>',
{
payment_method: {card: cardElement},
}
).then(function(result) {
if (result.error) {
// Display error.message in your UI.
} else {
// The payment has succeeded
// Display a success message
}

small roost
#

Can you share the code you're using to create and mount the Card Element?

strong ledge
#

i dont have any. I am just creating the payment intent in php, and then passing the secret

#

thats it.

small roost
#

If you don't have a Card Element why are you referencing cardElement in the code? Can you provide more details about what you're trying to build?

strong ledge
#

just copy -pasted some code from the documentation. I thought might be part of the library

small roost
#

Are you trying to create a payment form that takes card information from a customer?

strong ledge
#

yes

small roost
strong ledge
#

i want to create the intent and then that the clients gets the stripe window with the product information and they type the credit card

#

so this is something different to payment intents? I thought that Stripe mention that we should use payment intents from now on.

small roost
#

That guide uses Payment Intents.

strong ledge
#

The link shows something called Slim. Never seen that

small roost
#

That's a PHP framework. If you're not using Slim you can handle the backend parts yourself without it, but you'll need to write different code.

strong ledge
#

ok. I will take a look. Thank you

small roost
#

Hang on...

strong ledge
#

ok

small roost
#

Do you want to use Checkout or the Payment Element?

#

In other words, do you want to direct people to a Stripe-hosted Checkout page (easier and recommended) or do you want to create your own custom payment page (harder, but you have more control).

strong ledge
#

Stripe-Hosted

#

this is the thing. My current code , that is in production does a session create and then does a stripe.redirectToCheckout

#

All I wanted to do was modify the code to use connected accounts

#

then the rabbit hole started because , apparently, I needed to change my code to use payment intents

#

and the redirectToCheckout does not work with payment intents

small roost
#

Hold on, I don't think you need to make that many changes. Can you tell me more about your connected accounts and how you want them to work with Checkout?

strong ledge
#

I sell stuff myself, but I want to add the ability for other to use my platform as a marketplace

#

when that happens, I was going to get a fee and let the vendor with a standard account charge directly

#

thats when I went to the direct charge documentation

#

that says to use payment intentents

small roost
#

What type of connected accounts do you have? Standard? Express?

strong ledge
#

Standard

#

I want the connected account to pay all the stripe fees, all I get is my application fee

#

in those cases

small roost
strong ledge
#

i am checking

#

the first link you sent me is to create connected account through the api. I am doing those manually on the dash board

#

so I can get the account id from the database

small roost
#

the first link you sent me is to create connected account through the api.

No, it's not. It's about how to make API requests on your connected accounts.

#

Please give that link a full read through.

strong ledge
#

ohh so you are saying to use the connected account secret key instead of mine?

#

ok I will

small roost
#

ohh so you are saying to use the connected account secret key instead of mine?

No, you should use your platform's secret key combined with the connected account ID you want to make the request on. Full details are in the link above. 🙂

strong ledge
#

i am going to read everything again

#

thank you

small roost
#

Happy to help!

strong ledge
#

are you still here?

bright sequoia
#

👋 I can help!

strong ledge
#

what is supposed to happen after calling the payment intent?

#

how do I go from there, to the stripe hosted screen so that the user can enter a credit card payment

#

the documentation on that page does not say anything

bright sequoia
#

Let me summarize some things to see if that'll clear it up

#

With Checkout you wouldnt be creating a separate paymetn intent or anything, you'd create the Checkout Session with the Stripe-Account header (so it's created on the Connect Account) and you'd set payment_intent_data[application_fee_amount] if you want to collect a fee (https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-payment_intent_data-application_fee_amount). Once the Checkout Session has been created, you'd redirect to the URL where they can complete payment. Once payment is completed we'll automatically transfer the fee to the platform

strong ledge
#

when I specify the application fee, do I also need to use on_behalf_of? to specify the connected account?

#

where in the session I specify the connected account?

bright sequoia
strong ledge
#

so you are saying is NOT in the session (php code) but in the javascript?

#

var stripe = Stripe('{{PLATFORM_PUBLISHABLE_KEY}}', {
stripeAccount: '{{CONNECTED_STRIPE_ACCOUNT_ID}}',
});

bright sequoia
#

You want it in your server-side call when you create the Session

strong ledge
#

so it happens when I create the customer? is creating customer mandatory?

bright sequoia
#

Creating a customer is not mandatory when using Checkout - you only need it if you want to use an already existing customer for a Checkout Session

strong ledge
#

i dont want to do that. Is not important for wha I am doing

bright sequoia
strong ledge
#

you keep mention that i specify the connected account on the header, but I dont see any php call to do that on the documentation. Only on the javscript code when creating the Stripe Object

bright sequoia
#

Again, that link is just to show how you set the header. You'd take the ["stripe_account" => "{{CONNECTED_STRIPE_ACCOUNT_ID}}"] line of code and use it when you create the Checkout Session

strong ledge
#

Received unknown parameter: payment_intent_data[stripe_account] thrown in

bright sequoia
#

What does your code look like?

strong ledge
#

"payment_intent_data" => [
'application_fee_amount' => 10*100,
'stripe_account'=>'XXXX',

bright sequoia
#

You want to pull ["stripe_account" => "{{CONNECTED_STRIPE_ACCOUNT_ID}}"] out of payment_intent_data. It's completely separate

strong ledge
#

ok, now I got the checkout screen, and try to process the payment, but got an error. I am checking on the logs

#

all i did was add the stripe_acctoun to the end

bright sequoia
#

How are you redirecting to Checkout?

strong ledge
#

i actually got the window, and enter the credit card

#

i got the fee on my account

#

i see the charge on the connected account

#

all that worked

#

, now , why did it send me back

#

weird

#

i will check my php code after the payment

#

because it seems that it did everything correctly on the dash board

#

thank you

bright sequoia
#

happy to help!

strong ledge
#

still there?

hollow nacelle
#

I'm around

#

hello

strong ledge
#

ok, i am getting an error that I never seen before , ever

#

everything seem s to work but when stripe calls my success_url

#

goes here

#

catch (\Stripe\Exception\InvalidRequestException $e) {
// Invalid parameters were supplied to Stripe's API
echo $e->getMessage();
die;
STCRequest::redirect($_SESSION['CART_GOBACK_URL'] . '&alertcode=E_CARD_INVALID_REQUEST');

}
#

Invalid checkout.session id:

#

so , it does not like the session id that I am getting even afters everything is processed correctly on stripes(charges and fees

#

i can see the payment on the connected

#

any ideas?

hollow nacelle
#

what is the request ID of the failing request

strong ledge
#

hold on

#

you mean the payment id?

#

or the invalid session id?

#

the one that starts with cs_test_

hollow nacelle
#

there should be a request ID to /v1/checkout/sessions that failed

strong ledge
#

excuse my ignorance, but where can i go to find that number? on the dashboard

#

?

hollow nacelle
strong ledge
#

req_DtjNI63DctdlOT

#

how can i session be invalid but still process by Stripe?

hollow nacelle
#

the CheckoutSession is valid, except not for the API key you are requesting it from

you're making the request as the Platform account, you need to make a "Connect request" (I believe you and karbi were talking about this earlier? )

#

you have it correct on CheckoutSession creation

strong ledge
#

thats what Iam doing. I added the stripe_account on the session create call

hollow nacelle
#

yeah I'm saying something else

strong ledge
#

also I aded the stripe account on the javascript

hollow nacelle
#

you do have it right on Creation

#

not on Retrieval

strong ledge
#

I notice that if I dont put it on the javscript , it does not work

hollow nacelle
#

you're not reading my answer

strong ledge
#

ohhhhhhh

hollow nacelle
#

I gave you the right answer I think you missed it

#

1/ you create Checkout correctly!
2/ you redirect to Checkout also correctly!
3/ you retrieve Checkout (after it is completed) incorrectly

#

so part 3 is what you need to fix

#

@strong ledge lets talk here

#

your messages were still in main channel haha I know by accident

#

@strong ledge tagging you so you get the notification in this thead

strong ledge
#

am i back?

#

how can i add the account to the retrive?

#

@hollow nacelle i am back

#

how can i add the connected account to the retrieve?

hollow nacelle
#

the same way you did for create

strong ledge
#

is not there

#

IT WORKED

hollow nacelle
#

you just pass the stripe_account param

strong ledge
#

thank you

hollow nacelle
#

yay

#

great

strong ledge
#

just added at the end, like in the create

#

Thank you

#

finally

#

thank you

#

take care