本文整理汇总了Python中paypal.standard.forms.PayPalPaymentsForm.render方法的典型用法代码示例。如果您正苦于以下问题:Python PayPalPaymentsForm.render方法的具体用法?Python PayPalPaymentsForm.render怎么用?Python PayPalPaymentsForm.render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类paypal.standard.forms.PayPalPaymentsForm
的用法示例。
在下文中一共展示了PayPalPaymentsForm.render方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_form_render
# 需要导入模块: from paypal.standard.forms import PayPalPaymentsForm [as 别名]
# 或者: from paypal.standard.forms.PayPalPaymentsForm import render [as 别名]
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)
示例2: product_detail
# 需要导入模块: from paypal.standard.forms import PayPalPaymentsForm [as 别名]
# 或者: from paypal.standard.forms.PayPalPaymentsForm import render [as 别名]
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))
示例3: scientist_research_payment_paypal
# 需要导入模块: from paypal.standard.forms import PayPalPaymentsForm [as 别名]
# 或者: from paypal.standard.forms.PayPalPaymentsForm import render [as 别名]
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))
示例4: paypal_form
# 需要导入模块: from paypal.standard.forms import PayPalPaymentsForm [as 别名]
# 或者: from paypal.standard.forms.PayPalPaymentsForm import render [as 别名]
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')
示例5: paypal_form
# 需要导入模块: from paypal.standard.forms import PayPalPaymentsForm [as 别名]
# 或者: from paypal.standard.forms.PayPalPaymentsForm import render [as 别名]
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
示例6: paypal
# 需要导入模块: from paypal.standard.forms import PayPalPaymentsForm [as 别名]
# 或者: from paypal.standard.forms.PayPalPaymentsForm import render [as 别名]
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)
示例7: checkout
# 需要导入模块: from paypal.standard.forms import PayPalPaymentsForm [as 别名]
# 或者: from paypal.standard.forms.PayPalPaymentsForm import render [as 别名]
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})
示例8: process
# 需要导入模块: from paypal.standard.forms import PayPalPaymentsForm [as 别名]
# 或者: from paypal.standard.forms.PayPalPaymentsForm import render [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()})
示例9: test_form_render_deprecated_paypal_receiver_email
# 需要导入模块: from paypal.standard.forms import PayPalPaymentsForm [as 别名]
# 或者: from paypal.standard.forms.PayPalPaymentsForm import render [as 别名]
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)
示例10: render_page
# 需要导入模块: from paypal.standard.forms import PayPalPaymentsForm [as 别名]
# 或者: from paypal.standard.forms.PayPalPaymentsForm import render [as 别名]
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))
示例11: paypal_standard
# 需要导入模块: from paypal.standard.forms import PayPalPaymentsForm [as 别名]
# 或者: from paypal.standard.forms.PayPalPaymentsForm import render [as 别名]
def paypal_standard(request):
ipn_url = 'http://%s%s' % (Site.objects.get_current().domain, reverse("paypal-ipn"))
pdt_url = 'http://%s%s' % (Site.objects.get_current().domain, reverse("paypal-pdt"))
return_url = pdt_url if config.PDT else ipn_url
data = {
"amount": "1.00",
"item_name": "Samsung Galaxy S3",
"invoice": "INVOICE001",
"notify_url": ipn_url,
"return_url": return_url,
}
form = PayPalPaymentsForm(initial=data)
data['form'] = form.sandbox() if config.DEBUG else form.render()
return render_to_response("payment/paypal/standard.html", data,
context_instance=RequestContext(request))
示例12: get_context_data
# 需要导入模块: from paypal.standard.forms import PayPalPaymentsForm [as 别名]
# 或者: from paypal.standard.forms.PayPalPaymentsForm import render [as 别名]
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
示例13: carga
# 需要导入模块: from paypal.standard.forms import PayPalPaymentsForm [as 别名]
# 或者: from paypal.standard.forms.PayPalPaymentsForm import render [as 别名]
def carga(request, pago_id):
pago=get_object_or_404(Pagos, pk=pago_id)
usuario_pago=Usuarios_Pagos.objects.get(usuario=request.user, pago=pago)
paypal_dict = {
# "business": settings.PAYPAL_RECEIVER_EMAIL,
"business": pago.correo,
"amount": pago.get_precio,
"item_name": pago.concepto,
"invoice": "pagos_family" + str(pago.id)+"_"+str(request.user.id),
"notify_url": "%s%s" % (SITE_NAME, reverse('paypal-ipn')),
"return_url": "http://joinity.com/",
"cancel_return": "http://joinity.com/",
"custom": usuario_pago.id,
"currency_code": "EUR", # currency
}
form = PayPalPaymentsForm(initial=paypal_dict)
context={"pago":pago, "form":form.render(), "usuario":request.user}
pagina_pago=render_to_string("joinitys/pagos/ajax_ver_pago.html", context)
return simplejson.dumps({"pago":pagina_pago})
示例14: paypal
# 需要导入模块: from paypal.standard.forms import PayPalPaymentsForm [as 别名]
# 或者: from paypal.standard.forms.PayPalPaymentsForm import render [as 别名]
def paypal(request, treatment_id):
# What you want the button to do.
try:
treatment = Treatment.objects.get(id=treatment_id)
except:
raise Http404
treatment_price = system.GET_TREATMENT_PRICE()
treatment_time = system.GET_TREATMENT_TIME_LIMIT()
paypal_dict = {
"business": settings.PAYPAL_RECEIVER_EMAIL,
"charset": "utf-8",
"amount": "%s" % treatment_price,
"item_name": u"Avaliação e Orientação Dermatológica",
"custom": treatment_id,
"invoice": treatment_id,
"notify_url": "%s%s" % (settings.SITE_NAME, reverse('paypal-ipn')),
"return_url": "%s%s" % (settings.SITE_NAME, reverse('paypalreturn')),
"cancel_return": "%s%s" % (settings.SITE_NAME, reverse('paypal-cancel-return')),
}
# Create the instance.
paypal_form = PayPalPaymentsForm(initial=paypal_dict)
free_treatments = system.GET_FREE_TREATMENTS()
if settings.PAYPAL_TEST:
paypal_form = paypal_form.sandbox()
else:
paypal_form = paypal_form.render()
context = {"paypal_form": paypal_form, "treatment": treatment, "treatment_time": treatment_time, "free_treatments": free_treatments}
return render_to_response("treatments/checkout.html", context, context_instance=RequestContext(request))
from paypal.pro.views import PayPalPro
示例15: donate
# 需要导入模块: from paypal.standard.forms import PayPalPaymentsForm [as 别名]
# 或者: from paypal.standard.forms.PayPalPaymentsForm import render [as 别名]
def donate(request, p, engine):
if not can_accept_donations(p):
return redirect("project-main", project_id=p.id)
is_test_donation = getattr(settings, "DONATION_TEST", False)
if request.method == "POST":
donate_form = InvoiceForm(data=request.POST, project=p, engine=engine)
if donate_form.is_valid():
description = u"Akvo-%d-%s" % (p.id, p.title)
cd = donate_form.cleaned_data
invoice = donate_form.save(commit=False)
invoice.project = p
invoice.engine = engine
invoice.name = cd["name"]
invoice.email = cd["email"]
invoice.campaign_code = cd["campaign_code"]
invoice.is_anonymous = not cd["is_public"]
original_http_referer = request.session.get("original_http_referer", None)
if original_http_referer:
invoice.http_referer = original_http_referer
del request.session["original_http_referer"]
else:
invoice.http_referer = request.META.get("HTTP_REFERER", None)
if is_test_donation:
invoice.test = True
if request.session.get("donation_return_url", False):
return_url = urljoin(request.session["donation_return_url"],
reverse("donate_thanks"))
else:
return_url = urljoin(request.META['HTTP_ORIGIN'], reverse("donate_thanks"))
if engine == "ideal":
invoice.bank = cd["bank"]
mollie_dict = dict(
amount=invoice.amount * 100,
bank_id=invoice.bank,
partnerid=invoice.gateway,
description=description,
reporturl=urljoin(request.META['HTTP_ORIGIN'], reverse("mollie_report")),
returnurl=return_url)
try:
mollie_response = query_mollie(mollie_dict, "fetch")
invoice.transaction_id = mollie_response["transaction_id"]
order_url = mollie_response["order_url"]
invoice.save()
except:
return redirect("donate_500")
return render_to_response("donate/donate_step3.html",
dict(invoice=invoice,
project=p,
payment_engine=engine,
mollie_order_url=order_url),
context_instance=RequestContext(request))
elif engine == "paypal":
invoice.save()
pp_dict = dict(
cmd="_donations",
currency_code=invoice.currency,
business=invoice.gateway,
amount=invoice.amount,
item_name=description,
invoice=int(invoice.id),
lc=invoice.locale,
notify_url=urljoin(request.META['HTTP_ORIGIN'], reverse("paypal_ipn")),
return_url=return_url,
cancel_url=request.META['HTTP_ORIGIN'])
pp_form = PayPalPaymentsForm(initial=pp_dict)
if is_test_donation:
pp_button = pp_form.sandbox()
else:
pp_button = pp_form.render()
return render_to_response("donate/donate_step3.html",
dict(invoice=invoice,
payment_engine=engine,
pp_form=pp_form,
pp_button=pp_button,
project=p),
context_instance=RequestContext(request))
else:
invoice_id = request.GET.get("invoice_id", None)
if not invoice_id:
donate_form = InvoiceForm(project=p,
engine=engine,
initial=dict(is_public=True))
else:
invoice = get_object_or_404(Invoice, pk=invoice_id)
donate_form = InvoiceForm(project=p,
engine=engine,
initial=dict(amount=invoice.amount,
name=invoice.name,
email=invoice.email,
email2=invoice.email,
campaign_code=invoice.campaign_code,
is_public=not invoice.is_anonymous))
if request.session.get("donation_return_url", False):
request.session["cancel_url"] = urljoin(request.session["donation_return_url"],
reverse("project-main",
kwargs={'project_id': p.id}))
else:
request.session["cancel_url"] = reverse("project-main", kwargs={'project_id': p.id})
return render_to_response("donate/donate_step2.html",
dict(donate_form=donate_form,
#.........这里部分代码省略.........