本文整理汇总了Python中paypal.pro.helpers.PayPalWPP.setExpressCheckout方法的典型用法代码示例。如果您正苦于以下问题:Python PayPalWPP.setExpressCheckout方法的具体用法?Python PayPalWPP.setExpressCheckout怎么用?Python PayPalWPP.setExpressCheckout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类paypal.pro.helpers.PayPalWPP
的用法示例。
在下文中一共展示了PayPalWPP.setExpressCheckout方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: redirect_to_express
# 需要导入模块: from paypal.pro.helpers import PayPalWPP [as 别名]
# 或者: from paypal.pro.helpers.PayPalWPP import setExpressCheckout [as 别名]
def redirect_to_express(self):
"""
First step of ExpressCheckout. Redirect the request to PayPal using the
data returned from setExpressCheckout.
"""
wpp = PayPalWPP(self.request)
try:
nvp_obj = wpp.setExpressCheckout(self.item)
except PayPalFailure:
self.context['errors'] = self.errors['paypal']
return self.render_payment_form()
else:
return HttpResponseRedirect(express_endpoint_for_token(nvp_obj.token))
示例2: redirect_to_express
# 需要导入模块: from paypal.pro.helpers import PayPalWPP [as 别名]
# 或者: from paypal.pro.helpers.PayPalWPP import setExpressCheckout [as 别名]
def redirect_to_express(self):
"""
First step of ExpressCheckout. Redirect the request to PayPal using the
data returned from setExpressCheckout.
"""
wpp = PayPalWPP(self.request)
nvp_obj = wpp.setExpressCheckout(self.item)
if not nvp_obj.flag:
pp_params = dict(token=nvp_obj.token, AMT=self.item['amt'],
RETURNURL=self.item['returnurl'],
CANCELURL=self.item['cancelurl'])
pp_url = self.get_endpoint() % urlencode(pp_params)
return HttpResponseRedirect(pp_url)
else:
self.context['errors'] = self.errors['paypal']
return self.render_payment_form()
示例3: redirect_to_express
# 需要导入模块: from paypal.pro.helpers import PayPalWPP [as 别名]
# 或者: from paypal.pro.helpers.PayPalWPP import setExpressCheckout [as 别名]
def redirect_to_express(self):
"""
First express flow step.
Redirect to PayPal with the data in tow.
"""
wpp = PayPalWPP(self.request)
nvp_obj = wpp.setExpressCheckout(self.item)
if not nvp_obj.flag:
pp_params = dict(token=nvp_obj.token,
AMT=self.item['amt'],
RETURNURL=self.item['returnurl'],
CANCELURL=self.item['cancelurl'])
pp_url = SANDBOX_EXPRESS_ENDPOINT % urllib.urlencode(pp_params)
return HttpResponseRedirect(pp_url)
else:
self.context = {'errors':'There was a problem contacting PayPal. Please try again later.'}
return self.render_payment_form()
示例4: redirect_to_express
# 需要导入模块: from paypal.pro.helpers import PayPalWPP [as 别名]
# 或者: from paypal.pro.helpers.PayPalWPP import setExpressCheckout [as 别名]
def redirect_to_express(self):
"""
First step of ExpressCheckout. Redirect the request to PayPal using the
data returned from setExpressCheckout.
"""
wpp = PayPalWPP(self.request)
try:
nvp_obj = wpp.setExpressCheckout(self.item)
except PayPalFailure:
self.context["errors"] = self.errors["paypal"]
return self.render_payment_form()
else:
pp_params = dict(
token=nvp_obj.token,
AMT=self.item["amt"],
RETURNURL=self.item["returnurl"],
CANCELURL=self.item["cancelurl"],
)
pp_url = self.get_endpoint() % urlencode(pp_params)
return HttpResponseRedirect(pp_url)
示例5: paypal_start
# 需要导入模块: from paypal.pro.helpers import PayPalWPP [as 别名]
# 或者: from paypal.pro.helpers.PayPalWPP import setExpressCheckout [as 别名]
def paypal_start(request):
"""
Creating express checkout request from users cart
"""
try:
params = get_cart_data_from_request(request)
host_name = request.get_host()
params.update({
"returnurl": "http://" + host_name + "/order/paypal/confirm",
"cancelurl": "http://" + host_name + "/#!/cart",
"noshipping": 2,
})
wpp = PayPalWPP()
nvp = wpp.setExpressCheckout(params)
response = HttpResponseRedirect(settings.PAYPAL_URL + '/cgi-bin/webscr?cmd=_express-checkout&token=' + nvp.token)
response.delete_cookie('cart')
return response
except Exception, e:
#log error here
print e
return HttpResponseRedirect("/#!/cart")
示例6: redirect_to_express
# 需要导入模块: from paypal.pro.helpers import PayPalWPP [as 别名]
# 或者: from paypal.pro.helpers.PayPalWPP import setExpressCheckout [as 别名]
def redirect_to_express(self):
"""
First step of ExpressCheckout. Redirect the request to PayPal using the
data returned from setExpressCheckout.
"""
wpp = PayPalWPP(self.request)
try:
nvp_obj = wpp.setExpressCheckout(self.item)
except PayPalFailure:
log.exception('paypal failure')
self.context['errors'] = self.errors['paypal']
return self.render_payment_form()
else:
pp_params = dict(token=nvp_obj.token,
L_PAYMENTREQUEST_0_AMTm=self.item['PAYMENTREQUEST_0_AMT'],
PAYMENTREQUEST_0_ITEMAMT=self.item['PAYMENTREQUEST_0_AMT'],
PAYMENTREQUEST_0_AMT=self.item['PAYMENTREQUEST_0_AMT'],
PAYMENTREQUEST_0_DESC=self.item['PAYMENTREQUEST_0_DESC'],
PAYMENTREQUEST_0_CURRENCYCODE=self.item['PAYMENTREQUEST_0_CURRENCYCODE'],
RETURNURL=self.item['returnurl'],
CANCELURL=self.item['cancelurl'])
pp_url = self.get_endpoint() % urlencode(pp_params)
# log.info('redirect data: %s'% pp_url)
return HttpResponseRedirect(pp_url)