#stephy

1 messages · Page 1 of 1 (latest)

odd vaporBOT
fervent raft
#

Sure, could you elaborate?

cold condor
#

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

quartz perch
#

$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

fervent raft
quartz perch
#

req_QvNfGQqjRNCKdZ

fervent raft
#

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

quartz perch
#

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?

fervent raft
#

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

quartz perch
#

if am integrating in in my website Checkout or Direct API which is better option?

fervent raft
#

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

quartz perch
#

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?

fervent raft
#

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?

quartz perch
#

no how to set up that ? i only see the two api in doc ..

fervent raft
fervent raft
quartz perch
#

but instead of this i want to debit money from bank account not via card

quartz perch
fervent raft
#

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

quartz perch
#

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?

fervent raft
#

The Checkout Session will automatically does it for you. It has the amount which will deduct from customer bank

quartz perch
#

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

fervent raft
#

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

quartz perch
#

yes i done that..i redirect to this checkout session but no form or anything displayed...if i miss anything??

fervent raft
#

Can you share its URL?

fervent raft
#

No I meant the Checkout URL

quartz perch
#

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

fervent raft
#

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.

fervent raft
quartz perch
#

ok its success...thanks so ..i think we can direct debit amount from customers account to admin stripe account using this method right?

fervent raft
#

Yep

quartz perch
#

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?

fervent raft
#

Re: quantity yes it is required.

quartz perch
#

you said , not recommend one ..why? if any issue to integrate this?

fervent raft
#

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