本文整理汇总了Python中paypal.standard.forms.PayPalPaymentsForm.fields['quantity_1']方法的典型用法代码示例。如果您正苦于以下问题:Python PayPalPaymentsForm.fields['quantity_1']方法的具体用法?Python PayPalPaymentsForm.fields['quantity_1']怎么用?Python PayPalPaymentsForm.fields['quantity_1']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类paypal.standard.forms.PayPalPaymentsForm
的用法示例。
在下文中一共展示了PayPalPaymentsForm.fields['quantity_1']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process
# 需要导入模块: from paypal.standard.forms import PayPalPaymentsForm [as 别名]
# 或者: from paypal.standard.forms.PayPalPaymentsForm import fields['quantity_1'] [as 别名]
def process(self,request,cart=None):
for k,v in request.REQUEST.iteritems():
if 'product' in k: product = v
elif 'value' in k: value = float(v)
elif 'qty' in k: qty = int(v)
host = 'http://%s' % request.get_host()
paypal = {
'business': settings.PAYPAL_RECEIVER_EMAIL,
'notify_url': '%s%s'%(host,settings.PAYPAL_NOTIFY_URL),
'return_url': '%s%s'%(host,settings.PAYPAL_RETURN_URL),
'cancel_return': '%s%s'%(host,settings.PAYPAL_CANCEL_RETURN),
'currency_code': 'BRL',
}
option = '_cart'; count = 0
form_paypal = PayPalPaymentsForm(initial=paypal)
if cart is not None:
for p in cart:
count += 1
form_paypal.fields['amount_%i'%count] = forms.IntegerField(widget=ValueHiddenInput(),initial=p['value'])
form_paypal.fields['item_name_%i'%count] = forms.CharField(widget=ValueHiddenInput(),initial=p['product'])
form_paypal.fields['quantity_%i'%count] = forms.CharField(widget=ValueHiddenInput(),initial=p['qty'])
else:
form_paypal.fields['amount_1'] = forms.IntegerField(widget=ValueHiddenInput(),initial=value)
form_paypal.fields['item_name_1'] = forms.CharField(widget=ValueHiddenInput(),initial=product)
form_paypal.fields['quantity_1'] = forms.CharField(widget=ValueHiddenInput(),initial=str(qty))
form_paypal.fields['cmd'] = forms.CharField(widget=ValueHiddenInput(),initial=option)
form_paypal.fields['upload'] = forms.CharField(widget=ValueHiddenInput(),initial='1')
return render(request,'form.jade',{'form':form_paypal.render()})