diff --git a/stripe_plus_gateway/config.json b/stripe_plus_gateway/config.json index 4ebe568..c372960 100644 --- a/stripe_plus_gateway/config.json +++ b/stripe_plus_gateway/config.json @@ -1,5 +1,5 @@ { - "version": "1.0.4", + "version": "1.0.5", "name": "Stripe Plus", "description": "Forked version of the official Stripe gateway which includes updated offsite storage and ACH payments.", "authors": [ diff --git a/stripe_plus_gateway/stripe_plus_gateway.php b/stripe_plus_gateway/stripe_plus_gateway.php index a2dd9f8..57143b9 100644 --- a/stripe_plus_gateway/stripe_plus_gateway.php +++ b/stripe_plus_gateway/stripe_plus_gateway.php @@ -678,7 +678,7 @@ private function removeSource($client_reference_id, $account_reference_id) { $this->loadApi(); $result = false; $logUrl = "customers/" . $client_reference_id . "/sources/" . $account_reference_id; - $request = []; + $request = array(); try { $stripe_customer = $result = \Stripe\Customer::retrieve($client_reference_id); $source = $stripe_customer->sources->retrieve($account_reference_id); @@ -1022,12 +1022,15 @@ private function formatAmount($amount, $currency) { * @return string Statement description of invoice(s) */ private function createDescription($invoice_amounts) { - Loader::loadModels($this, array("Invoices")); + if(!isset($this->Invoices)) + Loader::loadModels($this, array("Invoices")); + $desc = ""; if (count($invoice_amounts) > 1) { $ids = array(); - foreach($invoice_amounts as $invoice) { - $ids[] = $this->Invoices->get($invoice['invoice_id'])->id_code; + foreach($invoice_amounts as $invoice) { + $invoice_data = $this->Invoices->get($invoice['invoice_id']); + $ids[] = $invoice_data ? $invoice_data->id_code : $invoice['invoice_id']; } $desc = "Invoices " . join(", ", $ids); if (strlen($desc) > 22) { @@ -1035,7 +1038,8 @@ private function createDescription($invoice_amounts) { } } elseif(count($invoice_amounts) === 1) { - $desc = "Invoice " . $this->Invoices->get($invoice_amounts[0]['invoice_id'])->id_code; + $invoice_data = $this->Invoices->get($invoice['invoice_id']); + $desc = "Invoice " . $invoice_data ? $invoice_data->id_code : $invoice['invoice_id']; if (strlen($desc) > 22) { $desc = "Invoice payment"; } @@ -1044,7 +1048,7 @@ private function createDescription($invoice_amounts) { } return $desc; } - + /** * Helper function to generate single name from parts *