Fixes for vendor imports

This commit is contained in:
David Bomba 2023-02-05 08:59:20 +11:00
parent cbf8735d23
commit 21e995be82
3 changed files with 10 additions and 13 deletions

View File

@ -52,17 +52,6 @@ class VendorTransformer extends BaseTransformer
'custom_value2' => $this->getString($data, 'vendor.custom_value2'), 'custom_value2' => $this->getString($data, 'vendor.custom_value2'),
'custom_value3' => $this->getString($data, 'vendor.custom_value3'), 'custom_value3' => $this->getString($data, 'vendor.custom_value3'),
'custom_value4' => $this->getString($data, 'vendor.custom_value4'), 'custom_value4' => $this->getString($data, 'vendor.custom_value4'),
// 'vendor_contacts' => [
// [
// 'first_name' => $this->getString(
// $data,
// 'vendor.first_name'
// ),
// 'last_name' => $this->getString($data, 'vendor.last_name'),
// 'email' => $this->getString($data, 'vendor.email'),
// 'phone' => $this->getString($data, 'vendor.phone'),
// ],
// ],
'contacts' => [ 'contacts' => [
[ [
'first_name' => $this->getString( 'first_name' => $this->getString(
@ -70,7 +59,7 @@ class VendorTransformer extends BaseTransformer
'contact.first_name' 'contact.first_name'
), ),
'last_name' => $this->getString($data, 'contact.last_name'), 'last_name' => $this->getString($data, 'contact.last_name'),
'email' => $this->getString($data, 'contact.email'), 'email' => strlen($this->getString($data, 'contact.email')) > 1 ? $this->getString($data, 'contact.email') : $this->getString($data, 'vendor.email'),
'phone' => $this->getString($data, 'contact.phone'), 'phone' => $this->getString($data, 'contact.phone'),
'custom_value1' => $this->getString( 'custom_value1' => $this->getString(
$data, $data,

View File

@ -13,6 +13,8 @@ namespace App\Listeners\Subscription;
use App\Libraries\MultiDB; use App\Libraries\MultiDB;
use App\Models\Account; use App\Models\Account;
use App\Models\Company;
use App\Notifications\Ninja\RenewalFailureNotification;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
use Imdhemy\Purchases\Events\AppStore\DidRenew; use Imdhemy\Purchases\Events\AppStore\DidRenew;
@ -44,6 +46,12 @@ class AppStoreRenewSubscription implements ShouldQueue
$account = Account::where('inapp_transaction_id', $inapp_transaction_id)->first(); $account = Account::where('inapp_transaction_id', $inapp_transaction_id)->first();
if(!$account) {
$ninja_company = Company::on('db-ninja-01')->find(config('ninja.ninja_default_company_id'));
$ninja_company->notification(new RenewalFailureNotification("{$inapp_transaction_id}"))->ninja();
return;
}
if($account->plan_term == 'month') if($account->plan_term == 'month')
$account->plan_expires = now()->addMonth(); $account->plan_expires = now()->addMonth();
elseif($account->plan_term == 'year') elseif($account->plan_term == 'year')

View File

@ -68,7 +68,7 @@ class RenewalFailureNotification extends Notification
public function toSlack($notifiable) public function toSlack($notifiable)
{ {
$content = "Plan paid, account not updated\n"; $content = "Plan paid, account not updated\n";
$content .= "Contact: {$this->notification_message}"; $content .= "Contact/Inapp Purchase: {$this->notification_message}";
return (new SlackMessage) return (new SlackMessage)
->success() ->success()