Esempio n. 1
0
def paylane(request):
    amount = 1
    response = None
    if request.method == 'POST':
        form = CreditCardForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            credit_card = CreditCard(**data)
            merchant = get_gateway("paylane")
            customer = PaylanePaymentCustomer()
            customer.name = "%s %s" % (data['first_name'], data['last_name'])
            customer.email = "*****@*****.**"
            customer.ip_address = "127.0.0.1"
            options = {}
            address = PaylanePaymentCustomerAddress()
            address.street_house = 'Av. 24 de Julho, 1117'
            address.city = 'Lisbon'
            address.zip_code = '1700-000'
            address.country_code = 'PT'
            customer.address = address
            options['customer'] = customer
            options['product'] = {}
            response = merchant.purchase(amount, credit_card, options=options)
    else:
        form = CreditCardForm(initial=GATEWAY_INITIAL['paylane'])
    return render(
        request, 'app/index.html', {
            'form': form,
            'amount': amount,
            'response': response,
            'title': 'Paylane Gateway'
        })
Esempio n. 2
0
def paypal(request):
    amount = 1
    response = None
    if request.method == 'POST':
        form = CreditCardForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            credit_card = CreditCard(**data)
            merchant = get_gateway("pay_pal")
            try:
                merchant.validate_card(credit_card)
            except CardNotSupported:
                response = "Credit Card Not Supported"
            # response = merchant.purchase(amount, credit_card, options={'request': request})
            response = merchant.recurring(amount,
                                          credit_card,
                                          options={'request': request})
    else:
        form = CreditCardForm(initial=GATEWAY_INITIAL['paypal'])
    return render(request, 'app/index.html', {
        'form': form,
        'amount': amount,
        'response': response,
        'title': 'Paypal'
    })
Esempio n. 3
0
def beanstream(request):
    amount = 1
    response = None
    if request.method == 'POST':
        form = CreditCardForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            credit_card = CreditCard(**data)
            merchant = get_gateway("beanstream")
            response = merchant.purchase(amount, credit_card,
                                         {"billing_address": {
                        "name": "%s %s" % (data["first_name"], data["last_name"]),
                        # below are hardcoded just for the sake of the example
                        # you can make these optional by toggling the customer name
                        # and address in the account dashboard.
                        "email": "*****@*****.**",
                        "phone": "555-555-555-555",
                        "address1": "Addr1",
                        "address2": "Addr2",
                        "city": "Hyd",
                        "state": "AP",
                        "country": "IN"
                        }
                                          })
    else:
        form = CreditCardForm(initial=GATEWAY_INITIAL['beanstream'])
    return render(request, 'app/index.html',{'form': form,
                                             'amount': amount,
                                             'response': response,
                                             'title': 'Beanstream'})
Esempio n. 4
0
 def setUp(self):
     self.merchant = get_gateway("pay_pal")
     self.merchant.test_mode = True
     self.credit_card = CreditCard(first_name="Test", last_name="User",
                                   month=10, year=2017, 
                                   number="4500775008976759", 
                                   verification_value="000")
Esempio n. 5
0
 def setUp(self):
     self.merchant = get_gateway("pin")
     self.merchant.test_mode = True
     self.credit_card = CreditCard(first_name="Test", last_name="User",
                                   month=10, year=2020,
                                   number=VISA_SUCCESS,
                                   verification_value="100")
Esempio n. 6
0
    def post(self, request, *args, **kwargs):
        form = self.form_class(request.POST)
        card = request.POST.get('credit_card_number')
        month = request.POST.get('credit_card_expiration_month')
        year = request.POST.get('credit_card_expiration_year')
        cvv = request.POST.get('credit_card_cvc')
        first_name = request.POST.get('first_name')
        last_name = request.POST.get('last_name')
        plan = UserSubscriptions.objects.get(user=request.user)
        amount = int(plan.plan.price)
        if form.is_valid():
            # stripe = get_gateway("stripe")
            braintree = get_gateway("braintree_payments")
            credit_card = CreditCard(first_name=first_name, last_name=last_name, month=month, year=year,
                             number=card,
                             verification_value=cvv)
            # resp = stripe.purchase(int(amount), credit_card)
            resp = braintree.purchase(10, credit_card)
            print "resposne", resp['status']
            payment = Payment()
            payment.user = request.user
            payment.payment_type = "0"
            payment.amount = amount
            payment.plan = plan.plan.title
            payment.date = datetime.date.today()
            payment.save()
            return redirect('/accounts/update-profile/')

        else:
            print "error", form.errors
        return render_to_response(self.template_name, {'form': form}, context_instance=RequestContext(request))
