@@ 58-74 (lines=17) @@ | ||
55 | * @return null|Card |
|
56 | * @throws PartFireException |
|
57 | */ |
|
58 | public function get(string $cardId): Card |
|
59 | { |
|
60 | try { |
|
61 | $card = $this->mangoPayApi->Cards->Get($cardId); |
|
62 | if ($card instanceof mangoCard) { |
|
63 | return $this->cardTranslator->translateMangoCardToDto($card); |
|
64 | } |
|
65 | $this->logger->addCritical("Card ID: $cardId not found when querying API."); |
|
66 | throw new PartFireException("Card ID: $cardId not found when querying API."); |
|
67 | } catch (ResponseException $e) { |
|
68 | $this->logger->addCritical($e->getMessage(), ['code' => $e->getCode(), 'details' => $e->GetErrorDetails()]); |
|
69 | throw new PartFireException($e->getMessage(), $e->getCode(), $e); |
|
70 | } catch (Exception $e) { |
|
71 | $this->logger->addError($e->getMessage()); |
|
72 | throw new PartFireException($e->getMessage(), $e->getCode(), $e); |
|
73 | } |
|
74 | } |
|
75 | ||
76 | public function deactivate(string $cardId): Card |
|
77 | { |
@@ 46-63 (lines=18) @@ | ||
43 | $this->bankAccountTranslator = $bankAccountTranslator; |
|
44 | } |
|
45 | ||
46 | public function createIbanBankAccount(IbanBankAccount $ibanBankAccount): IbanBankAccount |
|
47 | { |
|
48 | try { |
|
49 | $bankAccount = $this->bankAccountTranslator->translateIbanDtoToMango($ibanBankAccount); |
|
50 | $bankAccount = $this->mangoPayApi->Users->CreateBankAccount($ibanBankAccount->getUserId(), $bankAccount); |
|
51 | if ($bankAccount instanceof BankAccount) { |
|
52 | return $this->bankAccountTranslator->translateMangoToIbanDto($bankAccount); |
|
53 | } |
|
54 | $this->logger->addCritical("Bank account not created when querying API."); |
|
55 | throw new PartFireException("Bank account not created when querying API."); |
|
56 | } catch (ResponseException $e) { |
|
57 | $this->logger->addCritical($e->getMessage(), ['code' => $e->getCode(), 'details' => $e->GetErrorDetails()]); |
|
58 | throw new PartFireException($e->getMessage(), $e->getCode(), $e); |
|
59 | } catch (Exception $e) { |
|
60 | $this->logger->addError($e->getMessage()); |
|
61 | throw new PartFireException($e->getMessage(), $e->getCode(), $e); |
|
62 | } |
|
63 | } |
|
64 | ||
65 | public function createGbBankAccount(GbBankAccount $gbBankAccount) : GbBankAccount |
|
66 | { |
|
@@ 65-82 (lines=18) @@ | ||
62 | } |
|
63 | } |
|
64 | ||
65 | public function createGbBankAccount(GbBankAccount $gbBankAccount) : GbBankAccount |
|
66 | { |
|
67 | try { |
|
68 | $bankAccount = $this->bankAccountTranslator->translateGbDtoToMango($gbBankAccount); |
|
69 | $bankAccount = $this->mangoPayApi->Users->CreateBankAccount($gbBankAccount->getUserId(), $bankAccount); |
|
70 | if ($bankAccount instanceof BankAccount) { |
|
71 | return $this->bankAccountTranslator->translateMangoToGbDto($bankAccount); |
|
72 | } |
|
73 | $this->logger->addCritical("Bank account not created when querying API."); |
|
74 | throw new PartFireException("Bank account not created when querying API."); |
|
75 | } catch (ResponseException $e) { |
|
76 | $this->logger->addCritical($e->getMessage(), ['code' => $e->getCode(), 'details' => $e->GetErrorDetails()]); |
|
77 | throw new PartFireException($e->getMessage(), $e->getCode(), $e); |
|
78 | } catch (Exception $e) { |
|
79 | $this->logger->addError($e->getMessage()); |
|
80 | throw new PartFireException($e->getMessage(), $e->getCode(), $e); |
|
81 | } |
|
82 | } |
|
83 | ||
84 | public function deactivate($userId, $bankAccountId) : bool |
|
85 | { |
|
@@ 84-100 (lines=17) @@ | ||
81 | } |
|
82 | } |
|
83 | ||
84 | public function deactivate($userId, $bankAccountId) : bool |
|
85 | { |
|
86 | try { |
|
87 | $bankAccount = $this->mangoPayApi->Users->UpdateBankAccount($userId, $bankAccountId); |
|
88 | if ($bankAccount instanceof BankAccount) { |
|
89 | return true; |
|
90 | } |
|
91 | $this->logger->addCritical("Bank account not deactivated when querying API."); |
|
92 | throw new PartFireException("Bank account not deactivated when querying API."); |
|
93 | } catch (ResponseException $e) { |
|
94 | $this->logger->addCritical($e->getMessage(), ['code' => $e->getCode(), 'details' => $e->GetErrorDetails()]); |
|
95 | throw new PartFireException($e->getMessage(), $e->getCode(), $e); |
|
96 | } catch (Exception $e) { |
|
97 | $this->logger->addError($e->getMessage()); |
|
98 | throw new PartFireException($e->getMessage(), $e->getCode(), $e); |
|
99 | } |
|
100 | } |
|
101 | ||
102 | /** |
|
103 | * @param $userId |
@@ 75-91 (lines=17) @@ | ||
72 | } |
|
73 | } |
|
74 | ||
75 | public function getBankWire(string $payOutId): PayOutBankWire |
|
76 | { |
|
77 | try { |
|
78 | $payout = $this->mangoPayApi->PayOuts->Get($payOutId); |
|
79 | if ($payout instanceof PayOut) { |
|
80 | return $this->payOutTranslator->translateMangoToPayOutDto($payout); |
|
81 | } |
|
82 | $this->logger->addCritical("could not get pay out when querying API."); |
|
83 | throw new PartFireException("could not get pay out when querying API."); |
|
84 | } catch (ResponseException $e) { |
|
85 | $this->logger->addCritical($e->getMessage(), ['code' => $e->getCode(), 'details' => $e->GetErrorDetails()]); |
|
86 | throw new PartFireException($e->getMessage(), $e->getCode(), $e); |
|
87 | } catch (Exception $e) { |
|
88 | $this->logger->addError($e->getMessage()); |
|
89 | throw new PartFireException($e->getMessage(), $e->getCode(), $e); |
|
90 | } |
|
91 | } |
|
92 | } |
|
93 |
@@ 103-119 (lines=17) @@ | ||
100 | } |
|
101 | } |
|
102 | ||
103 | public function get(string $cardRegisteredId): CardRegistrationDto |
|
104 | { |
|
105 | try { |
|
106 | $cardRegister = $this->mangoPayApi->CardRegistrations->Get($cardRegisteredId); |
|
107 | if ($cardRegister instanceof CardRegistration) { |
|
108 | return $this->cardTranslator->translateMangoCardRegistrationDataToDto($cardRegister); |
|
109 | } |
|
110 | $this->logger->addCritical("Card Registration ID: $cardRegisteredId not found when querying API."); |
|
111 | throw new PartFireException("Card Registration ID: $cardRegisteredId not found when querying API."); |
|
112 | } catch (ResponseException $e) { |
|
113 | $this->logger->addCritical($e->getMessage(), ['code' => $e->getCode(), 'details' => $e->GetErrorDetails()]); |
|
114 | throw new PartFireException($e->getMessage(), $e->getCode(), $e); |
|
115 | } catch (Exception $e) { |
|
116 | $this->logger->addError($e->getMessage()); |
|
117 | throw new PartFireException($e->getMessage(), $e->getCode(), $e); |
|
118 | } |
|
119 | } |
|
120 | } |
|
121 |
@@ 95-111 (lines=17) @@ | ||
92 | } |
|
93 | } |
|
94 | ||
95 | public function get($id) : BankwireDirectPayIn |
|
96 | { |
|
97 | try { |
|
98 | $payIn = $this->mangoPayApi->PayIns->Get($id); |
|
99 | if ($payIn instanceof PayIn) { |
|
100 | return $this->payInTranslator->translateMangoPayBankwireDirectPayInToDto($payIn); |
|
101 | } |
|
102 | $this->logger->addCritical("Failed to get PayIn"); |
|
103 | throw new PartFireException("Failed to get PayIn"); |
|
104 | } catch (ResponseException $e) { |
|
105 | $this->logger->addCritical($e->getMessage(), ['code' => $e->getCode(), 'details' => $e->GetErrorDetails()]); |
|
106 | throw new PartFireException($e->getMessage(), $e->getCode(), $e); |
|
107 | } catch (Exception $e) { |
|
108 | $this->logger->addError($e->getMessage()); |
|
109 | throw new PartFireException($e->getMessage(), $e->getCode(), $e); |
|
110 | } |
|
111 | } |
|
112 | } |
|
113 |