def request_parameters(self): payer = get_payer(self.payer) beneficiary = get_payer(self.beneficiary) return { 'payer_id': payer.get_pk(), 'beneficiary_id': beneficiary.get_pk(), 'tag': self.get_tag(), 'amount': self.amount, 'beneficiary_wallet_id': self.beneficiary_wallet_id }
def request_parameters(self): payer = get_payer(self.payer) beneficiary = get_payer(self.beneficiary) return { 'payer_id': payer.get_pk(), 'beneficiary_id': beneficiary.get_pk(), 'tag': self.get_tag(), 'amount': self.amount, 'beneficiary_wallet_id': self.beneficiary_wallet_id }
def request_parameters(self): user = get_payer(self.user) return { 'user_id': user.get_pk(), 'transfer_id': self.transfer.transfer_id, 'tag': self.get_tag() }
def request_parameters(self): user = get_payer(self.user) return { 'user_id': user.get_pk(), 'transfer_id': self.transfer.transfer_id, 'tag': self.get_tag() }
def post(self, request, *args, **kwargs): self.object = self.get_object() self.get_context_data(object=self.object) self.user = self.get_user() self.contenttype = ContentType.objects.get_for_model( self.get_observed()) self.statuses = self.get_statuses(self.get_observed()) response = self.validate() if response and isinstance(response, HttpResponse): return response try: payer = get_payer(self.get_user()) if 'transfer' in self.statuses and not 'transferrefund' in self.statuses: transfers = self.statuses.get('transfer') transfer_refund_list = [] for transfer in transfers: transfer_refund = TransferRefund() transfer_refund.content_object = self.get_observed() transfer_refund.transfer = transfer transfer_refund.user = self.user transfer_refund.save() transfer_refund_list.append(transfer_refund) return self.success(transfer_refund_list) elif 'contribution' in self.statuses and not 'refund' in self.statuses: contributions = self.statuses.get('contribution') refund_list = [] for contribution in contributions: refund = Refund() refund.content_object = self.get_observed() refund.contribution = contribution refund.user = self.user refund.save() refund_list.append(refund) return self.success(refund_list) except (DecodeError, APIError), e: logger_leetchi.error(e) return redirect(self.get_error_url())
def post(self, request, *args, **kwargs): self.object = self.get_object() self.get_context_data(object=self.object) self.user = self.get_user() self.contenttype = ContentType.objects.get_for_model(self.get_observed()) self.statuses = self.get_statuses(self.get_observed()) response = self.validate() if response and isinstance(response, HttpResponse): return response try: payer = get_payer(self.get_user()) if 'transfer' in self.statuses and not 'transferrefund' in self.statuses: transfers = self.statuses.get('transfer') transfer_refund_list = [] for transfer in transfers: transfer_refund = TransferRefund() transfer_refund.content_object = self.get_observed() transfer_refund.transfer = transfer transfer_refund.user = self.user transfer_refund.save() transfer_refund_list.append(transfer_refund) return self.success(transfer_refund_list) elif 'contribution' in self.statuses and not 'refund' in self.statuses: contributions = self.statuses.get('contribution') refund_list = [] for contribution in contributions: refund = Refund() refund.content_object = self.get_observed() refund.contribution = contribution refund.user = self.user refund.save() refund_list.append(refund) return self.success(refund_list) except (DecodeError, APIError), e: logger_leetchi.error(e) return redirect(self.get_error_url())
def clean_amount(self): payer = get_payer(self.payer) amount = self.cleaned_data.get('amount') if not self.is_personal_amount_enough(payer, amount): raise forms.ValidationError(_('Your personal amount %(personal_amount)s is not enough to make this transfer %(amount)s' % { 'personal_amount': payer.personal_wallet_amount_converted, 'amount': amount })) return amount
def clean_amount(self): payer = get_payer(self.payer) amount = self.cleaned_data.get('amount') if not self.is_personal_amount_enough(payer, amount): raise forms.ValidationError( _( 'Your personal amount %(personal_amount)s is not enough to make this transfer %(amount)s' % { 'personal_amount': payer.personal_wallet_amount_converted, 'amount': amount })) return amount
def request_parameters(self): user = get_payer(self.user) data = { 'user_id': user.get_pk(), 'amount': self.amount, 'client_fee_amount': self.client_fee_amount, 'return_url': self.return_url, 'wallet_id': self.wallet_id, 'tag': self.get_tag(), 'template_url': self.template_url } if self.type: data['type'] = self.get_type_display() return data
def request_parameters(self): user = get_payer(self.user) data = { 'user_id': user.get_pk(), 'amount': self.amount, 'client_fee_amount': self.client_fee_amount, 'return_url': self.return_url, 'wallet_id': self.wallet_id, 'tag': self.get_tag(), 'template_url': self.template_url } if self.type: data['type'] = self.get_type_display() return data
def get(self, request, *args, **kwargs): try: contribution_id = request.GET.get('ContributionID', None) if contribution_id: contribution_id = int(contribution_id) try: contribution = Contribution.objects.get( contribution=contribution_id) except Contribution.DoesNotExist: pass else: contribution.sync_status() if contribution.is_error(): return redirect( self.get_error_url(leetchi_contribution)) payer = get_payer(request.user) wallet = get_wallet(self.get_object()) personal_amount = payer.personal_wallet_amount amount = int(self.get_amount() * 100) if personal_amount < amount: return self.redirect_payment_error(request) transfer = Transfer() transfer.content_object = self.get_observed() transfer.amount = amount transfer.payer = self.get_payer() transfer.beneficiary = self.get_beneficiary() transfer.beneficiary_wallet = wallet transfer.save() except (APIError, DecodeError), e: logger_leetchi.error(e) return redirect(self.get_payment_error_url())
def get(self, request, *args, **kwargs): user = request.user try: payer = get_payer(user) wallet = get_wallet(self.get_object()) personal_wallet_amount = payer.personal_wallet_amount or 0 amount = int(self.get_amount() * 100) if amount > personal_wallet_amount: return_url = self.get_return_url() real_amount = amount - personal_wallet_amount contribution = Contribution() contribution.content_object = self.get_observed() contribution.user = self.request.user contribution.wallet_id = 0 contribution.amount = real_amount contribution.return_url = return_url contribution.type = self.get_type() contribution.culture = get_current_lang() template_url = self.get_template_url() if template_url: contribution.template_url = template_url contribution.save() return redirect(self.get_success_url(contribution)) return redirect(self.get_return_url()) except (APIError, DecodeError), e: logger_leetchi.error(e) return redirect(self.get_error_url())
def get(self, request, *args, **kwargs): try: contribution_id = request.GET.get('ContributionID', None) if contribution_id: contribution_id = int(contribution_id) try: contribution = Contribution.objects.get(contribution=contribution_id) except Contribution.DoesNotExist: pass else: contribution.sync_status() if contribution.is_error(): return redirect(self.get_error_url(leetchi_contribution)) payer = get_payer(request.user) wallet = get_wallet(self.get_object()) personal_amount = payer.personal_wallet_amount amount = int(self.get_amount() * 100) if personal_amount < amount: return self.redirect_payment_error(request) transfer = Transfer() transfer.content_object = self.get_observed() transfer.amount = amount transfer.payer = self.get_payer() transfer.beneficiary = self.get_beneficiary() transfer.beneficiary_wallet = wallet transfer.save() except (APIError, DecodeError), e: logger_leetchi.error(e) return redirect(self.get_payment_error_url())
def get(self, request, *args, **kwargs): user = request.user try: payer = get_payer(user) wallet = get_wallet(self.get_object()) personal_wallet_amount = payer.personal_wallet_amount or 0 amount = int(self.get_amount() * 100) if amount > personal_wallet_amount: return_url = self.get_return_url() real_amount = amount - personal_wallet_amount contribution = Contribution() contribution.content_object = self.get_observed() contribution.user = self.request.user contribution.wallet_id = 0 contribution.amount = real_amount contribution.return_url = return_url contribution.type = self.get_type() contribution.culture = get_current_lang() template_url = self.get_template_url() if template_url: contribution.template_url = template_url contribution.save() return redirect(self.get_success_url(contribution)) return redirect(self.get_return_url()) except (APIError, DecodeError), e: logger_leetchi.error(e) return redirect(self.get_error_url())
def request_parameters(self): return { 'user_id': get_payer(self.user).get_pk(), 'contribution_id': self.contribution.contribution_id, 'tag': self.get_tag() }
def request_parameters(self): return { 'user_id': get_payer(self.user).get_pk(), 'contribution_id': self.contribution.contribution_id, 'tag': self.get_tag() }