Esempio n. 7
0
def stripepayment(request,  campaign_id):
    campaign_obj = get_object_or_404(Campaign, pk=campaign_id)
    amount = int(campaign_obj.target_amount)
    if request.method == 'POST':
        form = CreditCardForm(request.POST)
        # import ipdb; ipdb.set_trace()
        if form.is_valid():
            data = form.cleaned_data
            credit_card = CreditCard(**data)
            merchant = get_gateway("stripe")
            response = merchant.purchase(amount, credit_card)
            response_dict = {}
            response_dict.update({'status': response['status']})
            response_dict.update(response['response'])
            del response_dict['card']
            response_dict.update(response['response']['card'])
            # request.session['response_data'] = response_dict
            # return HttpResponseRedirect(reverse('paygate:payment_success', args=[campaign_id]))
            return render_to_response('payment/payment_success.html',
                                       {'campaign': campaign_obj,
                                        'response': response_dict,},
                                             context_instance=RequestContext(request))
    else:
        form = CreditCardForm(initial={'number': '4242424242424242'})
    return render_to_response(
        'payment/stripe_payment_form.html', {'form': form,
                                             'campaign': campaign_obj},
        context_instance=RequestContext(request))
Esempio n. 8
0
def beanstream(request):
    amount = 1
    response = None
    if request.method == 'POST':
        form = CreditCardForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            credit_card = CreditCard(**data)
            merchant = get_gateway("beanstream")
            response = merchant.purchase(amount, credit_card,
                                         {"billing_address": {
                        "name": "%s %s" % (data["first_name"], data["last_name"]),
                        # below are hardcoded just for the sake of the example
                        # you can make these optional by toggling the customer name
                        # and address in the account dashboard.
                        "email": "*****@*****.**",
                        "phone": "555-555-555-555",
                        "address1": "Addr1",
                        "address2": "Addr2",
                        "city": "Hyd",
                        "state": "AP",
                        "country": "IN"
                        }
                                          })
    else:
        form = CreditCardForm(initial=GATEWAY_INITIAL['beanstream'])
    return render(request, 'app/index.html',{'form': form,
                                             'amount': amount,
                                             'response': response,
                                             'title': 'Beanstream'})
Esempio n. 9
0
def stripepayment(request, campaign_id):
    campaign_obj = get_object_or_404(Campaign, pk=campaign_id)
    amount = int(campaign_obj.target_amount)
    if request.method == 'POST':
        form = CreditCardForm(request.POST)
        # import ipdb; ipdb.set_trace()
        if form.is_valid():
            data = form.cleaned_data
            credit_card = CreditCard(**data)
            merchant = get_gateway("stripe")
            response = merchant.purchase(amount, credit_card)
            response_dict = {}
            response_dict.update({'status': response['status']})
            response_dict.update(response['response'])
            del response_dict['card']
            response_dict.update(response['response']['card'])
            request.session['response'] = response_dict
            return HttpResponseRedirect(
                reverse('paygate:payment_success', args=[campaign_id]))
    else:
        form = CreditCardForm(initial={'number': '4242424242424242'})
    return render_to_response('payment/stripe_payment_form.html', {
        'form': form,
        'campaign': campaign_obj
    },
                              context_instance=RequestContext(request))
 def setUp(self):
     self.merchant = get_gateway("braintree_payments")
     self.merchant.test_mode = True
     self.credit_card = CreditCard(first_name="Test", last_name="User",
                                   month=10, year=2020,
                                   number="4111111111111111",
                                   verification_value="100")
Esempio n. 11
0
def paypal(request):
    amount = 1
    response = None
    if request.method == 'POST':
        form = CreditCardForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            credit_card = CreditCard(**data)
            merchant = get_gateway("pay_pal")
            try:
                merchant.validate_card(credit_card)
            except CardNotSupported:
                response = "Credit Card Not Supported"
            # response = merchant.purchase(amount, credit_card, options={'request': request})
            response = merchant.recurring(amount, credit_card, options={'request': request})
    else:
        form = CreditCardForm(initial={'number': '4797503429879309',
                                       'verification_value': '037',
                                       'month': 1,
                                       'year': 2019,
                                       'card_type': 'visa'})
    return render(request, 'app/index.html', {'form': form,
                                              'amount': amount,
                                              'response': response,
                                              'title': 'Paypal'})
Esempio n. 12
0
 def setUp(self):
     self.merchant = get_gateway("authorize_net")
     self.merchant.test_mode = True
     self.credit_card = CreditCard(first_name="Test", last_name="User",
                                   month=10, year=2011, 
                                   number="4222222222222", 
                                   verification_value="100")
