当前位置: 首页>>代码示例>>Python>>正文


Python forms.PayPalPaymentsForm类代码示例

本文整理汇总了Python中paypal.standard.forms.PayPalPaymentsForm的典型用法代码示例。如果您正苦于以下问题:Python PayPalPaymentsForm类的具体用法?Python PayPalPaymentsForm怎么用?Python PayPalPaymentsForm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PayPalPaymentsForm类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: process

    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,代码行数:28,代码来源:payments.py

示例2: scientist_research_payment_paypal

def scientist_research_payment_paypal(request, research_id, template='scientist/research_payment_paypal.html',
                                      extra_context=None):
    research = get_object_or_404(Research, id=research_id, scientistresearch__scientist=request.user)

    # What you want the button to do.
    paypal_dict = {
        'business': settings.PAYPAL_RECEIVER_EMAIL,
        'amount': research.total_credit - request.user.userprofile.available_balance,
        'item_name': research.name,
        'invoice': '%s-%d' % (research.name, research.id),
        'notify_url': '%s%s' % (settings.SITE_NAME, reverse_lazy('paypal-ipn')),
        'return_url': '%s%s' % (settings.SITE_NAME, reverse_lazy('research_paypal_complete', args=[research.id, ])),
        'cancel_return': 'http://www.example.com/your-cancel-location/',
        'custom': research.id,
    }

    # Create the instance.
    form = PayPalPaymentsForm(initial=paypal_dict)
    if settings.PAYPAL_API_ENVIRONMENT == 'SANDBOX':
        paypal_form = form.sandbox()
    else:
        paypal_form = form.render()

    context = {
        'form': paypal_form,
        'research': research,
    }

    if extra_context:
        context.update(extra_context)
    return render_to_response(template, context, context_instance=RequestContext(request))
开发者ID:ContributeToScience,项目名称:participant-booking-app,代码行数:31,代码来源:views.py

示例3: paypal_form

def paypal_form(order):
    # res = {}
    paypal = {
        "business": settings.PAYPAL_RECEIVER_EMAIL,
        "amount": order.total(),
        "item_name": settings.PAYPAL_SUBJECT_LINE,
        #'item_number': 1,
        #'quantity':1,
        # PayPal wants a unique invoice ID
        "invoice": order.uid,
        # It'll be a good idea to setup a SITE_DOMAIN inside settings
        # so you don't need to hardcode these values.
        "currency_code": "EUR",
        "lc": "es_ES",
        #'notify_url': settings.SITE_DOMAIN + "/tienda/checkout/paypal/ipn",
        "notify_url": settings.SITE_DOMAIN + reverse("paypal-ipn"),
        "return_url": settings.SITE_DOMAIN + reverse("return_url"),
        "cancel_return": settings.SITE_DOMAIN + reverse("cancel_url"),
    }
    form = PayPalPaymentsForm(initial=paypal)
    if settings.DEBUG:
        rendered_form = form.sandbox()
    else:
        rendered_form = form.render()
    return rendered_form
开发者ID:hnejadi,项目名称:django_tiny_shop,代码行数:25,代码来源:__init__.py

示例4: checkout

def checkout(request):
    # 订单号
    out_trade_no = baseutil.time_hash()

    cart = Cart(request)
    # 关闭cart购物车,防止付款之前购物车内内容改变
    cart.cart.checked_out=True
    cart.cart.save()
    # 记录transaction
    now = datetime.datetime.now()
    Transaction.objects.create(out_trade_no=out_trade_no,user=request.user,\
            cart=cart.cart,payed_fee=0,trade_time=now)

   # What you want the button to do.
    paypal_dict = {
            "business": settings.PAYPAL_RECEIVER_EMAIL,
            "amount": (cart.total_fee)/5, # exchange rate is 5
            "item_name": "Bluessh ssh+vpn fee",
            "invoice": out_trade_no, # 本站订单号
            "notify_url": "%s%s" % (settings.SITE_URL, '/paypal/ipn_pengzhao/'),
            "return_url": "%s/usercenter/" % settings.SITE_URL,
            "currency_code":"USD", # 人民币CNY,美元USD
            "charset":"utf-8",
            }

    paypal_form = PayPalPaymentsForm(initial=paypal_dict)
    submit_js = "<script>document.forms['paypalsubmit'].submit()</script>"
    return render(request,'usercenter/checkout.html',
                  {'content':paypal_form.render(),'submit_js':submit_js})
开发者ID:ferrolad,项目名称:bluessh,代码行数:29,代码来源:views.py

示例5: paypal

