@@ 108-127 (lines=20) @@ | ||
105 | * @return AbstractBankAccount |
|
106 | * @throws PartFireException |
|
107 | */ |
|
108 | public function get($userId, $bankAccountId) : AbstractBankAccount |
|
109 | { |
|
110 | try { |
|
111 | $bankAccount = $this->mangoPayApi->Users->GetBankAccount($userId, $bankAccountId); |
|
112 | if ($bankAccount instanceof BankAccount) { |
|
113 | if ($bankAccount->Type == 'IBAN') { |
|
114 | return $this->bankAccountTranslator->translateMangoToIbanDto($bankAccount); |
|
115 | } |
|
116 | return $this->bankAccountTranslator->translateMangoToGbDto($bankAccount); |
|
117 | } |
|
118 | $this->logger->addCritical("Bank account not deactivated when querying API."); |
|
119 | throw new PartFireException("Bank account not deactivated when querying API."); |
|
120 | } catch (ResponseException $e) { |
|
121 | $this->logger->addCritical($e->getMessage(), ['code' => $e->getCode(), 'details' => $e->GetErrorDetails()]); |
|
122 | throw new PartFireException($e->getMessage(), $e->getCode(), $e); |
|
123 | } catch (Exception $e) { |
|
124 | $this->logger->addError($e->getMessage()); |
|
125 | throw new PartFireException($e->getMessage(), $e->getCode(), $e); |
|
126 | } |
|
127 | } |
|
128 | ||
129 | public function getAll($userId) |
|
130 | { |
@@ 101-122 (lines=22) @@ | ||
98 | * |
|
99 | */ |
|
100 | ||
101 | public function get($id) |
|
102 | { |
|
103 | try { |
|
104 | $payIn = $this->mangoPayApi->PayIns->Get($id); |
|
105 | if ($payIn instanceof PayIn) { |
|
106 | if ($payIn->PaymentType == MangoPayConstants::PAY_IN_TYPE_BANK_WIRE) { |
|
107 | return $this->payInTranslator->translateMangoPayBankwireDirectPayInToDto($payIn); |
|
108 | } |
|
109 | if ($payIn->PaymentType == MangoPayConstants::PAY_IN_TYPE_CARD) { |
|
110 | return $this->payInTranslator->translateMangoPayDirectPayInToDto($payIn); |
|
111 | } |
|
112 | } |
|
113 | $this->logger->addCritical("Failed to get PayIn"); |
|
114 | throw new PartFireException("Failed to get PayIn"); |
|
115 | } catch (ResponseException $e) { |
|
116 | $this->logger->addCritical($e->getMessage(), ['code' => $e->getCode(), 'details' => $e->GetErrorDetails()]); |
|
117 | throw new PartFireException($e->getMessage(), $e->getCode(), $e); |
|
118 | } catch (Exception $e) { |
|
119 | $this->logger->addError($e->getMessage()); |
|
120 | throw new PartFireException($e->getMessage(), $e->getCode(), $e); |
|
121 | } |
|
122 | } |
|
123 | } |
|
124 |