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' })
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' })
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'})
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")
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")
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))
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))
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")
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'})
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")
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")
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")
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'})
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
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
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
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"]
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 __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']
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")
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')
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')
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")
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 })
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')
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 })
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')
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
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' })
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 })
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'})
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 })
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'})
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'})
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')
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 })
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' })
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'})
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 })
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 })
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)'})
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'})
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 })
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'})
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'})
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"))
def __init__(self): super(StripeIntegration, self).__init__() self.gateway = get_gateway("stripe") self.publishable_key = settings.STRIPE_PUBLISHABLE_KEY