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
示例#2
0
    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
示例#3
0
def payment_method_redirect(request, update ):
    if update:
        success_redirect = settings.SAMURAI_UPDATEMETHOD_REDIRECT
        error_redirect = settings.SAMURAI_UPDATEMETHOD_REDIRECT
    else:
        success_redirect = settings.SAMURAI_NEWMETHOD_REDIRECT
        error_redirect = settings.SAMURAI_NEWMETHOD_REDIRECT

    if not 'payment_method_token' in request.GET:
        return HttpResponseRedirect( reverse(error_redirect ) )
 
    new_payment_method = PaymentMethod(payment_method_token = request.GET['payment_method_token'], user = request.user)

    if not new_payment_method.fetch() or not new_payment_method.is_sensitive_data_valid:
        return HttpResponseRedirect( reverse(error_redirect ) 
            + "?payment_method_token=" + new_payment_method.payment_method_token )

    try:
        new_payment_method.full_clean()

        if update:
            old_payment_method = PaymentMethod.objects.get(payment_method_token = new_payment_method.custom['django_prev_payment_method_token'])
            old_payment_method.redact()
            old_payment_method.disabled = True
            old_payment_method.save()

        new_payment_method.retain()
        new_payment_method.save()

        return HttpResponseRedirect( reverse(success_redirect ) 
            + "?payment_method_token=" + new_payment_method.payment_method_token )
    except ValidationError: # not attached to the right user
        return HttpResponseRedirect( reverse(error_redirect )
            + "?payment_method_token=" + new_payment_method.payment_method_token )
示例#4
0
def add_payment_method():
    user = session.user
    payment_method = PaymentMethod.add(user=user, **request.json)
    user.update(default_payment_method=payment_method)
    return jsonify(payment_method=payment_method.json)