_config = $config; } public function send_ach_invoice_sale_order($customer_real_name, $customer_email, $customer_phone, $total, $days_until_due) { $stripe_secret_key = $this->_config->item('stripe_secret_key'); Stripe::setApiKey( $stripe_secret_key ); try { $customer = Customer::create([ 'name' => $customer_real_name, 'email' => $customer_email, 'description' => $customer_phone, ]); $amount = $total * 100; try { $invoice_item = InvoiceItem::create([ 'amount' => $amount, 'currency' => 'usd', 'customer' => $customer->id, 'description' => 'Sale Order Invoice' ]); if ($invoice_item) { try { // pulls in invoice items $invoice_detail = Invoice::create(array( 'customer' => $customer->id, 'collection_method' => 'send_invoice', 'days_until_due' => $days_until_due, )); try { $output['invoice_id'] = $invoice_detail->id; return $output; // Invoice::sendInvoice(array($invoice_detail->id)); } catch (Exception $e) { $output['error'] = $e; return $output; } // # status (error: 0, success: 1) // echo json_encode(['status' => 1]); // exit(); } catch (Exception $e) { $output['error'] = $e; return $output; } } else { $output['error'] = $e; return $output; } } catch (Exception $e) { $output['error'] = $e; return $output; } } catch (Exception $e) { $output['error'] = $e; return $output; } } } ?>