def __init__(self, data=None):
     if not data:
         return
     super(BankPayment, self).__init__(data)
     bank = Bank()
     bank.bank_account_id = int(data.get("bank_account_id", None))
     self.bank = bank
Example #2
0
 def __init__(self, data=None):
     if not data:
         return
     super(PaymentByBank, self).__init__(data)
     bank = Bank()
     bank.bank_account_id = int(data["bank_account_id"])
     self.bank = bank
    def test_is_successful(self):
        bank = Bank()
        bank.status = "processed"
        payment = Payment()
        payment.source = "bank"
        payment.bank = bank

        self.assertTrue(payment.is_successful())
 def __init__(self, data=None):
     if not data:
         return
     super(BankPayment, self).__init__(data)
     bank = Bank()
     bank.bank_account_id = int(data["bank_account_id"])
     total_amount = Decimal(data["amount"])
     if self.amount < total_amount and self.amount > 1:
         bank.status = 'processed'
     else:
         bank.status = 'failed'
Example #5
0
    def test_is_successful(self):
        card = Card()
        card.status = "processed"
        payment1 = Payment()
        payment1.card = card

        bank = Bank()
        bank.status = "processed"
        payment2 = Payment()
        payment2.bank = bank

        self.assertTrue(payment1.is_successful())
        self.assertTrue(payment2.is_successful())
Example #6
0
    def test_bank_is_successful(self):
        bank = Bank()
        payment = Payment()
        payment.source = "bank"
        payment.bank = bank

        self.assertTrue(payment.is_successful())
Example #7
0
    def process_trx(self, data):
        self.customer_id = int(data.get("customer_id"))
        self.date = parse(data["date"])
        total_amount = Decimal(data["amount"])
        self.fee = total_amount * PAYMENT_FEE_RATE
        self.amount = total_amount - self.fee

        if "bank_account_id" in data:
            id_key = "bank_account_id"
            bank = Bank()
            bank.bank_account_id = int(data[id_key])
            bank.status = 'success'
            self.bank = bank
        elif "card_id" in data:
            id_key = "card_id"
            card = Card()
            card.card_id = int(data.get(id_key))
            card.status = data["card_status"]
            self.card = card
Example #8
0
    def __init__(self, data=None, source="card"):

        if not data:
            return

        self.customer_id = int(data["customer_id"])
        self.date = parse(data["date"])

        total_amount = Decimal(data["amount"])
        self.fee = total_amount * PAYMENT_FEE_RATE
        self.amount = total_amount - self.fee

        if (source == "card"):
            card = Card()
            card.card_id = int(data["card_id"])
            card.status = data["card_status"]
            self.card = card
        elif (source == "bank"):
            bank = Bank()
            bank.bank_account_id = data["bank_account_id"]
            bank.status = "processed"
            self.bank = bank
Example #9
0
    def __init__(self, data=None):

        if not data:
            return

        self.customer_id = int(data["customer_id"])
        self.date = parse(data["date"])

        total_amount = Decimal(data["amount"])
        self.fee = total_amount * PAYMENT_FEE_RATE
        self.amount = total_amount - self.fee

        if data.get("source") == "bank":
            bank = Bank()
            bank.bank_account_id = int(data["bank_account_id"])
            bank.status = data["bank_status"]
            self.bank = bank
            self.source = "bank"
        else:
            self.source = "card"
            card = Card()
            card.card_id = int(data["card_id"])
            card.status = data["card_status"]
            self.card = card
Example #10
0
    def __init__(self, data=None):

        if not data:
            return

        self.customer_id = int(data["customer_id"])
        self.date = parse(data["date"])

        total_amount = Decimal(data["amount"])
        self.fee = total_amount * PAYMENT_FEE_RATE
        self.amount = total_amount - self.fee

        card_id = data.get("card_id" or None)
        bank_acc_id = data.get("bank_account_id" or None)

        if card_id is not None:
            card = Card()
            card.card_id = int(card_id)
            card.status = data["card_status"]
            self.card = card
        elif bank_acc_id is not None:
            bank = Bank()
            bank.bank_account_id = int(bank_acc_id)
            self.bank = bank
Example #11
0
 def setUp(self):
     self.payment_mode = BankPayment()
     self.bank = Bank()