|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace GoCardlessPayment\Models\Traits; |
|
4
|
|
|
|
|
5
|
|
|
trait AsGoCardlessCustomer |
|
6
|
|
|
{ |
|
7
|
1 |
|
public function getSyncKey(): ?string |
|
8
|
|
|
{ |
|
9
|
1 |
|
return (string) $this->getKey(); |
|
|
|
|
|
|
10
|
|
|
} |
|
11
|
|
|
|
|
12
|
3 |
|
public function gocardlessKeyName(): string |
|
13
|
|
|
{ |
|
14
|
3 |
|
return config('gocardless-payment.local_customer_repositories.eloquent.key'); |
|
15
|
|
|
} |
|
16
|
|
|
|
|
17
|
3 |
|
public function gocardlessKey(): ?string |
|
18
|
|
|
{ |
|
19
|
3 |
|
return $this->{$this->gocardlessKeyName()}; |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
public function hasGocardlessId(): bool |
|
23
|
|
|
{ |
|
24
|
|
|
return ! is_null($this->gocardlessKey()); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
1 |
|
public function gocardlessGivenName(): ?string |
|
28
|
|
|
{ |
|
29
|
1 |
|
return $this->first_name ?? null; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
1 |
|
public function gocardlessFamilyName(): ?string |
|
33
|
|
|
{ |
|
34
|
1 |
|
return $this->last_name ?? null; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
1 |
|
public function gocardlessEmail(): ?string |
|
38
|
|
|
{ |
|
39
|
1 |
|
return $this->email ?? null; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
1 |
|
public function gocardlessPostalCode(): ?string |
|
43
|
|
|
{ |
|
44
|
1 |
|
return $this->postalcode ?? null; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
1 |
|
public function gocardlessAddressLine1(): ?string |
|
48
|
|
|
{ |
|
49
|
1 |
|
return $this->address_line_1 ?? null; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
1 |
|
public function gocardlessAddressLine2(): ?string |
|
53
|
|
|
{ |
|
54
|
1 |
|
return $this->address_line_2 ?? null; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
1 |
|
public function gocardlessAddressLine3(): ?string |
|
58
|
|
|
{ |
|
59
|
1 |
|
return $this->address_line_3 ?? null; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
1 |
|
public function gocardlessCity(): ?string |
|
63
|
|
|
{ |
|
64
|
1 |
|
return $this->city ?? null; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
1 |
|
public function gocardlessRegion(): ?string |
|
68
|
|
|
{ |
|
69
|
1 |
|
return $this->region ?? null; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
1 |
|
public function gocardlessCountryCode(): ?string |
|
73
|
|
|
{ |
|
74
|
1 |
|
return $this->country_code ?? null; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
2 |
|
public function setGocardlessKey(string $key): static |
|
78
|
|
|
{ |
|
79
|
2 |
|
$this->fill([ |
|
|
|
|
|
|
80
|
2 |
|
$this->gocardlessKeyName() => $key, |
|
81
|
2 |
|
]); |
|
82
|
|
|
|
|
83
|
2 |
|
$this->save(); |
|
|
|
|
|
|
84
|
|
|
|
|
85
|
2 |
|
return $this; |
|
86
|
|
|
} |
|
87
|
|
|
} |
|
88
|
|
|
|