def paypal(request):

    # What you want the button to do.

    paypal_dict = {
                   "cmd": "_xclick-subscriptions",
                   "a1": "0",     # trial price 
                   "p1": 1,     # trial duration, duration of unit defaults to month 
                   "a3": "1", # yearly price 
                   "p3": 1, # duration of each unit (depends on unit) 
                   "t3": "Y", # duration unit ("M for Month") 
                   "src": "1", # make payments recur 
                   "sra": "1", # reattempt payment on payment error 
                   "no_note": "1", # remove extra notes (optional)        
        
                   "business": settings.PAYPAL_RECEIVER_EMAIL,
                   #"amount": "1.00",
                   "item_name": "one Bondiz",
                   "invoice": "99",
                   "notify_url": "%s%s" % (settings.SITE_NAME, reverse('paypal-ipn')),
                   "return_url": "http://www.bondiz.com/success/",
                   "cancel_return": "http://www.bondiz.com/cancel/",
    }

    # Create the instance.
    form = PayPalPaymentsForm(initial=paypal_dict, button_type="subscribe") 
    context = {"form": form.render()} # form.render() for real case
    return render_to_response("paypal.html", context)
开发者ID:AndreiDev,项目名称:Bondiz,代码行数:28,代码来源:views.py

示例6: paypal_form

def paypal_form(request):
    domain = Site.objects.get_current().domain
    
    paypal_dict = {
        "cmd": "_xclick-subscriptions",
        "business": "[email protected]",
        # "business": "[email protected]",
        "a3": "12.00",                     # price 
        "p3": 1,                           # duration of each unit (depends on unit)
        "t3": "Y",                         # duration unit ("M for Month")
        "src": "1",                        # make payments recur
        "sra": "1",                        # reattempt payment on payment error
        "no_note": "1",                    # remove extra notes (optional)
        "item_name": "NewsBlur Premium Account",
        "notify_url": "http://%s%s" % (domain, reverse('paypal-ipn')),
        "return_url": "http://%s%s" % (domain, reverse('paypal-return')),
        "cancel_return": "http://%s%s" % (domain, reverse('index')),
        "custom": request.user.username,
    }

    # Create the instance.
    form = PayPalPaymentsForm(initial=paypal_dict, button_type="subscribe")

    # Output the button.
    return HttpResponse(form.render(), mimetype='text/html')
开发者ID:adamjernst,项目名称:NewsBlur,代码行数:25,代码来源:views.py

示例7: product_detail

def product_detail(request, slug):
    '''
    It is a smaple funcation that could be used to send only one item to
    Paypal. it will send the information of the select  product to be paied
    in Paypal.
    '''
    product = get_object_or_404(Product, pk=slug)
    paypal = {
        'amount': product.price,
        'item_name': product.name,
        'item_number': product.slug,
        
        # PayPal wants a unique invoice ID
        'invoice': str(uuid.uuid1()), 
        
        # It'll be a good idea to setup a SITE_DOMAIN inside settings
        # so you don't need to hardcode these values.
        'return_url': settings.SITE_DOMAIN + 'return_url', #reverse('return_url'),
        'cancel_return': settings.SITE_DOMAIN + 'cancel_url', #reverse('cancel_url'),
    }
    form = PayPalPaymentsForm(initial=paypal)
    if settings.DEBUG:
        rendered_form = form.sandbox()
    else:
        rendered_form = form.render()
    return render_to_response('products/product_detail.html', {
        'product' : product,
        'form' : rendered_form,
    }, RequestContext(request))
开发者ID:HeisSuperHan,项目名称:djangoShop,代码行数:29,代码来源:views.py

示例8: test_form_render

    def test_form_render(self):
        return_url = 'https://example.com/return_url'

        f = PayPalPaymentsForm(initial={'business': '[email protected]',
                                        'amount': '10.50',
                                        'shipping': '2.00',
                                        'return_url': return_url,
                                        })
        rendered = f.render()
        self.assertIn('''action="https://www.sandbox.paypal.com/cgi-bin/webscr"''', rendered)
        self.assertIn('''value="[email protected]"''', rendered)
        self.assertIn('''value="2.00"''', rendered)
        self.assertIn('''value="10.50"''', rendered)
        self.assertIn('''buynowCC''', rendered)
        self.assertIn('''value="''' + return_url + '''"''', rendered)

        f = PayPalPaymentsForm(initial={'business': '[email protected]',
                                        'amount': '10.50',
                                        'shipping': '2.00',
                                        'return': return_url,
                                        })
        rendered = f.render()
        self.assertIn('''action="https://www.sandbox.paypal.com/cgi-bin/webscr"''', rendered)
        self.assertIn('''value="[email protected]"''', rendered)
        self.assertIn('''value="2.00"''', rendered)
        self.assertIn('''value="10.50"''', rendered)
        self.assertIn('''buynowCC''', rendered)
        self.assertIn('''value="''' + return_url + '''"''', rendered)
