#stephy
1 messages · Page 1 of 1 (latest)
Sure, could you elaborate?
For doing ach payment i integrate some api in my website but got some error
Payment method of typ US Bank account must be verified before attached to customer like
$name = 'Telgy';
$routingNumber = '110000000';
$accountNumber = '000123456789';
Stripe::setApiKey(config('services.stripe.secret'));
$customer = Customer::create(array(
"name" => 'telgy',
));
//Create a bank account token
$bankAccountToken = Token::create([
'bank_account' => [
'country' => 'US',
'currency' => 'usd',
'routing_number' => '110000000',
'account_number' => '000123456789',
'account_holder_name' => 'John Doe',
'account_holder_type' => 'individual',
],
]);
$paymentMethod = PaymentMethod::create([
'type' => 'us_bank_account',
'billing_details' => [
'name' => $name,
'email' => 'telgy1@gmail.com',
],
'us_bank_account' => [
'routing_number' => $routingNumber,
'account_number' => $accountNumber,
'account_holder_type' => 'individual',
],
]);
$paymentMethod->attach([
'customer' => $customer->id,
]);
$charge = \Stripe\PaymentIntent::create([
'payment_method_types' => ['us_bank_account'],
'payment_method' => $paymentMethod->id,
'amount' => '1000',
'currency' => 'usd',
'confirm' => true,
]);
this is my code
Can you find the errored request id instead? from https://dashboard.stripe.com/test/logs
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
req_QvNfGQqjRNCKdZ
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
The error is quite self-explanatory isn't it? PaymentMethods of type us_bank_account must be verified before they can be attached to a customer
So this is ACH and you can't just create it on backend and use it. It needs verification
that means could you explain me more??? beacuse we are from india and here ach payment is not supporting and am doing the secction for a us client..so before give them code i need to test this so how would do this? how can i identify any errors in my code?\
is the code that am providing is correct tp debit the amount from the customers bank account?
Okie so you would want to follow an ACH doc for Accept a Payment https://stripe.com/docs/payments/ach-debit/accept-a-payment?platform=web
There are 2 path: Checkout or Direct API
In the Doc you would see how to create PaymentIntent and confirm it on the client. That's where it would be verified
If you are looking for saving the ACH payment method first before creating PaymentIntent, then https://stripe.com/docs/payments/ach-debit/set-up-payment
if am integrating in in my website Checkout or Direct API which is better option?
Checkout is easier and recommended. It's a Stripe-hosted page so you only need to perform a redirection
Direct API is when you want to embed the Stripe components into your website, instead of redirection
Checkout is easier and recommended. It's a Stripe-hosted page so you only need to perform a redirection i use this one but got a empty page
to do this one first i gave
\Stripe\Stripe::setApiKey('sk_test_51MrJC7ANNm2HMGMowvLJoLwddIuNRcJphGo0gkxnJACfZHscnyu8VZ2UlL5KcsJQnOPqHGsbe9HVYeU6pNe8WPvz00oGrDWr83');
$customer = \Stripe\Customer::create();
// Set your secret key. Remember to switch to your live secret key in production.
// See your keys here: https://dashboard.stripe.com/apikeys
$stripe = new \Stripe\StripeClient('sk_test_51MrJC7ANNm2HMGMowvLJoLwddIuNRcJphGo0gkxnJACfZHscnyu8VZ2UlL5KcsJQnOPqHGsbe9HVYeU6pNe8WPvz00oGrDWr83');
$stripe->checkout->sessions->create([
'mode' => 'payment',
'customer' => '{{CUSTOMER_ID}}',
'payment_method_types' => ['card', 'us_bank_account'],
'payment_method_options' => [
'us_bank_account' => [
'financial_connections' => ['permissions' => ['payment_method']],
],
],
'line_items' => [
[
'price_data' => [
'currency' => 'usd',
'unit_amount' => 2000,
'product_data' => ['name' => 'T-shirt'],
],
'quantity' => 1,
],
],
'success_url' => 'https://example.com/success',
'cancel_url' => 'https://example.com/cancel',
]);
but empty page is shown no form or anything will showed?
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Please redact the secret key sk_test_xxx. This is a public forum
Have you setup a HTML form and submit it will trigger this method? Have you called redirection?
no how to set up that ? i only see the two api in doc ..
Please do this first. It's important
Similar to steps in here, please take as reference!
but instead of this i want to debit money from bank account not via card
this section not understand...did you mean that not mention secret key in code?
No, don’t let the secret key visible here, in this Discord chat
And for the Card Doc, I meant only refer to how to create a form and a redirection there
ok sorry for that
ok...so there is question .... the ach means we pulling the amount from customers bank account right? so they should enter their bank account details in form ..but in our api there is no section to take that bank account details to verify and pull the amount?
The Checkout Session will automatically does it for you. It has the amount which will deduct from customer bank
ok that means when am creating a form there i should add account number and routing number filed and when submit that time call the checkout api only?
now i create a form
<form action="{{url('/charge')}}" method="post" id="payment-form">
@csrf
<div id="payment-method-container"></div>
<div class="form-group">
<label for="amount">Amount</label>
<input type="text" id="amount" name="amount" class="form-control">
</div>
<div class="form-group">
<label for="description">Description</label>
<input type="text" id="description" name="description" class="form-control">
</div>
<div class="form-group">
<label for="ach_name">Name</label>
<input type="text" id="ach_name" name="ach_name" class="form-control">
</div>
<div class="form-group">
<label for="ach_routing_number">Routing Number</label>
<input type="text" id="ach_routing_number" name="ach_routing_number" class="form-control">
</div>
<div class="form-group">
<label for="ach_account_number">Account Number</label>
<input type="text" id="ach_account_number" name="ach_account_number" class="form-control">
</div>
<button type="submit">Submit Payment</button>
</form>
after that
$customer = \Stripe\Customer::create();
$stripe->checkout->sessions->create([
'mode' => 'payment',
'customer' => $customer->id,
'payment_method_types' => ['card', 'us_bank_account'],
'payment_method_options' => [
'us_bank_account' => [
'financial_connections' => ['permissions' => ['payment_method']],
],
],
'line_items' => [
[
'price_data' => [
'currency' => 'usd',
'unit_amount' => 2000,
'product_data' => ['name' => 'T-shirt'],
],
'quantity' => 1,
],
],
'success_url' => 'https://example.com/success',
'cancel_url' => 'https://example.com/cancel',
]);
I call these two sections in backend
No the amount you should decide on backend (you wouldn't want to let your customer decide how much they pay) and all routing number or account number will be collected by Checkout, so not needed
Essentially you basically need an empty form with a submit button. On backend you create a redirect the CheckoutSession upon button submited
yes i done that..i redirect to this checkout session but no form or anything displayed...if i miss anything??
Can you share its URL?
No I meant the Checkout URL
not understand
now i create a form with button and after click that button it should be redirect to the backend code where i write
$customer = \Stripe\Customer::create();
$stripe->checkout->sessions->create([
'mode' => 'payment',
'customer' => $customer->id,
'payment_method_types' => ['card', 'us_bank_account'],
'payment_method_options' => [
'us_bank_account' => [
'financial_connections' => ['permissions' => ['payment_method']],
],
],
'line_items' => [
[
'price_data' => [
'currency' => 'usd',
'unit_amount' => 2000,
'product_data' => ['name' => 'T-shirt'],
],
'quantity' => 1,
],
],
'success_url' => 'https://example.com/success',
'cancel_url' => 'https://example.com/cancel',
]);
code only
Okie, then how do you redirect to this Checkout Session url?
header("HTTP/1.1 303 See Other");
header("Location: " . $checkout_session->url);
for PHP, ie.
here card shows to me
but i want to enter bank details
this works me
but my payament status is pending why?
You may need to use the Test information here https://stripe.com/docs/payments/ach-debit/accept-a-payment?platform=web&ui=checkout#test-integration
ok its success...thanks so ..i think we can direct debit amount from customers account to admin stripe account using this method right?
Yep
ok if i wanted to do ach_credit_tranfer then how?
$session= $stripe->checkout->sessions->create([
'mode' => 'payment',
'customer' => $customer->id,
'payment_method_types' => ['card', 'us_bank_account'],
'payment_method_options' => [
'us_bank_account' => [
'financial_connections' => ['permissions' => ['payment_method']],
],
],
'line_items' => [
[
'price_data' => [
'currency' => 'usd',
'unit_amount' => 2000,
'product_data' => ['name' => 'T-shirt'],
],
'quantity' => 1,
],
],
here i not want quantity but when i removes it shows error? so is it required one?
Re: quantity yes it is required.
Re: ACH Credit Transfer that's a totally different payment method and it use Source - a legacy API. I wouldn't recommend it but here is the Doc https://stripe.com/docs/sources/ach-credit-transfer
you said , not recommend one ..why? if any issue to integrate this?
because Source is a legacy API. No issue right now but down in the road we may release a newer integration and it will cost time to switch