本文整理匯總了Python中paypal.standard.forms.PayPalPaymentsForm.fields['item_name_%i'%count]方法的典型用法代碼示例。如果您正苦於以下問題:Python PayPalPaymentsForm.fields['item_name_%i'%count]方法的具體用法?Python PayPalPaymentsForm.fields['item_name_%i'%count]怎麽用?Python PayPalPaymentsForm.fields['item_name_%i'%count]使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類paypal.standard.forms.PayPalPaymentsForm
的用法示例。
在下文中一共展示了PayPalPaymentsForm.fields['item_name_%i'%count]方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: process
# 需要導入模塊: from paypal.standard.forms import PayPalPaymentsForm [as 別名]
# 或者: from paypal.standard.forms.PayPalPaymentsForm import fields['item_name_%i'%count] [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()})