def _show_payment_form(self, context, payment): amount_available = self.get_credit_available_for_user(context.user.name) remaining_to_pay = payment['amount'] - amount_available # Partial payment if remaining_to_pay > decimal('0'): # Delete credit users_credit = self.get_resource('users-credit') results = users_credit.handler.search(user=context.user.name) if len(results) == 0: raise ValueError, 'Error, credit do not exist' record = results[0] old_amount = users_credit.handler.get_record_value(record, 'amount') new_amount = old_amount - payment['amount'] if new_amount < decimal('0'): users_credit.del_record(record.id) else: kw = {'amount': new_amount} users_credit.update_recod(record.id, **kw) # Encapsulate in pay view payment['mode'] = 'paybox' # XXX (Can have another name ?) payment['amount'] = remaining_to_pay return self.parent.show_payment_form(context, payment) # Complete payment return PaymentWay._show_payment_form(self, context, payment)
def get_metadata_schema(cls): return merge_dicts(PaymentWay.get_metadata_schema(), address=Unicode)
def get_metadata_schema(cls): return merge_dicts(PaymentWay.get_metadata_schema(), deposit_schema)
def get_metadata_schema(cls): schema = PaymentWay.get_metadata_schema() # Paybox account configuration schema.update(cls.base_schema) return schema
def get_metadata_schema(cls): return merge_dicts(PaymentWay.get_metadata_schema(), to=Unicode, address=Unicode)
def _make_resource(cls, folder, name, *args, **kw): # Create resource PaymentWay._make_resource(cls, folder, name, *args, **kw) CreditAvailable_Table._make_resource(CreditAvailable_Table, folder, '%s/users-credit' % name)
def get_metadata_schema(cls): return merge_dicts(PaymentWay.get_metadata_schema(), RIB=RIB, IBAN=IBAN)