Esempio n. 13
0
 def setUp(self):
     with mock.patch('bitcoinrpc.connection.BitcoinConnection') as MockBitcoinConnection:
         connection = MockBitcoinConnection()
         connection.getnewaddress.return_value = TEST_ADDRESS
         connection.listtransactions.return_value = TEST_SUCCESSFUL_TXNS
         self.merchant = get_gateway("bitcoin")
         self.address = self.merchant.get_new_address()
 def setUp(self):
     self.merchant = get_gateway("braintree_payments")
     self.merchant.test_mode = True
     self.credit_card = CreditCard(first_name="Test", last_name="User",
                                   month=10, year=2011, 
                                   number="4111111111111111", 
                                   verification_value="100")
Esempio n. 15
0
def paypal(request):
    amount = 1
    response = None
    if request.method == 'POST':
        form = CreditCardForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            credit_card = CreditCard(**data)
            merchant = get_gateway("pay_pal")
            try:
                merchant.validate_card(credit_card)
            except CardNotSupported:
                response = "Credit Card Not Supported"
            # response = merchant.purchase(amount, credit_card, options={'request': request})
            response = merchant.recurring(amount, credit_card, options={'request': request})
    else:
        form = CreditCardForm(initial={'number': '4797503429879309',
                                       'verification_value': '037',
                                       'month': 1,
                                       'year': 2019,
                                       'card_type': 'visa'})
    return render(request, 'app/index.html', {'form': form,
                                              'amount': amount,
                                              'response': response,
                                              'title': 'Paypal'})
Esempio n. 16
0
 def setUp(self):
     self.merchant = get_gateway("apt")
     self.merchant.test_mode = True
     self.credit_card = CreditCard(first_name="Test", last_name="User",
         month=10, year=2020,
         number="4222222222222",
         verification_value="100")
Esempio n. 17
0
def paylane(request):
    amount = 1
    response= None
    if request.method == 'POST':
        form = CreditCardForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            credit_card = CreditCard(**data)
            merchant = get_gateway("paylane")
            customer = PaylanePaymentCustomer()
            customer.name = "%s %s" %(data['first_name'], data['last_name'])
            customer.email = "*****@*****.**"
            customer.ip_address = "127.0.0.1"
            options = {}
            address = PaylanePaymentCustomerAddress()
            address.street_house = 'Av. 24 de Julho, 1117'
            address.city = 'Lisbon'
            address.zip_code = '1700-000'
            address.country_code = 'PT'
            customer.address = address
            options['customer'] = customer
            options['product'] = {}
            response = merchant.purchase(amount, credit_card, options = options)
    else:
        form = CreditCardForm(initial=GATEWAY_INITIAL['paylane'])
    return render(request, 'app/index.html', {'form': form,
                                              'amount':amount,
                                              'response':response,
                                              'title':'Paylane Gateway'})
Esempio n. 18
0
 def setUp(self):
     self.merchant = get_gateway("stripe")
     self.credit_card = CreditCard(first_name="Test", last_name="User",
                                   month=10, year=2012,
                                   number="4242424242424242",
                                   verification_value="100")
     stripe.api_key = settings.STRIPE_API_KEY
     self.stripe = stripe
Esempio n. 19
0
 def setUp(self):
     self.merchant = get_gateway("stripe")
     self.credit_card = CreditCard(first_name="Test", last_name="User",
                                   month=10, year=2020,
                                   number="4242424242424242",
                                   verification_value="100")
     stripe.api_key = self.merchant.stripe.api_key
     self.stripe = stripe
Esempio n. 20
0
    def testRaiseExceptionNotConfigured(self):
        original_settings = settings.MERCHANT_SETTINGS
        settings.MERCHANT_SETTINGS = {"google_checkout": {"MERCHANT_ID": "", "MERCHANT_KEY": ""}}

        # Test if we can import any other gateway or integration
        self.assertRaises(IntegrationNotConfigured, lambda: get_integration("stripe"))
        self.assertRaises(GatewayNotConfigured, lambda: get_gateway("authorize_net"))
        settings.MERCHANT_SETTINGS = original_settings
