def handle_payment(self, order_number, order_total, **kwargs): ''' 处理支付请求 :param order_number: :param total_incl_tax: :param kwargs: :return: ''' if self.get_paymethod() != 'oscar_account': self.set_order_number(order_number) self.set_info() paymethod = self.paymentsource_method[self.get_paymethod()] paymethod(self, order_number, **kwargs) else: # Override payment method to use accounts to pay for the order allocations = self.get_account_allocations() if allocations.total != order_total.incl_tax: raise UnableToTakePayment("您的账户余额不足,请充值!") try: gateway.redeem(order_number, self.request.user, allocations) except act_exceptions.AccountException: raise UnableToTakePayment("账户余额支付发生错误") # If we get here, payment was successful. We record the payment # sources and event to complete the audit trail for this order source_type, __ = SourceType.objects.get_or_create(name="Account") for code, amount in allocations.items(): source = Source(source_type=source_type, amount_debited=amount, reference=code) self.add_payment_source(source) self.add_payment_event("Settle", order_total.incl_tax)
def handle_payment(self, order_number, total, **kwargs): # Override payment method to use accounts to pay for the order allocations = self.get_account_allocations() if allocations.total != total.incl_tax: raise exceptions.UnableToTakePayment( "Your account allocations do not cover the order total") try: gateway.redeem(order_number, self.request.user, allocations) except act_exceptions.AccountException: raise exceptions.UnableToTakePayment( "An error occurred with the account redemption") # If we get here, payment was successful. We record the payment # sources and event to complete the audit trail for this order source_type, __ = SourceType.objects.get_or_create(name="Account") for code, amount in allocations.items(): source = Source(source_type=source_type, amount_debited=amount, reference=code) self.add_payment_source(source) self.add_payment_event("Settle", total.incl_tax)
def handle_payment(self, order_number, total, **kwargs): # Override payment method to use accounts to pay for the order allocations = self.get_account_allocations() if allocations.total != total.incl_tax: raise exceptions.UnableToTakePayment( "SWAMAHANI, Vos moyens de paiement sont insuffisant") try: gateway.redeem(order_number, self.request.user, allocations) except act_exceptions.AccountException: raise exceptions.UnableToTakePayment( "Il y a une erreur, reesayer plus tard") # If we get here, payment was successful. We record the payment # sources and event to complete the audit trail for this order source_type, __ = SourceType.objects.get_or_create(name="Account") for code, amount in allocations.items(): source = Source(source_type=source_type, amount_debited=amount, reference=code) self.add_payment_source(source) self.add_payment_event("Settle", total.incl_tax)
def handle_payment(self, order_number, total, **kwargs): # Override payment method to use accounts to pay for the order allocations = self.get_account_allocations() if allocations.total != total: raise exceptions.UnableToTakePayment( "Your account allocations do not cover the order total") try: gateway.redeem(order_number, self.request.user, allocations) except act_exceptions.AccountException: raise exceptions.UnableToTakePayment( "An error occurred with the account redemption") # If we get here, payment was successful. We record the payment # sources and event to complete the audit trail for this order source_type, __ = SourceType.objects.get_or_create( name="Account") for code, amount in allocations.items(): source = Source( source_type=source_type, amount_debited=amount, reference=code) self.add_payment_source(source) self.add_payment_event("Settle", total)