#Verox

1 messages ยท Page 1 of 1 (latest)

oblique siloBOT
compact linden
#

Hi! Let me help you with this.

#

Could you please share the exact error?

bleak ledge
#

Code: ```php
$request->user()->invoiceFor('"' . $validated['name'] . '" Server', $price);


Error:
``"The payment attempt failed because of an invalid payment method."``
#

The customer should be able to pick a currency the first time and pick a payment method from the enabled ones everytime he pays an invoice.

compact linden
#

Sorry, I don't follow. Where does the error come from?

bleak ledge
#

From invoicing a customer with Laravel Cashier:

$request->user()->invoiceFor('"' . $validated['name'] . '" Server', $price);
compact linden
#

Okay, we don't officially support that, so you will have to contact the developer to solve this.

bleak ledge
#

I'm pretty sure Stripe wants the customer to have a default payment method he can be charged with, but I just want the customer to be able to pay via mail with every enabled payment method..

bleak ledge
compact linden
#

I understand, but I don't know how ->invoiceFor method works under the hood so I don't know exactly why the error pops up. The developer will be able to solve this.

bleak ledge
#

Yes, that's why I wrote you. I want to know how to do it manually with the Laravel Stripe SDK.

compact linden
#

But I don't know how Laravel Cashier works. That's why you need to contact Laravel Cashier developer.

bleak ledge
#

The main problem is that I don't want the customer to set a payment method before. He should be able to pay with every payment method that's available.

Here is the code for Native Stripe PHP:

// Create an Invoice
        $invoice = Invoice::create([
            'customer' => $request->user()->stripe_id,
            'collection_method' => 'send_invoice',
            'days_until_due' => 7,
        ]);

        // Create an Invoice Item with the Price, and Customer you want to charge
        $invoiceItem = InvoiceItem::create([
            'customer' => $request->user()->stripe_id,
            'price' => $price,
            'invoice' => $invoice->id
        ]);

$invoice->send();
#

I'll get the error: "Nothing to invoice for the customer"

compact linden
#

You need to finalize the invoice before sending it.

hasty tundra
#

Hi there ๐Ÿ‘‹ jumping in as my teammate needs to step away soon.

bleak ledge
hasty tundra
bleak ledge
#

And even if I finalize the invoice, the error still occurs.

hasty tundra
# bleak ledge From ``$invoice->send()``

Is this a Laravel Cashier function? We are not familiar with how that Stripe integration is expected to work or how to implement it, Cashier was built by Laravel and you will need to work with them for getting assistance on it.

We can help answer questions about our APIs and libraries, but we won't be able to offer insight on third-party libraries.

hasty tundra
bleak ledge
#

Yes, because I'm using the static approach obviously.

bleak ledge
hasty tundra
#

Can you share the ID of a request where you saw that error being returned?

bleak ledge
#

in_1N9SXhBxo62JExo2Xx2woL9I

hasty tundra
#

That looks like the ID of an Invoice, using it I found this request that seems to return the error you indicated, but it has a user agent matching that of the Laravel Cashier library rather than appearing to come directly from our PHP library:
https://dashboard.stripe.com/test/logs/req_uf2vC1gbQgOv5w

bleak ledge
#

Ah, thanks. I think I found the error. It is mostly the unthinkable: Switched from Production to Test mode, where the customer doesn't exist.

#

No, actually not. The customer id should be correct.

hasty tundra
#

That error indicates that there are no pending Invoice Items associated with the Customer, so there is nothing to be pulled into the Invoice you're trying to create.

bleak ledge
hasty tundra
#

No, that is a request to create an Invoice. Creating Invoice Items use a separate set of endpoints/functions.

bleak ledge
#

Ah, now it works, but I get this error:
"The payment attempt failed because of an invalid payment method."

bleak ledge
hasty tundra
#

Cannot charge a customer that has no active card
https://dashboard.stripe.com/logs/req_MIk5Jyp0b0Ruz1

Is this the request you're referring to? It's being made to the endpoint to trigger the payment for an Invoice. What are you expecting/hoping to happen here if you don't want to automatically charge an existing Payment Method?

bleak ledge
hasty tundra
bleak ledge
hasty tundra
#

Any time!