Пример #1
0
def update_payment_info(request, recurring_payment_id,
                          template_name="recurring_payments/authnet/cim_update_payment_info2.html"):
    """
    Add or edit payment info.
    """
    rp = get_object_or_404(RecurringPayment, pk=recurring_payment_id)

    # only admin or user self can access this page
    if not request.user.profile.is_superuser and request.user.id <> rp.user.id:
        raise Http403

    rp.populate_payment_profile()

    payment_profiles = PaymentProfile.objects.filter(
                                        customer_profile_id=rp.customer_profile_id,
                                        status=True, status_detail='active')
    if payment_profiles:
        payment_profile = payment_profiles[0]
    else:
        payment_profile = None


    token, gateway_error = get_token(rp, CIMCustomerProfile, CIMHostedProfilePage,
                                     is_secure=request.is_secure())
    test_mode = get_test_mode()


    return render_to_response(template_name, {'rp': rp,
                                              'payment_profile': payment_profile,
                                              'token': token,
                                              'test_mode': test_mode,
                                              'gateway_error': gateway_error
                                              },
        context_instance=RequestContext(request))
Пример #2
0
def retrieve_token(request):
    """
    retrieve a token for a given recurring payment.
    """
    recurring_payment_id = request.POST.get('rpid')
    guid = request.POST.get('guid')
    rp = get_object_or_404(RecurringPayment, pk=recurring_payment_id)
    if guid != rp.guid:
        raise Http403

    token, gateway_error = get_token(rp,
                                     CIMCustomerProfile,
                                     CIMHostedProfilePage,
                                     is_secure=request.is_secure())

    return HttpResponse(token)
Пример #3
0
def api_get_rp_token(data):
    """Get the token for using authorize.net hosted profile page
        Accepted format: json

    Input fields:
        rp_id - required
        iframe_communicator_url

    Output:
        token
        gateway_error
        payment_profile_id
        result_code
    """
    rp_id = data.get('rp_id', 0)
    iframe_communicator_url = data.get('iframe_communicator_url', '')

    try:
        rp = RecurringPayment.objects.get(id=int(rp_id))
    except:
        return False, {}

    token, gateway_error = get_token(rp, CIMCustomerProfile,
                                     CIMHostedProfilePage,
                                     iframe_communicator_url)

    d = {'token': token,
         'gateway_error': gateway_error}

    # also pass the payment_profile_id
    payment_profiles = PaymentProfile.objects.filter(customer_profile_id=rp.customer_profile_id,
                                                    status=True,
                                                    status_detail='active')
    if payment_profiles:
        payment_profile_id = (payment_profiles[0]).payment_profile_id
    else:
        payment_profile_id = ''

    d['payment_profile_id'] = payment_profile_id


    if gateway_error:
        status = False
    else:
        status = True

    return status, d
Пример #4
0
def api_get_rp_token(data):
    """Get the token for using authorize.net hosted profile page
        Accepted format: json
    
    Input fields:
        rp_id - required
        iframe_communicator_url
        
    Output:
        token
        gateway_error
        payment_profile_id
        result_code
    """
    rp_id = data.get('rp_id', 0)
    iframe_communicator_url = data.get('iframe_communicator_url', '')
    
    try:
        rp = RecurringPayment.objects.get(id=int(rp_id))
    except:
        return False, {}
    
    token, gateway_error = get_token(rp, CIMCustomerProfile, 
                                     CIMHostedProfilePage, 
                                     iframe_communicator_url)
    
    d = {'token': token,
         'gateway_error': gateway_error}
    
    # also pass the payment_profile_id
    payment_profiles = PaymentProfile.objects.filter(customer_profile_id=rp.customer_profile_id, 
                                                    status=True, 
                                                    status_detail='active')
    if payment_profiles:
        payment_profile_id = (payment_profiles[0]).payment_profile_id
    else:
        payment_profile_id = ''
        
    d['payment_profile_id'] = payment_profile_id
    
    
    if gateway_error:
        status = False
    else:
        status = True
        
    return status, d