本文整理汇总了Python中paypal.standard.forms.PayPalPaymentsForm.sandbox方法的典型用法代码示例。如果您正苦于以下问题:Python PayPalPaymentsForm.sandbox方法的具体用法?Python PayPalPaymentsForm.sandbox怎么用?Python PayPalPaymentsForm.sandbox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类paypal.standard.forms.PayPalPaymentsForm
的用法示例。
在下文中一共展示了PayPalPaymentsForm.sandbox方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: scientist_research_payment_paypal
# 需要导入模块: from paypal.standard.forms import PayPalPaymentsForm [as 别名]
# 或者: from paypal.standard.forms.PayPalPaymentsForm import sandbox [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))
示例2: paypal_form
# 需要导入模块: from paypal.standard.forms import PayPalPaymentsForm [as 别名]
# 或者: from paypal.standard.forms.PayPalPaymentsForm import sandbox [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
示例3: product_detail
# 需要导入模块: from paypal.standard.forms import PayPalPaymentsForm [as 别名]
# 或者: from paypal.standard.forms.PayPalPaymentsForm import sandbox [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))
示例4: ServicesPayment
# 需要导入模块: from paypal.standard.forms import PayPalPaymentsForm [as 别名]
# 或者: from paypal.standard.forms.PayPalPaymentsForm import sandbox [as 别名]
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)
示例5: render_page
# 需要导入模块: from paypal.standard.forms import PayPalPaymentsForm [as 别名]
# 或者: from paypal.standard.forms.PayPalPaymentsForm import sandbox [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))
示例6: paypal
# 需要导入模块: from paypal.standard.forms import PayPalPaymentsForm [as 别名]
# 或者: from paypal.standard.forms.PayPalPaymentsForm import sandbox [as 别名]
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)
示例7: view_ask_money_ipn
# 需要导入模块: from paypal.standard.forms import PayPalPaymentsForm [as 别名]
# 或者: from paypal.standard.forms.PayPalPaymentsForm import sandbox [as 别名]
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)
示例8: view_that_asks_for_money
# 需要导入模块: from paypal.standard.forms import PayPalPaymentsForm [as 别名]
# 或者: from paypal.standard.forms.PayPalPaymentsForm import sandbox [as 别名]
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)
示例9: get_context_data
# 需要导入模块: from paypal.standard.forms import PayPalPaymentsForm [as 别名]
# 或者: from paypal.standard.forms.PayPalPaymentsForm import sandbox [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
示例10: paypal_standard
# 需要导入模块: from paypal.standard.forms import PayPalPaymentsForm [as 别名]
# 或者: from paypal.standard.forms.PayPalPaymentsForm import sandbox [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))
示例11: paypal
# 需要导入模块: from paypal.standard.forms import PayPalPaymentsForm [as 别名]
# 或者: from paypal.standard.forms.PayPalPaymentsForm import sandbox [as 别名]
def paypal(request, publisher_id, product_id):
# What you want the button to do.
productchoice = Product.objects.get(id=product_id)
publisher = Publisher.objects.get(id=publisher_id)
paypal_dict = {
"business": settings.PAYPAL_RECEIVER_EMAIL,
"amount": "%.2f" % productchoice.product_cost,
"item_name": "%s" % productchoice.product_type,
"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(), "productchoice": productchoice}
return render_to_response("signup/paypal.html", context)
示例12: try_paypal
# 需要导入模块: from paypal.standard.forms import PayPalPaymentsForm [as 别名]
# 或者: from paypal.standard.forms.PayPalPaymentsForm import sandbox [as 别名]
def try_paypal(request):
paypal_dict = {
"business": settings.PAYPAL_RECEIVER_EMAIL,
"amount": "1.00", # amount to charge for item
"invoice": datetime.now(), # unique tracking variable paypal
"item_name": "Cipő",
"notify_url": "%s%s" % (settings.SITE_NAME, "atyalapatyala"),
"cancel_return": "%s/try_paypal_cancel" % settings.SITE_NAME, # Express checkout cancel url
"return_url": "%s/try_paypal_success" % settings.SITE_NAME} # Express checkout return url
# kw = {"item": item, # what you're selling
# "payment_template": "try_paypal.html", # template name for payment
# "confirm_template": "try_paypal_confirmation.html", # template name for confirmation
# "success_url": "/try_paypal_success/"} # redirect location after success
#ppp = PayPalPro(**kw)
#return ppp(request)
form = PayPalPaymentsForm(initial=paypal_dict)
context = {"form": form.sandbox()}
return render(request, "try_paypal.html", context)
示例13: view_ask_money_pdt
# 需要导入模块: from paypal.standard.forms import PayPalPaymentsForm [as 别名]
# 或者: from paypal.standard.forms.PayPalPaymentsForm import sandbox [as 别名]
def view_ask_money_pdt(request):
# What you want the button to do.
access_token = ''
if request.COOKIES.has_key('access_token'):
access_token = str(request.COOKIES['access_token'])
else:
#print 'redirect user to the sign in page'
#redirect user to the sign_in page
_redirect = True
paypal_dict = {
"business":settings.PAYPAL_RECEIVER_EMAIL,
"item_number": access_token,
"item_name":"Ttagit Credits",
"notify_url": paths.HTTPS+request.get_host() + "/3f2cf0fe3d994fb8dfe6d8f9g2h5",
"return_url": paths.HTTPS+request.get_host() + "/paypal/pdt/",
"cancel_return": paths.HTTPS+request.get_host()+ "/cancel",
}
form = PayPalPaymentsForm(initial=paypal_dict)
context = {"form":form.sandbox()}
return render_to_response("payment.html", context)
示例14: image_show
# 需要导入模块: from paypal.standard.forms import PayPalPaymentsForm [as 别名]
# 或者: from paypal.standard.forms.PayPalPaymentsForm import sandbox [as 别名]
def image_show(request, image):
try:
colorscheme = ColorScheme.objects.get(use_for_galleries=True)
except ColorScheme.DoesNotExist:
colorscheme = None
try:
bgimage = BackgroundImage.objects.get(use_for_galleries=True)
except BackgroundImage.DoesNotExist:
bgimage = None
image = get_object_or_404(models.Image, title_slug=image)
gallery = image.gallery
# Paypal form info
mysite = Site.objects.get_current()
domain = mysite.domain
paypal_dict = {
"business": settings.PAYPAL_RECEIVER_EMAIL,
"amount": image.price,
"item_name": image.title,
"item_number": image.id,
"no_shipping": PayPalPaymentsForm.SHIPPING_CHOICES[1][0],
"invoice": random_string(),
"notify_url": "http://%s%s"%(domain, reverse('paypal-ipn')),
"return_url": "http://%s%s"%(domain, reverse("purchase_return",args=(image.title_slug,))),
"cancel_return": "http://%s%s"%(domain, reverse("purchase_cancel",args=(image.title_slug,)))
}
the_form = PayPalPaymentsForm(initial=paypal_dict)
# Change this in production!
form = the_form.sandbox()
# Use gallery colorscheme
try:
colorscheme = ColorScheme.objects.get(use_for_galleries=True)
except ColorScheme.DoesNotExist:
pass
return render_to_response("image_show.html", locals(), context_instance=RequestContext(request))
示例15: carga_compra
# 需要导入模块: from paypal.standard.forms import PayPalPaymentsForm [as 别名]
# 或者: from paypal.standard.forms.PayPalPaymentsForm import sandbox [as 别名]
def carga_compra(request, pago_id):
pago=get_object_or_404(Pagos, pk=pago_id)
usuario_pago=Usuarios_Pagos.objects.get_or_create(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_compras_" + 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[0].id,
"currency_code": "EUR", # currency
"paymentaction": "authorization",
}
form = PayPalPaymentsForm(initial=paypal_dict)
context={"pago":pago, "form":form.sandbox()}
pagina_pago=render_to_string("joinitys/pagos/ajax_ver_compra.html", context)
return simplejson.dumps({"pago":pagina_pago})