Esempio n. 21
0
 def testRaiseExceptionNotConfigured(self):
     with self.settings(MERCHANT_SETTINGS = {
             "pay_pal": {
             }
     }):
         # Test if we can import any other gateway or integration
         self.assertRaises(IntegrationNotConfigured, lambda: get_integration("stripe"))
         self.assertRaises(GatewayNotConfigured, lambda: get_gateway("authorize_net"))
 def __init__(self):
     super(StripeIntegration, self).__init__()
     merchant_settings = getattr(settings, "MERCHANT_SETTINGS")
     if not merchant_settings or not merchant_settings.get("stripe"):
         raise IntegrationNotConfigured("The '%s' integration is not correctly " "configured." % self.display_name)
     stripe_settings = merchant_settings["stripe"]
     self.gateway = get_gateway("stripe")
     self.publishable_key = stripe_settings["PUBLISHABLE_KEY"]
Esempio n. 23
0
 def setUp(self):
     with mock.patch('bitcoinrpc.connection.BitcoinConnection'
                     ) as MockBitcoinConnection:
         connection = MockBitcoinConnection()
         connection.getnewaddress.return_value = TEST_ADDRESS
         connection.listtransactions.return_value = TEST_SUCCESSFUL_TXNS
         self.merchant = get_gateway("bitcoin")
         self.address = self.merchant.get_new_address()
Esempio n. 24
0
 def setUp(self):
     self.merchant = get_gateway("pay_pal")
     self.merchant.test_mode = True
     self.credit_card = CreditCard(first_name="Test",
                                   last_name="User",
                                   month=10,
                                   year=2017,
                                   number="4500775008976759",
                                   verification_value="000")
Esempio n. 25
0
 def __init__(self):
     super(StripeIntegration, self).__init__()
     merchant_settings = getattr(settings, "MERCHANT_SETTINGS")
     if not merchant_settings or not merchant_settings.get("stripe"):
         raise IntegrationNotConfigured("The '%s' integration is not correctly "
                                    "configured." % self.display_name)
     stripe_settings = merchant_settings["stripe"]
     self.gateway = get_gateway("stripe")
     self.publishable_key = stripe_settings['PUBLISHABLE_KEY']
Esempio n. 26
0
 def __init__(self):
     super(SamuraiIntegration, self).__init__()
     merchant_settings = getattr(settings, "MERCHANT_SETTINGS")
     if not merchant_settings or not merchant_settings.get("samurai"):
         raise IntegrationNotConfigured("The '%s' integration is not correctly "
                                    "configured." % self.display_name)
     samurai_settings = merchant_settings["samurai"]
     self.merchant_key = samurai_settings['MERCHANT_KEY']
     self.gateway = get_gateway("samurai")
Esempio n. 27
0
 def setUp(self):
     self.merchant = get_gateway("paylane")
     self.merchant.test_mode = True
     address = PaylanePaymentCustomerAddress()
     address.street_house = 'Av. 24 de Julho, 1117'
     address.city = 'Lisbon'
     address.zip_code = '1700-000'
     address.country_code = 'PT'
     self.customer = PaylanePaymentCustomer(name='Celso Pinto',email='*****@*****.**',ip_address='8.8.8.8',address=address)
     self.product = PaylanePaymentProduct(description='Paylane test payment')
Esempio n. 28
0
 def setUp(self):
     self.merchant = get_gateway("paylane")
     self.merchant.test_mode = True
     address = PaylanePaymentCustomerAddress()
     address.street_house = 'Av. 24 de Julho, 1117'
     address.city = 'Lisbon'
     address.zip_code = '1700-000'
     address.country_code = 'PT'
     self.customer = PaylanePaymentCustomer(name='Celso Pinto', email='*****@*****.**', ip_address='8.8.8.8', address=address)
     self.product = PaylanePaymentProduct(description='Paylane test payment')
Esempio n. 29
0
 def __init__(self):
     super(SamuraiIntegration, self).__init__()
     merchant_settings = getattr(settings, "MERCHANT_SETTINGS")
     if not merchant_settings or not merchant_settings.get("samurai"):
         raise IntegrationNotConfigured(
             "The '%s' integration is not correctly "
             "configured." % self.display_name)
     samurai_settings = merchant_settings["samurai"]
     self.merchant_key = samurai_settings['MERCHANT_KEY']
     self.gateway = get_gateway("samurai")
Esempio n. 30
0
def bitcoin(request):
    bitcoin_obj = get_gateway("bitcoin")
    address = request.session.get("bitcoin_address", None)
    if not address:
        address = bitcoin_obj.get_new_address()
        request.session["bitcoin_address"] = address
    return render(request, "app/bitcoin.html", {
        "title": "Bitcoin",
        "address": address
    })