开发者ID:rsalmaso,项目名称:django-paypal,代码行数:28,代码来源:test_forms.py

示例9: test_form_render_deprecated_paypal_receiver_email

 def test_form_render_deprecated_paypal_receiver_email(self):
     f = PayPalPaymentsForm(initial={'amount': '10.50',
                                     'shipping': '2.00',
                                     })
     rendered = f.render()
     self.assertIn('''action="https://www.sandbox.paypal.com/cgi-bin/webscr"''', rendered)
     self.assertIn('''value="[email protected]"''', rendered)
     self.assertIn('''value="2.00"''', rendered)
     self.assertIn('''value="10.50"''', rendered)
     self.assertIn('''buynowCC''', rendered)
开发者ID:RulongWang,项目名称:django-paypal,代码行数:10,代码来源:test_forms.py

示例10: ServicesPayment

def ServicesPayment(request, serviceId, csrf, payStatus, date_created):

    import datetime
    import time

    service = Service.objects.all().get(id=int(serviceId))
    user = request.user
    if date_created == "0":
        date_created = str(time.time())
    invoice_number = date_created + '-service-' + str(serviceId) + "-" \
                     + str(user.id)

    paypal_dict = {
        "business": settings.PAYPAL_RECEIVER_EMAIL,
        "amount": service.service_cost,
        "item_name": service.name,
        "invoice": invoice_number,
        "notify_url": "%s%s" % (settings.SITE_NAME, reverse('paypal-ipn')),
        "return_url": settings.SITE_NAME + "/paypal/payment/service/"
                      + serviceId + "/1/" + csrf + "/" + date_created + "/",
        "cancel_return": settings.SITE_NAME + "/paypal/payment/service/"
                         + serviceId + "/0/" + csrf + "/" + date_created + "/",
    }

    if payStatus == "2":
        if len(Invoice.objects.all().filter(number=invoice_number)) > 0:
            payStatus = "3"
        else:
            dateTime = datetime.datetime.\
                fromtimestamp(float(date_created)/1000)
            i = Invoice.objects.create(date_created=dateTime, service=service,
                                       buyer=user, amount=1, is_paid=False,
                                       number=invoice_number)
            i.save()
    if payStatus == "1":
        if len(Invoice.objects.all().filter(number=invoice_number)) == 0:
            payStatus = "3"
        else:
            i = Invoice.objects.all().get(number=invoice_number)
            i.is_paid = True
            i.save()
    if payStatus == "0":
        if len(Invoice.objects.all().filter(number=invoice_number)) == 0:
            payStatus = "3"
        else:
            i = Invoice.objects.all().get(number=invoice_number)
            i.is_paid = False
            i.save()

    form = PayPalPaymentsForm(initial=paypal_dict)
    context = {"form": form.sandbox(), "service": service,
               "payStatus": payStatus, "invoice_number": invoice_number,
               "date_created": date_created, "serviceId": serviceId, }

    return render_with_user(request, "paypal/payment.html", context)
开发者ID:qysnolan,项目名称:ChoiceNet,代码行数:55,代码来源:views.py

