#iloveapplepie - Stripe.js Error
1 messages · Page 1 of 1 (latest)
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
- Start with three backticks (```) followed by an optional language identifer, like ```js or ```php
- Type several lines of code (while inside a code block you can hit
returnwithout sending the message) - 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();
}
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
}
Can you share the code you're using to create and mount the Card Element?
i dont have any. I am just creating the payment intent in php, and then passing the secret
thats it.
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?
just copy -pasted some code from the documentation. I thought might be part of the library
Are you trying to create a payment form that takes card information from a customer?
yes
I recommend you follow the guide here instead: https://stripe.com/docs/payments/accept-a-payment
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.
That guide uses Payment Intents.
The link shows something called Slim. Never seen that
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.
ok. I will take a look. Thank you
Hang on...
ok
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).
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
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?
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
What type of connected accounts do you have? Standard? Express?
Standard
I want the connected account to pay all the stripe fees, all I get is my application fee
in those cases
You can create the Checkout Session on the connected account: https://stripe.com/docs/connect/authentication
When you create the Checkout Session you can set the application fee your platform will get: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-payment_intent_data-application_fee_amount
And, optionally to make things easier, you can send people to the url on the Checkout Session instead of using Stripe.js and stripe.redirectToCheckout: https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-url
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
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.
ohh so you are saying to use the connected account secret key instead of mine?
ok I will
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. 🙂
Happy to help!
are you still here?
👋 I can help!
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
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
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
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?
No you do not need to use on_behalf_of - you're using Direct Charges so you'd specify the Connect accuont by setting the Stripe-Account header (Rubeus linked you to https://stripe.com/docs/connect/authentication which shows how to set that header)
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}}',
});
You want it in your server-side call when you create the Session
so it happens when I create the customer? is creating customer mandatory?
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
i dont want to do that. Is not important for wha I am doing
To be clear - the https://stripe.com/docs/connect/authentication#stripe-account-header link was only to show you how to use the Stripe-Account header. It's just creating a Customer to demonstrate how to use it and it's not needed for Checkout
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
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
Received unknown parameter: payment_intent_data[stripe_account] thrown in
What does your code look like?
"payment_intent_data" => [
'application_fee_amount' => 10*100,
'stripe_account'=>'XXXX',
You want to pull ["stripe_account" => "{{CONNECTED_STRIPE_ACCOUNT_ID}}"] out of payment_intent_data. It's completely separate
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
How are you redirecting to Checkout?
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
happy to help!
still there?
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?
what is the request ID of the failing request
hold on
you mean the payment id?
or the invalid session id?
the one that starts with cs_test_
there should be a request ID to /v1/checkout/sessions that failed
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 need this change Karbi mentioned except also when you retrieve your CheckoutSession: #916059653425741854 message
you have it correct on CheckoutSession creation
thats what Iam doing. I added the stripe_account on the session create call
yeah I'm saying something else
also I aded the stripe account on the javascript
I notice that if I dont put it on the javscript , it does not work
you're not reading my answer
ohhhhhhh
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
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?
the same way you did for create
when I check here https://stripe.com/docs/api/checkout/sessions/retrieve
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
is not there
IT WORKED
you just pass the stripe_account param
thank you