Add Address to braintree create customer

This commit is contained in:
David Bomba 2021-09-30 11:42:27 +10:00
parent f615b7801d
commit c718c6d19b
3 changed files with 45 additions and 1 deletions

View File

@ -132,7 +132,6 @@ class SendRecurring implements ShouldQueue
});
if ($invoice->client->getSetting('auto_bill_date') == 'on_send_date' && $invoice->auto_bill_enabled) {
nlog("attempting to autobill {$invoice->number}");
$invoice->service()->autoBill()->save();

View File

@ -119,6 +119,15 @@ class BraintreePaymentDriver extends BaseDriver
]);
if ($result->success) {
$address = $this->gateway->address()->create([
'customerId' => $result->customer->id,
'firstName' => $this->client->present()->name,
'streetAddress' => $this->client->address1,
'postalCode' => $this->client->postal_code,
'countryCodeAlpha2' => $this->client->country ? $this->client->country->iso_3166_2 : '',
]);
return $result->customer;
}
}

View File

@ -1,5 +1,9 @@
<?php
use App\DataMapper\ClientRegistrationFields;
use App\Models\Company;
use App\Models\Currency;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
@ -13,9 +17,41 @@ class AddRequiredClientRegistrationFields extends Migration
*/
public function up()
{
Schema::table('companies', function (Blueprint $table) {
$table->mediumText('client_registration_fields')->nullable();
});
Company::all()->each(function ($company){
$company->update(['client_registration_fields' => ClientRegistrationFields::generate()]);
});
Model::unguard();
$currencies = [
['id' => 111, 'name' => 'Cuban Peso','code' => 'CUP', 'symbol' => '₱', 'precision' => '2','thousand_separator' => ',','decimal_separator' => '.'],
];
foreach ($currencies as $currency) {
$record = Currency::whereCode($currency['code'])->first();
if ($record) {
$record->name = $currency['name'];
$record->symbol = $currency['symbol'];
$record->precision = $currency['precision'];
$record->thousand_separator = $currency['thousand_separator'];
$record->decimal_separator = $currency['decimal_separator'];
if (isset($currency['swap_currency_symbol'])) {
$record->swap_currency_symbol = $currency['swap_currency_symbol'];
}
$record->save();
} else {
Currency::create($currency);
}
}
}
/**