本文整理汇总了Python中app.forms.CreditCardForm.is_valid方法的典型用法代码示例。如果您正苦于以下问题:Python CreditCardForm.is_valid方法的具体用法?Python CreditCardForm.is_valid怎么用?Python CreditCardForm.is_valid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app.forms.CreditCardForm
的用法示例。
在下文中一共展示了CreditCardForm.is_valid方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: paylane
# 需要导入模块: from app.forms import CreditCardForm [as 别名]
# 或者: from app.forms.CreditCardForm import is_valid [as 别名]
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 = "[email protected]"
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'})
示例2: beanstream
# 需要导入模块: from app.forms import CreditCardForm [as 别名]
# 或者: from app.forms.CreditCardForm import is_valid [as 别名]
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": "[email protected]",
"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'})
示例3: paypal
# 需要导入模块: from app.forms import CreditCardForm [as 别名]
# 或者: from app.forms.CreditCardForm import is_valid [as 别名]
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'})
示例4: stripe
# 需要导入模块: from app.forms import CreditCardForm [as 别名]
# 或者: from app.forms.CreditCardForm import is_valid [as 别名]
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'})
示例5: samurai
# 需要导入模块: from app.forms import CreditCardForm [as 别名]
# 或者: from app.forms.CreditCardForm import is_valid [as 别名]
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'})
示例6: authorize
# 需要导入模块: from app.forms import CreditCardForm [as 别名]
# 或者: from app.forms.CreditCardForm import is_valid [as 别名]
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'})
示例7: chargebee
# 需要导入模块: from app.forms import CreditCardForm [as 别名]
# 或者: from app.forms.CreditCardForm import is_valid [as 别名]
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'})
示例8: braintree
# 需要导入模块: from app.forms import CreditCardForm [as 别名]
# 或者: from app.forms.CreditCardForm import is_valid [as 别名]
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)'})
示例9: paypal
# 需要导入模块: from app.forms import CreditCardForm [as 别名]
# 或者: from app.forms.CreditCardForm import is_valid [as 别名]
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'})
示例10: authorize
# 需要导入模块: from app.forms import CreditCardForm [as 别名]
# 或者: from app.forms.CreditCardForm import is_valid [as 别名]
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'})
示例11: eway
# 需要导入模块: from app.forms import CreditCardForm [as 别名]
# 或者: from app.forms.CreditCardForm import is_valid [as 别名]
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': '[email protected]',
'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'})