Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

yafeearun's avatar

Stripe invoice always placed as a draft

Hi

i tried to take payment instantly but the invoice always saved as a draft. and when i'm hiding the following condition

if($this->defaultCard()->chargeable){

payment made successfully but this condition inside library file vendor/laravel/cashier/src/Billable.php

here i add the entire function and i tried in test mode

public function invoice(array $options = [])
{
    
    if ($this->stripe_id) {
        
        $parameters = array_merge($options, ['customer' => $this->stripe_id]);

        try {
            // echo ($this->defaultCard()->chargeable) ? 'chargeable' : 'non chargeable';
            // print_r($this->defaultCard());die();
            $invoice = StripeInvoice::create($parameters, $this->getStripeKey());
            if($this->defaultCard()->chargeable){
                $invoice->pay();
            }
                // print_r($invoice);exit();
            return $invoice;         
        } catch (StripeErrorInvalidRequest $e) {
            // dd($e);
            return false;
        }
    }
    return true;
}

my stripe charge function

$account->invoiceFor($this->invoice->description, ($amount * 100), [
                //'quantity' => 50,
                //'unit_amount' => 50,
            ], [
                'tax_percent' => $this->invoice->tax_percentage,
                'billing' => 'charge_automatically',
                // 'billing' => 'send_invoice',
                // 'days_until_due' => today()->diffInDays($this->invoice->due_date),
                'auto_advance' => true,
            ]);

have to enable any option in stripe for default card ??

guys kindly help me to solve this

0 likes
0 replies

Please or to participate in this conversation.