示例#1
0
	def save_payload(self, data, payloads):
		new_payment = Payment()
		new_payment.transaction_id = data['transaction_id']
		new_payment.order_id = data['order_id']
		new_payment.gross_amount = data['gross_amount']
		new_payment.payment_type = data['payment_type']
		new_payment.transaction_time = data['transaction_time']
		new_payment.transaction_status = data['transaction_status']
		new_payment.bank = data['bank']
		new_payment.fraud_status = data['fraud_status'] if 'fraud_status' in data else None
		new_payment.masked_card = payloads['masked_card'] if 'masked_card' in payloads else None
		new_payment.saved_token_id = payloads['saved_token_id'] if 'saved_token_id' in payloads else None
		new_payment.va_number = data['va_number'] if 'va_number' in data else None

		db.session.add(new_payment)
		db.session.commit()
示例#2
0
    def run():
        """
        Create 4 Payments seeds
        """

        transaction_statuses = ['capture', 'authorize', 'deny']
        statuses = ['accept', 'challenge', 'deny']
        payment_types = ['bank_transfer', 'credit_card']
        banks = ['bri', 'bni', 'permata', 'maybank', 'mandiri', 'bca', 'cimb']
        range_start = 10**(7 - 1)
        range_end = (10**7) - 1
        orders = BaseModel.as_list(db.session.query(Order).all())
        for i in range(0, 4):
            order_id = choice(orders)['id']
            saved_token_id = randint(range_start, range_end)
            transaction_id = randint(range_start, range_end)
            gross_amount = randint(range_start, range_end)
            transaction_time = datetime.datetime.now()

            transaction_status = transaction_statuses[randint(0, 2)]
            masked_card = randint(range_start, range_end)
            payment_type = payment_types[randint(0, 1)]
            bank = banks[randint(0, 6)]
            fraud_status = statuses[randint(0, 2)]

            new_payment = Payment()
            new_payment.order_id = order_id
            new_payment.saved_token_id = saved_token_id
            new_payment.transaction_id = transaction_id
            new_payment.gross_amount = gross_amount
            new_payment.transaction_time = transaction_time
            new_payment.transaction_status = transaction_status
            new_payment.masked_card = masked_card
            new_payment.payment_type = payment_type
            new_payment.bank = bank
            new_payment.fraud_status = fraud_status
            db.session.add(new_payment)
            db.session.commit()