Esempio n. 31
0
 def setUp(self):
     self.merchant = get_gateway(
         "beanstream", **{
             "merchant_id": 267390000,
             "hashcode": "dine-otestkey",
             "hash_algorithm": "SHA1",
             "payment_profile_passcode": "BCCE75A688F8497E9CDBC77AA8178581",
         })
     self.merchant.test_mode = True
     self.billing_address = Address('John Doe', '*****@*****.**',
                                    '555-555-5555', '123 Fake Street', '',
                                    'Fake City', 'ON', 'A1A1A1', 'CA')
Esempio n. 32
0
def bitcoin(request):
    amount = 0.01
    bitcoin_obj = get_gateway("bitcoin")
    address = request.session.get("bitcoin_address", None)
    if not address:
        address = bitcoin_obj.get_new_address()
        request.session["bitcoin_address"] = address
    return render(request, "app/bitcoin.html", {
        "title": "Bitcoin",
        "amount": amount,
        "address": address
    })
Esempio n. 33
0
 def setUp(self):
     self.merchant = get_gateway("beanstream")
     self.merchant.test_mode = True
     self.billing_address = Address(
         'John Doe',
         '*****@*****.**',
         '555-555-5555',
         '123 Fake Street',
         '',
         'Fake City',
         'ON',
         'A1A1A1',
         'CA')
Esempio n. 34
0
    def testRaiseExceptionNotConfigured(self):
        original_settings = settings.MERCHANT_SETTINGS
        settings.MERCHANT_SETTINGS = {
            "google_checkout": {
                "MERCHANT_ID": '',
                "MERCHANT_KEY": ''
                }
            }

        # Test if we can import any other gateway or integration
        self.assertRaises(IntegrationNotConfigured, lambda: get_integration("stripe"))
        self.assertRaises(GatewayNotConfigured, lambda: get_gateway("authorize_net"))
        settings.MERCHANT_SETTINGS = original_settings
Esempio n. 35
0
 def setUp(self):
     self.merchant = get_gateway("beanstream")
     self.merchant.test_mode = True
     self.billing_address = Address(
         'John Doe',
         '*****@*****.**',
         '555-555-5555',
         '123 Fake Street',
         '',
         'Fake City',
         'ON',
         'A1A1A1',
         'CA')
Esempio n. 36
0
def eway(request):
    amount = 1
    response = None
    if request.method == 'POST':
        form = CreditCardForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            credit_card = CreditCard(**data)
            merchant = get_gateway("eway")
            try:
                merchant.validate_card(credit_card)
            except CardNotSupported:
                response = "Credit Card Not Supported"
            billing_address = {
                'salutation': 'Mr.',
                'address1': 'test',
                'address2': ' street',
                'city': 'Sydney',
                'state': 'NSW',
                'company': 'Test Company',
                'zip': '2000',
                'country': 'au',
                'email': '*****@*****.**',
                'fax': '0267720000',
                'phone': '0267720000',
                'mobile': '0404085992',
                'customer_ref': 'REF100',
                'job_desc': 'test',
                'comments': 'any',
                'url': 'http://www.google.com.au',
            }
            response = merchant.purchase(amount,
                                         credit_card,
                                         options={
                                             'request': request,
                                             'billing_address': billing_address
                                         })
    else:
        form = CreditCardForm(
            initial={
                'number': '4444333322221111',
                'verification_value': '000',
                'month': 7,
                'year': 2012
            })
    return render(request, 'app/index.html', {
        'form': form,
        'amount': amount,
        'response': response,
        'title': 'Eway'
    })
Esempio n. 37
0
def bitcoin_done(request):
    amount = 1
    bitcoin_obj = get_gateway("bitcoin")
    address = request.session.get("bitcoin_address", None)
    if not address:
        return HttpResponseRedirect(reverse("app_bitcoin"))
    result = bitcoin_obj.purchase(amount, address)
    if result['status'] == 'SUCCESS':
        del request.session["bitcoin_address"]
    return render(request, "app/bitcoin_done.html", {
        "title": "Bitcoin",
        "address": address,
        "result": result
    })
Esempio n. 38
0
def we_pay(request):
    wp = get_gateway("we_pay")
    form = None
    amount = 10
    response = wp.purchase(10, None, {
            "description": "Test Merchant Description",
            "type": "SERVICE",
            "redirect_uri": request.build_absolute_uri(reverse('app_we_pay_redirect'))
            })
    if response["status"] == "SUCCESS":
        return HttpResponseRedirect(response["response"]["checkout_uri"])
    return render(request, 'app/index.html', {'form': form,
                                              'amount':amount,
                                              'response':response,
                                              'title':'WePay Payment'})
