-
Notifications
You must be signed in to change notification settings - Fork 1
/
payment_processor_debit_liskov.h
40 lines (33 loc) · 1.18 KB
/
payment_processor_debit_liskov.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//
// Created by bender on 16/11/2021.
//
#ifndef SOLID_PRINCIPLES_INCLUDE_PAYMENT_PROCESSOR_DEBIT_LISKOV_H_
#define SOLID_PRINCIPLES_INCLUDE_PAYMENT_PROCESSOR_DEBIT_LISKOV_H_
#include "payment_processor_abstract_liskov.h"
#include "spdlog/spdlog.h"
#include "trouble.h"
struct PaymentProcessorDebitLiskov final : public PaymentProcessorAbstractLiskov {
explicit PaymentProcessorDebitLiskov(NewOrder &new_order, std::string_view security_code)
: new_order_{new_order}
, security_code_{security_code} {}
void AuthSMS(std::string_view sms_code) override {
spdlog::info("Verifying SMS code {0}", sms_code);
verified_ = true;
}
void Pay() const override {
if (!verified_) {
throw Trouble{"Not authorised"};
}
spdlog::info("Processing debit payment type");
spdlog::info("Verifying security code: {0}", security_code_);
new_order_.SetStatus(Status::Paid);
}
void DisplayInfo() const override {
spdlog::info("Debit payment processor for order {0}", to_string(new_order_.GetId()));
}
private:
NewOrder &new_order_;
std::string_view security_code_;
bool verified_{false};
};
#endif//SOLID_PRINCIPLES_INCLUDE_PAYMENT_PROCESSOR_DEBIT_LISKOV_H_