#Sarvesh
1 messages · Page 1 of 1 (latest)
I have few queries with connected account direct charges apis
$paymentIntent = PaymentIntent::create([
'payment_method_types' => ['card'],
'payment_method' => 'pm_card_bypassPending',
'amount' => 700, //$eventRegData->total_amount,
'currency' => 'usd',
'application_fee_amount' => 123, //$eventRegData->platform_fee,
'transfer_group' => 'directCharges1',
'confirm' => true,
], ['stripe_account' => $hostData->stripe_id]);
in paymentIntent response which fields I need to check to update payment status is done?
or I will receive webhook notification?
You can refer to the the status of PaymentIntent object: https://stripe.com/docs/api/payment_intents/object#payment_intent_object-status
Here are the status lifecycle of a PaymentIntent: https://stripe.com/docs/payments/intents
In additional, Stripe will also send payment_intent.* events your Webhook to inform you the outcome: https://stripe.com/docs/payments/payment-intents/verifying-status#webhooks
ok, but if i not subscribed to webhook then also from the paymentIntent response I will check few fieldset and update the payment status right?
or webhook is needed?
I should rely on paymentIntent response or webhook response?
We recommend to subscribe to webhook events as well in case
- if your request is not able to get response, you can still get outcome via webhook
- if the asynchronous payment method is used and the payment outcome will be posted via webhook
You can refer to the webhook integration doc here: https://stripe.com/docs/webhooks/quickstart
Yes, this is similar. This code is an example for your reference.
ok
how i can build form to get card / bank details from user ?
and then split payment and call paymentintent api?"
how i can build form to get card / bank details from user ?
You can refer to the doc here: https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements
and then split payment and call paymentintent api?"
Can you explain more on what you want to achieve?
yes, goal is something like,
when user register for the event, we want to show the form to fill up card / bank details on our site and we will post it to API. We do not want to redirect user to Stripe page to fillup card/bank details and pay from there. So what could be the solution for this case
You can PaymentIntent API in your server and Payment Element embedded in your frontend to collect card/bank details. The integration steps are described here: https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements
ok great, can we get that form HTML/JS to accept credit/debit card or US Bank accounts only?
"stripe/stripe-php": "^9.4", we alredy installed via composer
Hi! I'm taking over this thread.
You can see all payment methods that Stripe support here: https://stripe.com/docs/payments/payment-methods/overview
Hi Soma
Yes this is fine. I am asking that is there a customize form to download available with all needed payment menthod fields like credit/debit card fieldset, bank account field set etc?
with their proper inputs validations Javascript?
If you are using the Payment Element, this is built in by default.
- Create the PaymentIntent on the backend and set the payment method you want
- Then on the frontend the Payment Element will automatically display the correct UI with all the required fields
i see, good, let me check this
I recommend reading this page to better understand how the Payment Element works: https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements
ok
$stripe->paymentIntents->create(
[
'amount' => 1099,
'currency' => 'usd',
'automatic_payment_methods' => ['enabled' => true],
]
);
So 'automatic_payment_methods' => ['enabled' => true], will generate a form above shown?
'automatic_payment_methods' => ['enabled' => true] means that all payment method activated in your dashboard will be shown in the Payment Element form.
Payment Element form how to create?
client secret used in JS and will be visible in page view source will not security problem
?
No issue, that's our recommended implementation:
- Create the PaymentIntent on the backend
- Send the client_secret to the frontend
- The use the client_secret to mount the Payment Element
ok
suppose I need to pay amount
$12.5 for event registration charges to connected event host account and internally with payment intent we will split website charges 1.5 to main stripe account then How I need to send these amounts to payment intent object?
12.5 x100? = 1250?
1.5 x100 = 150?
So you want to charge the customer $12.5, and then you want the platform account to keep $1.5?
yes
The the amount to charge is 12.5 * 100 = 1250. Then to send money to the connected account, you have to decide how you want to do it. You have three options that are explained here: https://stripe.com/docs/connect/charges
ok so for each amount we need to multiply by 100 before sending to api request right?
for most currencies (like EUR, USD, etc.) yes. But there are some exceptions: https://stripe.com/docs/currencies#zero-decimal
ok we will only receive US dollars only as customer base from USA only
Then yes it's just $amount x 100.
ok thanks
Now I will try to build the payment elements form as per above documentation
next question is regarding the webhook response from payment intent transactions, which fields we need to look to decide whethere payment success/fail/ any errors etc.
Here are the webhook events you can receive: https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements#web-post-payment
And the PaymentIntent has a status field: https://stripe.com/docs/api/payment_intents/object#payment_intent_object-status
ok, good
what are the Stripe payment processing charges for payment intents?
We need to include that amount in our event registration fee so that it will be taken from the customers
I hope it must be some %% on the event fee
You can learn more about our pricing here: https://stripe.com/pricing
And if you want to know the exact Stripe fee for a specific PaymentIntent:
- On the PaymentIntent there is a
chargeobject: https://stripe.com/docs/api/payment_intents/object#payment_intent_object-charges-data - The charge object contains a
balance_transactionobject https://stripe.com/docs/api/charges/object#charge_object-balance_transaction - And the balance transaction contains a
feeandfee_detailshttps://stripe.com/docs/api/balance_transactions/object#balance_transaction_object-fee
You can see an example of this here: https://stripe.com/docs/expand/use-cases#stripe-fee-for-payment
So from first link
3% for cards issued outside India
So can we save this 3% as stripe processing fee in our project setting and our event fee say $10 then calculate 10*3%=0.03
so total amount to pay $10.03 for end customers?
including stripe fee
If you create a PaymentIntent for $10, the customer will pay exactly $10 and the Stripe fee is included in this, so you business will get ~$9.70
If you want your business to get exactly $10, then yes you would need to increase your price a little.
But note that the Stripe fee can change depending on the type of card, on the payment method used.
ok
Stripe fee can change depending on the type of card, on the payment method used.
where it is mentioned?
👋 taking over for my colleague. Let me catch up.
if you need specific charge fees you can visiting https://stripe.com/pricing or contact https://support.stripe.com/?contact=true for more info
View Stripe fees and pricing information. Explore pricing by product, by payment method including credit and debit cards, or design a custom pricing package.
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
if you want to add the Stripe fees to your charge you can take a look at this guide https://support.stripe.com/questions/passing-the-stripe-fee-on-to-customers
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
ok
let me know if you need any more help
yes
The Payment Element contains an iframe that securely sends the payment information to Stripe over an HTTPS connection. The checkout page address must also start with https:// rather than http:// for your integration to work.
So this will shows a form and get submitted to Stripe without API call?
yes true
but what will heppen after form is posted? user will stay on same site or redirect to Stripe?
if you're using PaymentElement on your site, redirection will only happen when an action (e.g. 3DS) is needed and you can specify where to redirect after success
ok I have this object created
$paymentIntent = PaymentIntent::create([
'payment_method_types' => ['card'],
'payment_method' => 'pm_card_bypassPending',
'amount' => 700, //$eventRegData->total_amount,
'currency' => 'usd',
'application_fee_amount' => 123, //$eventRegData->platform_fee,
'transfer_group' => 'directCharges1',
'confirm' => true,
], ['stripe_account' => $hostData->stripe_id]);
So If I want to take card details from user then I need to add
automatic_payment_methods' => ['enabled' => true], ??
ok, I am still not understood correctly following scenario
- on our payment info page we will show payment summary e.g.
Event fee: $10
Platform (website) charges: $0.5
Stripe charges : 0.5
Total to Pay: $11
and below of this we want to show the a form on our website (maybe without Iframe from stripe) to select the payment methods (Card or Bank Transfer)
and based on select the form fields will change and user will fill the card details or bank account details and on Submit we will call our function to set the
amount => 1000
'application_fee_amount' => 50
stripe_account' => $hostData->stripe_id
and send API requests
and we should get the response back from request and also from the webhook subscribed to update the payment status in our database
so in above case, we want to use HTML / JS form elements based on payment method selected by user instead of creating our own form
is this possible? can we get readymade form code ?
just give me a minute to read through
sure
and below of this we want to show the a form on our website (maybe without Iframe from stripe) to select the payment methods (Card or Bank Transfer)
if you don't want to use Stripe Elements you would have to worry about being PCI compliance and about how to create the Payment Methods yourself, that's a big hassle that I don't really recommend you doing
ok, so you suggest to use I frame with form elements ?
but in that case how we can attach the payment intentent split payment to main and connected accounts?
that has nothing to do with the frontend code
or https://stripe.com/docs/connect/direct-charges
or https://stripe.com/docs/connect/charges-transfers
depending on your scenario
yes but this Creating direct charges I need to create object first with all split payment and then ask user to fill up the payment form inside the iframe which we get submitted to stripe?
how strip will know which amount to pay to which accounts ?
a Direct Charge is for doing one payment with just your platform and a connected account (the connected account gets most of the money, and you take e.g. a 10% amount for yourself). It doesn't involve multiple accounts.
yes, do not need multiple accounts in our case, only 2 main account (to get some %) and connected account with major amount
whole picture is not getting cleared with iframe integration how I can call the api? to split some amount to main account and connected account
or is thre a way to create direct charges object and redirect user to Stripe to fill the card/bank details on stripe page and then you will send it back to us success/error info?
?
sounds good
not sure what you mean by 'iframe' here.
Anyway, the guides are here:
https://stripe.com/docs/connect/enable-payment-acceptance-guide — complete guide for the full flow
https://stripe.com/docs/connect/charges-transfers
yes, since you can use our Checkout hosted payment page to do a Direct Charge. It's one of the options explained and documented in https://stripe.com/docs/connect/enable-payment-acceptance-guide
ok checking the last url
https://stripe.com/docs/connect/enable-payment-acceptance-guide?platform=web&ui=checkout#create-checkout-session
This is the correct workflow as explained in the diagram, we want to implement
The checkout.html
<html>
<head>
<title>Checkout</title>
</head>
<body>
<form action="/create-checkout-session" method="POST">
HOW FORM ELEMENTS SHOW HERE BASED ON CARD/BANK SELECTED BY END USER
<button type="submit">Pay</button>
</form>
</body>
</html>
HOW FORM ELEMENTS SHOW HERE BASED ON CARD/BANK SELECTED BY END USER in checkout.html?
not sure what you mean
you're talking about Checkout, which is a hosted Stripe page.
on your own site, you simply have a button
the user clicks the button, and they are redirected to Stripe, and that's where they enter their payment information, and then are redirected back to you.
https://checkout.stripe.dev/ shows you some of examples of what the flow looks like.
ok got it now
but the object we created
$paymentIntent = PaymentIntent::create([
'payment_method_types' => ['card'],
'payment_method' => 'pm_card_bypassPending',
'amount' => 700, //$eventRegData->total_amount,
'currency' => 'usd',
'application_fee_amount' => 123, //$eventRegData->platform_fee,
'transfer_group' => 'directCharges1',
'confirm' => true,
'automatic_payment_methods' => ['enabled' => true],
], ['stripe_account' => $hostData->stripe_id]);
when to post it to Stripe? with above checkout form post or when?
that code is not using Checkout so it's something entirely different.
how stripe will know the how much application fee amount to transfer to other account?
can we do a quick call? its long time we are dicussing on this flow
so first you have to decide which flow you're going to use, the hosted Checkout page, or your own page.
you told us, it's in your API call. In that code you posted, you told us to transfer 123 ($1.23) to your platform.
yes, but along with that I need to update the object with user inputs card / bank details right? so that you will charge money from that card/bank account
so that I want to show a form with card / bank input fields and on form post we will send all details together to API
its not checkout, custom api calls we need to do
then why did you say this?
nd redirect user to Stripe to fill the card/bank details on stripe page and then you will send it back to us success/error info?
are you sure you "need" to do custom API calls? do you have a specific reason for not using Checkout? Do you understand the difference and extra dev work in building your own payment form directly?
anyway, please read the guide and let me know specific questions you have. If you're not using Checkout, you want the "Payment Element" tab (https://stripe.com/docs/connect/enable-payment-acceptance-guide?platform=web&ui=payment-element) and it clearly explains how it works and how and where the customer enters payment details. Please read it first and then let me know what's unclear.
$intent = # ... Fetch or create the PaymentIntent;
what is mean by Fetch or create the PaymentIntent;?
<?php
$intent = # ... Fetch or create the PaymentIntent;
?>
...
<form id="payment-form" data-secret="<?= $intent->client_secret ?>">
<div id="payment-element">
<!-- Elements will create form elements here -->
</div>
<button id="submit">Submit</button>
</form>
...
it means, in the previous step you wrote code to create a PaymentIntent
so now in this step, you want to set $intent to be that PaymentIntent object you created
is that clear?
yes, going with this direction
@tight violet any further questions or can I close this thread for now?
what is in the console logs tab, any errors?
no errors
share the exact code you're using
Stripe::setApiKey(config('services.stripe.stripeSecret'));
$paymentIntent = PaymentIntent::create([
'payment_method_types' => ['card'],
'payment_method' => 'pm_card_bypassPending',
'amount' => 700, //$eventRegData->total_amount,
'currency' => 'usd',
'application_fee_amount' => 123, //$eventRegData->platform_fee,
'transfer_group' => 'directCharges1',
'confirm' => true,
//'automatic_payment_methods' => ['enabled' => true],
], ['stripe_account' => 'acct_1LxWk2PBvk5urIAm']);
<form id="payment-form" data-secret="<?= $paymentIntent->client_secret ?>">
<div id="payment-element">
<!-- Elements will create form elements here -->
</div>
<button id="submit">Submit</button>
</form>
where is your Javascript?
did you actually write the frontend code that create the Stripe Element?
<script src="https://js.stripe.com/v3/"></script>
this i need to include?
you need to include that, and write a bunch of your own code, yes....
ok
<script src="https://js.stripe.com/v3/"></script>
<script>
const stripe = Stripe('pk_test_51LcWQoALTlZ8nxc3GJK8QkvCP3La9KU8BHrcFljOTyJpWFMnzP9l9JAwelvy6IvdmdOddsZx4YzENuYnsQTRLO6200mbv2lMGT', {
stripeAccount: 'acct_1LxWk2PBvk5urIAm'
});
//const stripe = Stripe('pk_test_51LcWQoALTlZ8nxc3GJK8QkvCP3La9KU8BHrcFljOTyJpWFMnzP9l9JAwelvy6IvdmdOddsZx4YzENuYnsQTRLO6200mbv2lMGT');
const options = {
clientSecret: 'sk_test_51LcWQoALTlZ8nxc3bpx4OjMu2WedesCask1c8que7gMVZBml4A9RAo6TXimQdFcU5LJuyZzlbJzRBwiDudItKqkR00ZpMKJISz',
// Fully customizable with the Appearance API
appearance: {/.../},
};
// Set up Stripe.js and Elements to use in checkout form using the client secret
const elements = stripe.elements(options);
// Create and mount the Payment Element
const paymentElement = elements.create("payment");
paymentElement.mount("#payment-element");
</script>
This is provided in JS and your JS is also included and loaded properly before the JS code
still form elements are not visible.
got 1 error in console
Invalid value for elements(): clientSecret should be a client secret of the form ${id}secret${secret}. You specified: sk_test_51LcWQoALTlZ8nxc3bpx4OjMu2WedesCask1c8que7gMVZBml4A9RAo6TXimQdFcU5LJuyZzlbJzRBwiDudItKqkR00ZpMKJISz.
now shown the form
after fixed above error
is there any css to load for form?
Hey! Taking over for my colleague. Let me catch up.
what will be the next step?
Can I set form action="my-custom-action" and call stripe api or this form will get directly posted to Stripe and return response to Return URL specified?
Sorry for my late reply
For Stripe Payment Element no. It's charged with
No you can attach the action yeah and submit the payment once the customer enters their card details
ok
payment_intent_unexpected_state
The PaymentIntent’s state was incompatible with the operation you were trying to perform.
getting this error now
type: 'invalid_request_error', code: 'payment_intent_unexpected_state',
Can you share the ID (req_xxx) of the failing API request?
https://support.stripe.com/questions/finding-the-id-for-an-api-request
However, IÂ may invite to to complete a separate sample project that accept Card Payment aside, then try working on your target project. You can follow/download this full Quickstart and try to understand each step:
https://stripe.com/docs/payments/quickstart?lang=node
transation is not failing, on stripe it is showing Succeeded pi_3Lxs0BPBvk5urIAm0h5mUD1c
in console it is getting error
You need to create new PaymentIntent for each customer purchase
Tha PaymentIntent is already confirmed and succeeded. You need to pass a client_secret of new PaymentIntent to make a new attempt
ok, and I can send the my eventId and user id along with request which I can get back in return response in success / fail case so that I can update that record in database?
also in above screenshot I can not see the Card / Bank details boxes to switch? I need to enabled bank account from my dashboard so it will get visible on top o form?
Hi there 👋 I'm jumping in as my teammate needs to step away soon.
Correct, as you enable more payment method options, the Payment Element will begin including those.
I'm not sure I'm understanding the question here, would you mind trying to rephrase it?
$paymentIntent = PaymentIntent::create([
//'payment_method_types' => ['card'],
'payment_method' => 'pm_card_bypassPending',
'amount' => 800, //$eventRegData->total_amount,
'currency' => 'usd',
'application_fee_amount' => 244, //$eventRegData->platform_fee,
'transfer_group' => 'directCharges1',
'confirm' => true,
'automatic_payment_methods' => ['enabled' => true],
'return_url' => 'http://localhost:8000/athlete/payment',
], ['stripe_account' => 'acct_1LxWk2PBvk5urIAm']);
I can send the eventId and use id along with request which I can get back in return response in success / fail case so that I can update that record in database?
That request won't give you an Event ID, Events are the objects that Stripe sends to your endpoints if you set up a webhook endpoint.
https://stripe.com/docs/api/events
I'm also not sure what you're referring to by user ID, do you mean the ID of the Customer object?
The request that you're showing will return a Payment Intent, and that Payment Intent will have an ID that you can use to reference it later.
https://stripe.com/docs/api/payment_intents/object#payment_intent_object-id
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
no I am not talking about that event
Can I send some custom fields with the paymentIntegent request to Stripe? e.g loggedin userid on our website, and productId or eventId he is going to pay for
so that I will get those custom fields back in the response to track the response or webhook and update the data in our database
Yes, that functionality is available via our metadata field:
https://stripe.com/docs/api/metadata
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
ok