Esempio n. 39
0
def bitcoin_done(request):
    amount = 0.01
    bitcoin_obj = get_gateway("bitcoin")
    address = request.session.get("bitcoin_address", None)
    if not address:
        return HttpResponseRedirect(reverse("app_bitcoin"))
    result = bitcoin_obj.purchase(amount, address)
    if result['status'] == 'SUCCESS':
        del request.session["bitcoin_address"]
    return render(request, "app/bitcoin_done.html", {
        "title": "Bitcoin",
        "amount": amount,
        "address": address,
        "result": result
    })
Esempio n. 40
0
def we_pay(request):
    wp = get_gateway("we_pay")
    form = None
    amount = 10
    response = wp.purchase(10, None, {
            "description": "Test Merchant Description",
            "type": "SERVICE",
            "redirect_uri": request.build_absolute_uri(reverse('app_we_pay_redirect'))
            })
    if response["status"] == "SUCCESS":
        return HttpResponseRedirect(response["response"]["checkout_uri"])
    return render(request, 'app/index.html', {'form': form,
                                              'amount':amount,
                                              'response':response,
                                              'title':'WePay Payment'})
Esempio n. 41
0
def samurai(request):
    amount = 1
    response= None
    if request.method == 'POST':
        form = CreditCardForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            credit_card = CreditCard(**data)
            merchant = get_gateway("samurai")
            response = merchant.purchase(amount,credit_card)
    else:
        form = CreditCardForm(initial={'number':'4111111111111111'})
    return render(request, 'app/index.html',{'form': form,
                                             'amount':amount,
                                             'response':response,
                                             'title':'Samurai'})
Esempio n. 42
0
def stripe(request):
    amount = 1
    response= None
    if request.method == 'POST':
        form = CreditCardForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            credit_card = CreditCard(**data)
            merchant = get_gateway("stripe")
            response = merchant.purchase(amount,credit_card)
    else:
        form = CreditCardForm(initial=GATEWAY_INITIAL['stripe'])
    return render(request, 'app/index.html',{'form': form,
                                             'amount':amount,
                                             'response':response,
                                             'title':'Stripe Payment'})
Esempio n. 43
0
def stripe(request):
    amount = 1
    response= None
    if request.method == 'POST':
        form = CreditCardForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            credit_card = CreditCard(**data)
            merchant = get_gateway("stripe")
            response = merchant.purchase(amount,credit_card)
    else:
        form = CreditCardForm(initial=GATEWAY_INITIAL['stripe'])
    return render(request, 'app/index.html',{'form': form,
                                             'amount':amount,
                                             'response':response,
                                             'title':'Stripe Payment'})
Esempio n. 44
0
 def setUp(self):
     self.merchant = get_gateway("beanstream", **{"merchant_id": 267390000,
                                                  "hashcode"  : "dine-otestkey",
                                                  "hash_algorithm"   : "SHA1",
                                                  "payment_profile_passcode":"BCCE75A688F8497E9CDBC77AA8178581",
                                             })
     self.merchant.test_mode = True
     self.billing_address = Address(
         'John Doe',
         '*****@*****.**',
         '555-555-5555',
         '123 Fake Street',
         '',
         'Fake City',
         'ON',
         'A1A1A1',
         'CA')
Esempio n. 45
0
def bitcoin(request):
    with mock.patch('bitcoinrpc.connection.BitcoinConnection') as MockBitcoinConnection:
        connection = MockBitcoinConnection()
        connection.getnewaddress.return_value = BTC_TEST_ADDRESS
        connection.listtransactions.return_value = BTC_TEST_SUCCESSFUL_TXNS
        amount = 0.01
        bitcoin_obj = get_gateway("bitcoin")
        address = request.session.get("bitcoin_address", None)
        if not address:
            address = bitcoin_obj.get_new_address()
            request.session["bitcoin_address"] = address
        return render(request, "app/bitcoin.html", {
            "title": "Bitcoin",
            "amount": amount,
            "address": address,
            "settings": settings
        })
Esempio n. 46
0
def samurai(request):
    amount = 1
    response = None
    if request.method == 'POST':
        form = CreditCardForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            credit_card = CreditCard(**data)
            merchant = get_gateway("samurai")
            response = merchant.purchase(amount, credit_card)
    else:
        form = CreditCardForm(initial={'number': '4111111111111111'})
    return render(request, 'app/index.html', {
        'form': form,
        'amount': amount,
        'response': response,
        'title': 'Samurai'
    })
