Conditions | 4 |
Paths | 3 |
Total Lines | 23 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 4.4661 |
Changes | 0 |
1 | <?php |
||
11 | 2 | public function handle(): void |
|
12 | { |
||
13 | 2 | $metadataKeyName = GoCardlessPayment::$syncMetadataKeyName; |
|
14 | |||
15 | 2 | $gocardlessCustomerId = $this->event->links?->customer; |
|
16 | 2 | $syncKey = $this->event->metadata?->$metadataKeyName; |
|
17 | |||
18 | 2 | if (! $gocardlessCustomerId || ! $syncKey) { |
|
19 | Log::debug("BillingRequestCreatedHandlerJob event object not contains required references to customer or {$metadataKeyName}"); |
||
20 | |||
21 | return; |
||
22 | } |
||
23 | |||
24 | 2 | $localCustomer = GoCardlessPayment::localCustomerRepository()->findLocalCustomerBySyncKey($syncKey); |
|
25 | 2 | if (! $localCustomer) { |
|
26 | Log::debug("Local customer not found to attach key [{$metadataKeyName}:{$syncKey}]"); |
||
27 | |||
28 | return; |
||
29 | } |
||
30 | |||
31 | 2 | $localCustomer->setGocardlessKey($gocardlessCustomerId); |
|
32 | |||
33 | 2 | GoCardlessWebhookEventHandled::dispatch($this->event, $localCustomer); |
|
34 | } |
||
36 |