示例11: render_page

 def render_page(request, order, selectdiscountform=None, claimdiscountform=None, dropforms=None):
     context = {}
     if float(order.get_full_price()) < 0.01: # Free service. Don't show discount forms. Clear coupons so they are not wasted.
         context['show_discounts'] = False
         order.reset_discount_claims()
         order.save()
     else:
         context['show_discounts'] = True
         # Define forms for managing discounts on order
         if not dropforms:
             dropforms = [];
             for claim in order.get_discount_claims():
                 dropforms.append({
                         'label': claim.discount.display_text, 
                         'form': coupons.forms.RemoveDiscountForm(initial={u'discount': claim.pk})
                         })
         context['dropforms'] = dropforms
         if not selectdiscountform:
             available_claims = order.get_unused_discount_claims()
             if available_claims:
                 selectdiscountform = coupons.forms.SelectDiscountForm(request.user, available_claims=available_claims)
             else:
                 selectdiscountform = None
         context['selectdiscountform'] = selectdiscountform
         if not claimdiscountform:
             claimdiscountform = coupons.forms.ClaimOrSelectDiscountForm(request.user)
         context['claimdiscountform'] = claimdiscountform
     # Define invoice data
     invoice = order.calculate_price()
     order.save()
     context['invoice'] = invoice
     if float(order.get_amount_to_pay()) < 0.01: # No payment due. Free service or 100% covered with discounts
         context['paid_service'] = False
         return render_to_response("order/submit_payment.html", RequestContext(request, context))
     else:
         context['paid_service'] = True
         # paypal button
         paypal_dict = {
             "business": settings.PAYPAL_RECEIVER_EMAIL,
             "amount": invoice['amount_due'],
             "item_name": order.get_service_description(),
             "invoice": order.invoice_id,
             "notify_url": "%s%s" % (settings.ROOT_URL, reverse('paypal-ipn')),
             "return_url": "%s%s" % (settings.ROOT_URL, 'paymentreceived/'),
             "cancel_return": "%s%s" % (settings.ROOT_URL, 'paymentcanceled/'),
             }
         form = PayPalPaymentsForm(initial=paypal_dict)
         if settings.RACK_ENV=='production':
             context["pay_button"] = form.render()
         else:
             context["pay_button"] = form.sandbox()
         context["pay_button_message"] = mark_safe(_('Clicking the "Buy Now" button will submit your order and take you away from this site.')+'<br/>'+_('Please complete your secure payment with PayPal.'))
         return render_to_response("order/submit_payment.html", RequestContext(request, context))
开发者ID:nhammond,项目名称:swe,代码行数:53,代码来源:views.py

示例12: paypal

def paypal(request):
# What you want the button to do.
    paypal_dict = {
    "business": settings.PAYPAL_RECEIVER_EMAIL,
    "amount": "1.00",
    "item_name": "name of the item",
    "invoice": "unique-invoice-id",
    "notify_url": "%s%s" % (settings.SITE_NAME, reverse('paypal-ipn')),
    "return_url": "http://www.example.com/your-return-location/",
    "cancel_return": "http://www.example.com/your-cancel-location/",}
# Create the instance.
    form = PayPalPaymentsForm(initial=paypal_dict)
    context = {"form": form.sandbox()}
    return render_to_response("paypal.html", context)
开发者ID:shahfaizanali,项目名称:musey,代码行数:14,代码来源:views.py

示例13: view_ask_money_ipn

def view_ask_money_ipn(request):
	# What you want the button to do.
	paypal_dict = {
			"business":settings.PAYPAL_RECEIVER_EMAIL,
			"amount":"0.01",
			"item_name":"Ttagit Pro Account",
			"invoice":"unique-invoice-id",
			"notify_url":"http://dev.ttagit.com/paypal-ipn",
			"return_url":"http://dev.ttagit.com/paypal/pdt/",
			"cancel_return":"",
	}

	form = PayPalPaymentsForm(initial=paypal_dict)
	context = {"form":form.sandbox()}
	return render_to_response("payment.html", context)
开发者ID:JackWu,项目名称:djangoSample,代码行数:15,代码来源:views.py

示例14: view_that_asks_for_money

def view_that_asks_for_money(request):

    # What you want the button to do.
    paypal_dict = {
        "business": settings.PAYPAL_RECEIVER_EMAIL,
        "amount": "1.00",
        "item_name": "name of the item",
        "invoice": "unique-invoice-id",
        "notify_url": "%s%s" % (settings.SITE_NAME, reverse('paypal-ipn')),
        "return_url": "http://0.0.0.0:8008/hello/",
        "cancel_return": "http://0.0.0.0:8008/hello/",
    }

    # Create the instance.
    form = PayPalPaymentsForm(initial=paypal_dict)
    context = {"form": form.sandbox(), "productID": request.POST["productID"]}
    return render_with_user(request, "paypal/payment.html", context)
开发者ID:qysnolan,项目名称:ChoiceNet,代码行数:17,代码来源:views.py

示例15: get_context_data

 def get_context_data(self, **kwargs):
     context = super(MerchDetailView, self).get_context_data(**kwargs)
     merch = context['merch']
     paypal = {
         'amount': merch.price,
         'item_name': merch.title,
         'item_number': merch.slug,
         'currency_code': 'GBP',
         
         # PayPal wants a unique invoice ID
         'invoice': str(uuid.uuid4()),
         
         'return_url': '/merch/thanks',
         'cancel_return': merch.get_absolute_url(),
     }
     form = PayPalPaymentsForm(initial=paypal)
     context['form'] = form.sandbox() if settings.DEBUG else form.render()
     return context
开发者ID:G53NMD-3,项目名称:longdeadsignal,代码行数:18,代码来源:views.py


注:本文中的paypal.standard.forms.PayPalPaymentsForm类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。