Esempio n. 47
0
def chargebee(request):
    amount = 1
    response = None
    if request.method == 'POST':
        form = CreditCardForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            credit_card = CreditCard(**data)
            merchant = get_gateway("chargebee")
            response = merchant.purchase(amount, credit_card,
                                         {"plan_id": "professional",
                                          "description": "Quick Purchase"})
    else:
        form = CreditCardForm(initial=GATEWAY_INITIAL['chargebee'])
    return render(request, 'app/index.html',{'form': form,
                                             'amount': amount,
                                             'response': response,
                                             'title': 'Chargebee'})
Esempio n. 48
0
def chargebee(request):
    amount = 1
    response = None
    if request.method == 'POST':
        form = CreditCardForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            credit_card = CreditCard(**data)
            merchant = get_gateway("chargebee")
            response = merchant.purchase(amount, credit_card,
                                         {"plan_id": "professional",
                                          "description": "Quick Purchase"})
    else:
        form = CreditCardForm(initial=GATEWAY_INITIAL['chargebee'])
    return render(request, 'app/index.html',{'form': form,
                                             'amount': amount,
                                             'response': response,
                                             'title': 'Chargebee'})
Esempio n. 49
0
def bitcoin(request):
    with mock.patch('bitcoinrpc.connection.BitcoinConnection'
                    ) as MockBitcoinConnection:
        connection = MockBitcoinConnection()
        connection.getnewaddress.return_value = BTC_TEST_ADDRESS
        connection.listtransactions.return_value = BTC_TEST_SUCCESSFUL_TXNS
        amount = 0.01
        bitcoin_obj = get_gateway("bitcoin")
        address = request.session.get("bitcoin_address", None)
        if not address:
            address = bitcoin_obj.get_new_address()
            request.session["bitcoin_address"] = address
        return render(
            request, "app/bitcoin.html", {
                "title": "Bitcoin",
                "amount": amount,
                "address": address,
                "settings": settings
            })
Esempio n. 50
0
def bitcoin_done(request):
    with mock.patch('bitcoinrpc.connection.BitcoinConnection') as MockBitcoinConnection:
        connection = MockBitcoinConnection()
        connection.getnewaddress.return_value = BTC_TEST_ADDRESS
        connection.listtransactions.return_value = BTC_TEST_SUCCESSFUL_TXNS
        amount = 0.01
        bitcoin_obj = get_gateway("bitcoin")
        address = request.session.get("bitcoin_address", None)
        if not address:
            return HttpResponseRedirect(reverse("app_bitcoin"))
        result = bitcoin_obj.purchase(amount, address)
        if result['status'] == 'SUCCESS':
            del request.session["bitcoin_address"]
        return render(request, "app/bitcoin_done.html", {
            "title": "Bitcoin",
            "amount": amount,
            "address": address,
            "result": result
        })
Esempio n. 51
0
def braintree(request):
    amount = 1
    response = None
    if request.method == 'POST':
        form = CreditCardForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            credit_card = CreditCard(**data)
            merchant = get_gateway("braintree_payments")
            try:
                merchant.validate_card(credit_card)
            except CardNotSupported:
                response = "Credit Card Not Supported"
            response = merchant.purchase(amount, credit_card)
    else:
        form = CreditCardForm(initial={'number':'4111111111111111'})
    return render(request, 'app/index.html', {'form': form,
                                              'amount': amount,
                                              'response': response,
                                              'title': 'Braintree Payments (S2S)'})
Esempio n. 52
0
def braintree(request):
    amount = 1
    response = None
    if request.method == 'POST':
        form = CreditCardForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            credit_card = CreditCard(**data)
            merchant = get_gateway("braintree_payments")
            try:
                merchant.validate_card(credit_card)
            except CardNotSupported:
                response = "Credit Card Not Supported"
            response = merchant.purchase(amount, credit_card)
    else:
        form = CreditCardForm(initial={'number':'4111111111111111'})
    return render(request, 'app/index.html', {'form': form,
                                              'amount': amount,
                                              'response': response,
                                              'title': 'Braintree Payments (S2S)'})
Esempio n. 53
0
def authorize(request):
    amount = 1
    response = None
    if request.method == 'POST':
        form = CreditCardForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            credit_card = CreditCard(**data)
            merchant = get_gateway("authorize_net")
            try:
                merchant.validate_card(credit_card)
            except CardNotSupported:
                response = "Credit Card Not Supported"
            response = merchant.purchase(amount, credit_card)
            #response = merchant.recurring(amount, credit_card)
    else:
        form = CreditCardForm(initial={'number': '4222222222222'})
    return render(request, 'app/index.html', {'form': form,
                                              'amount': amount,
                                              'response': response,
                                              'title': 'Authorize'})
