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 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={'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 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 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 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 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 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 = AuthorizeNetGateway() # 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 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 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 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 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 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 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'})