當前位置: 首頁>>代碼示例>>Python>>正文


Python PayPalPaymentsForm.fields['upload']方法代碼示例

本文整理匯總了Python中paypal.standard.forms.PayPalPaymentsForm.fields['upload']方法的典型用法代碼示例。如果您正苦於以下問題:Python PayPalPaymentsForm.fields['upload']方法的具體用法?Python PayPalPaymentsForm.fields['upload']怎麽用?Python PayPalPaymentsForm.fields['upload']使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在paypal.standard.forms.PayPalPaymentsForm的用法示例。


在下文中一共展示了PayPalPaymentsForm.fields['upload']方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: process

# 需要導入模塊: from paypal.standard.forms import PayPalPaymentsForm [as 別名]
# 或者: from paypal.standard.forms.PayPalPaymentsForm import fields['upload'] [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()})
開發者ID:fabricadeideias,項目名稱:hub,代碼行數:30,代碼來源:payments.py


注:本文中的paypal.standard.forms.PayPalPaymentsForm.fields['upload']方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。