Esempio n. 54
0
def authorize(request):
    amount = 1
    response = None
    if request.method == 'POST':
        form = CreditCardForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            credit_card = CreditCard(**data)
            merchant = get_gateway("authorize_net")
            try:
                merchant.validate_card(credit_card)
            except CardNotSupported:
                response = "Credit Card Not Supported"
            response = merchant.purchase(amount, credit_card)
            #response = merchant.recurring(amount, credit_card)
    else:
        form = CreditCardForm(initial={'number': '4222222222222'})
    return render(request, 'app/index.html', {'form': form,
                                              'amount': amount,
                                              'response': response,
                                              'title': 'Authorize'})
Esempio n. 55
0
def bitcoin_done(request):
    with mock.patch('bitcoinrpc.connection.BitcoinConnection'
                    ) as MockBitcoinConnection:
        connection = MockBitcoinConnection()
        connection.getnewaddress.return_value = BTC_TEST_ADDRESS
        connection.listtransactions.return_value = BTC_TEST_SUCCESSFUL_TXNS
        amount = 0.01
        bitcoin_obj = get_gateway("bitcoin")
        address = request.session.get("bitcoin_address", None)
        if not address:
            return HttpResponseRedirect(reverse("app_bitcoin"))
        result = bitcoin_obj.purchase(amount, address)
        if result['status'] == 'SUCCESS':
            del request.session["bitcoin_address"]
        return render(
            request, "app/bitcoin_done.html", {
                "title": "Bitcoin",
                "amount": amount,
                "address": address,
                "result": result
            })
Esempio n. 56
0
def paypal(request):
    amount = 1
    response = None
    if request.method == 'POST':
        form = CreditCardForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            credit_card = CreditCard(**data)
            merchant = get_gateway("pay_pal")
            try:
                merchant.validate_card(credit_card)
            except CardNotSupported:
                response = "Credit Card Not Supported"
            # response = merchant.purchase(amount, credit_card, options={'request': request})
            response = merchant.recurring(amount, credit_card, options={'request': request})
    else:
        form = CreditCardForm(initial=GATEWAY_INITIAL['paypal'])
    return render(request, 'app/index.html', {'form': form,
                                              'amount': amount,
                                              'response': response,
                                              'title': 'Paypal'})
Esempio n. 57
0
def eway(request):
    amount = 1
    response = None
    if request.method == 'POST':
        form = CreditCardForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            credit_card = CreditCard(**data)
            merchant = get_gateway("eway")
            try:
                merchant.validate_card(credit_card)
            except CardNotSupported:
                response = "Credit Card Not Supported"
            billing_address = {'salutation': 'Mr.',
                               'address1': 'test',
                               'address2': ' street',
                               'city': 'Sydney',
                               'state': 'NSW',
                               'company': 'Test Company',
                               'zip': '2000',
                               'country': 'au',
                               'email': '*****@*****.**',
                               'fax': '0267720000',
                               'phone': '0267720000',
                               'mobile': '0404085992',
                               'customer_ref': 'REF100',
                               'job_desc': 'test',
                               'comments': 'any',
                               'url': 'http://www.google.com.au',
                               }
            response = merchant.purchase(amount, credit_card, options={'request': request, 'billing_address': billing_address})
    else:
        form = CreditCardForm(initial={'number':'4444333322221111',
                                       'verification_value': '000',
                                       'month': 7,
                                       'year': 2012})
    return render(request, 'app/index.html', {'form': form,
                                              'amount': amount,
                                              'response': response,
                                              'title': 'Eway'})
Esempio n. 58
0
 def delete_card(self, id, tenant_id):
     stripe = billing.get_gateway("stripe").stripe
     try:
         card = self.get(
             id__exact=id,
             tenant_id__exact=tenant_id
         )
         stripe_cust = stripe.Customer.retrieve(card.stripe_customer_id)
         stripe_cust.delete()
         card.delete()
         return (True,)
     except stripe.error.StripeError as e:
         # Display a very generic error to the user
         if e.http_status == 404:
             card.delete()
             return (True,)
         return (False, e.message)
     except ObjectDoesNotExist as e:
         return (False, u'Card does not exist')
     except Exception:
         return (False, _("Could not delete card. "
                          "Please try again later"))
Esempio n. 59
0
 def __init__(self):
     super(StripeIntegration, self).__init__()
     self.gateway = get_gateway("stripe")
     self.publishable_key = settings.STRIPE_PUBLISHABLE_KEY