def __init__(self, model): self.URL = model.endpoint self.USERNAME = model.merchant self.PASSWORD = model.password self.SUCCESS_CALLBACK = model.success_callback self.ERROR_CALLBACK = model.error_callback self.PENDING_CALLBACK = model.pending_callback self.MONEY = 100 self.CURRENCY = 'EUR' self.order = compute_uuid() self.gw = model self.gateways_manager = PaymentGatewayManager() self.payment_method_process = PaymentMethodProcess()
class PaymentMethodManager: payment_method_process = PaymentMethodProcess() def get_payment_methods(self, account, status): return PaymentMethod.objects.filter(account=account, status=status) def get_payment_methods_by_order_code(self, order_code, status): return PaymentMethod.objects.get(recurrent_order_code=order_code, status=status) def get_valid_payment_methods(self, account): return PaymentMethod.objects.filter(account=account, status='VALIDATED') def get_valid_payment_method(self, pm_id, account): try: return PaymentMethod.objects.get(id=pm_id, account=account, status='VALIDATED') except PaymentMethod.DoesNotExist: return None def store_payment_method(self, account, recurrent_order_code, gateway): # Creating PaymentMethod payment_method = PaymentMethod( account=account, recurrent_order_code=recurrent_order_code, gateway=gateway) payment_method.save() return payment_method def start_new_payment_method_notification_process(self, payment_method, fn): fn = self.payment_method_process._start_standalone_new_payment_method_process # Async. Starting notification process self.payment_method_process.start_new_payment_method_notification_process( payment_method, fn)
def __init__(self): self.payment_method_process = PaymentMethodProcess() self.customer_manager = CustomerManager() self.payment_method_manager = PaymentMethodManager()