|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Created by Carl Owens ([email protected]) |
|
4
|
|
|
* Company: PartFire Ltd (www.partfire.co.uk) |
|
5
|
|
|
* Copyright © 2017 PartFire Ltd. All rights reserved. |
|
6
|
|
|
* |
|
7
|
|
|
* User: Carl Owens |
|
8
|
|
|
* Date: 17/01/2017 |
|
9
|
|
|
* Time: 16:25 |
|
10
|
|
|
* File: Card.php |
|
11
|
|
|
**/ |
|
12
|
|
|
|
|
13
|
|
|
namespace PartFire\MangoPayBundle\Services; |
|
14
|
|
|
|
|
15
|
|
|
use PartFire\MangoPayBundle\Models\CardQueryInterface; |
|
16
|
|
|
use PartFire\MangoPayBundle\Models\CardRegistrationsQueryInterface; |
|
17
|
|
|
|
|
18
|
|
|
class Card |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* @var CardRegistrationsQueryInterface |
|
22
|
|
|
*/ |
|
23
|
|
|
private $cardRegistrationQuery; |
|
24
|
|
|
/** |
|
25
|
|
|
* @var CardQueryInterface |
|
26
|
|
|
*/ |
|
27
|
|
|
private $cardQuery; |
|
28
|
|
|
|
|
29
|
|
|
public function __construct(CardRegistrationsQueryInterface $cardRegistrationsQuery, CardQueryInterface $cardQuery) |
|
30
|
|
|
{ |
|
31
|
|
|
$this->cardRegistrationQuery = $cardRegistrationsQuery; |
|
32
|
|
|
$this->cardQuery = $cardQuery; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @param string $userId |
|
37
|
|
|
* @param string $currency |
|
38
|
|
|
* @param string $cardType |
|
39
|
|
|
* @param string $tag |
|
40
|
|
|
* @return null|\PartFire\MangoPayBundle\Models\DTOs\CardRegistration |
|
41
|
|
|
* Create a card registration |
|
42
|
|
|
*/ |
|
43
|
|
|
public function createRegistration(string $userId, string $currency, string $cardType, string $tag) |
|
44
|
|
|
{ |
|
45
|
|
|
return $this->cardRegistrationQuery->create($userId, $currency, $cardType, $tag); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @param $cardRegisteredId |
|
50
|
|
|
* update cardRegister after payment form |
|
51
|
|
|
* @param $registrationData |
|
52
|
|
|
* @return null|\PartFire\MangoPayBundle\Models\DTOs\CardRegistration |
|
53
|
|
|
*/ |
|
54
|
|
|
public function updateRegistration(string $cardRegisteredId, string $registrationData, string $errorCode) |
|
55
|
|
|
{ |
|
56
|
|
|
return $this->cardRegistrationQuery->update($cardRegisteredId, $registrationData, $errorCode); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @param string $cardRegisteredId |
|
61
|
|
|
* @return null|\PartFire\MangoPayBundle\Models\DTOs\CardRegistration |
|
62
|
|
|
*/ |
|
63
|
|
|
public function getRegistration(string $cardRegisteredId) |
|
64
|
|
|
{ |
|
65
|
|
|
return $this->cardRegistrationQuery->get($cardRegisteredId); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @param $cardId |
|
70
|
|
|
* @return null|\PartFire\MangoPayBundle\Models\DTOs\Card |
|
71
|
|
|
*/ |
|
72
|
|
|
public function get($cardId) |
|
73
|
|
|
{ |
|
74
|
|
|
return $this->cardQuery->get($cardId); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
public function getAll() |
|
78
|
|
|
{ |
|
79
|
|
|
|
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @param $cardId |
|
84
|
|
|
* @return null|\PartFire\MangoPayBundle\Models\DTOs\Card |
|
85
|
|
|
*/ |
|
86
|
|
|
public function deactivate($cardId) |
|
87
|
|
|
{ |
|
88
|
|
|
return $this->cardQuery->deactivate($cardId); |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
|