getCards() ?? [] as $card) { $meta = new \stdClass(); $meta->exp_month = $card->getExpMonth(); $meta->exp_year = $card->getExpYear(); $meta->last4 = $card->getLast4(); $meta->brand = $card->getCardBrand(); $meta->type = GatewayType::CREDIT_CARD; $cards[] = [ 'token' => $card->getId(), 'payment_meta' => $meta, 'payment_method_id' => GatewayType::CREDIT_CARD, 'gateway_customer_reference' => $customer->getId(), ]; } $address = $customer->getAddress(); return collect([ 'name' => $customer->getCompanyName() ?? ($customer->getGivenName() ?? '' ." " . $customer->getFamilyName() ?? ''), 'contacts' => [ [ 'first_name' => $customer->getGivenName(), 'last_name' => $customer->getFamilyName(), 'email' => $customer->getEmailAddress(), 'phone' => $customer->getPhoneNumber(), ] ], 'currency_id' => $company->settings->currency_id, 'address1' => $address->getAddressLine1(), 'address2' => $address->getAddressLine2(), 'city' => $address->getLocality(), 'state' => $address->getAdministrativeDistrictLevel1(), 'postal_code' => $address->getPostalCode(), 'country_id' => '840', 'settings' => [ 'currency_id' => $company->settings->currency_id, ], 'cards' => $cards, ]) ->toArray(); } }