|
@@ -29,10 +29,28 @@ class StripeHelper {
|
|
|
public function createOrUpdateCustomer(Location $location): Customer {
|
|
public function createOrUpdateCustomer(Location $location): Customer {
|
|
|
$customer = $location->getCustomer();
|
|
$customer = $location->getCustomer();
|
|
|
|
|
|
|
|
|
|
+ if($location->legal_entity_name) {
|
|
|
|
|
+ $name = sprintf("%s - %s (%s)", $customer->name, $location->name, $location->legal_entity_name);
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ $name = sprintf("%s - %s", $customer->name, $location->name);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
$data = [
|
|
$data = [
|
|
|
- "name" => $customer->name . " - " . $location->name,
|
|
|
|
|
|
|
+ "name" => $name,
|
|
|
"email" => $location->email,
|
|
"email" => $location->email,
|
|
|
"phone" => $location->phone,
|
|
"phone" => $location->phone,
|
|
|
|
|
+ "shipping" => array_filter([
|
|
|
|
|
+ "address" => array_filter([
|
|
|
|
|
+ "city" => $location->city,
|
|
|
|
|
+ "line1" => $location->address_1,
|
|
|
|
|
+ "line2" => $location->address_2,
|
|
|
|
|
+ "postal_code" => $location->postal_code,
|
|
|
|
|
+ "state" => $location->county,
|
|
|
|
|
+ ]),
|
|
|
|
|
+ "name" => $name,
|
|
|
|
|
+ "phone" => $location->phone,
|
|
|
|
|
+ ]),
|
|
|
"metadata" => [
|
|
"metadata" => [
|
|
|
"location_id" => $location->id,
|
|
"location_id" => $location->id,
|
|
|
]
|
|
]
|
|
@@ -59,12 +77,7 @@ class StripeHelper {
|
|
|
*/
|
|
*/
|
|
|
public function createInvoice(Test $test, string $price): Invoice {
|
|
public function createInvoice(Test $test, string $price): Invoice {
|
|
|
$location = $test->getLocation();
|
|
$location = $test->getLocation();
|
|
|
- if($location->stripe_customer_id) {
|
|
|
|
|
- $customer = $this->client->customers->retrieve($location->stripe_customer_id);
|
|
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
- $customer = $this->createOrUpdateCustomer($location);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ $customer = $this->createOrUpdateCustomer($location);
|
|
|
|
|
|
|
|
if($test->stripe_invoice_id) {
|
|
if($test->stripe_invoice_id) {
|
|
|
return $this->client->invoices->retrieve($test->stripe_invoice_id);
|
|
return $this->client->invoices->retrieve($test->stripe_invoice_id);
|