本文整理汇总了Python中paypal.pro.helpers.PayPalWPP.doExpressCheckoutPayment方法的典型用法代码示例。如果您正苦于以下问题:Python PayPalWPP.doExpressCheckoutPayment方法的具体用法?Python PayPalWPP.doExpressCheckoutPayment怎么用?Python PayPalWPP.doExpressCheckoutPayment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类paypal.pro.helpers.PayPalWPP
的用法示例。
在下文中一共展示了PayPalWPP.doExpressCheckoutPayment方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_doExpressCheckoutPayment_invalid
# 需要导入模块: from paypal.pro.helpers import PayPalWPP [as 别名]
# 或者: from paypal.pro.helpers.PayPalWPP import doExpressCheckoutPayment [as 别名]
def test_doExpressCheckoutPayment_invalid(self, mock_request_object):
ec_token = 'EC-1234567890'
payerid = 'LXYZABC1234'
item = self.ec_item.copy()
item.update({'token': ec_token, 'payerid': payerid})
mock_request_object.return_value = 'ack=Failure&l_errorcode=42&l_longmessage0=Broken'
wpp = PayPalWPP(REQUEST)
with self.assertRaises(PayPalFailure):
wpp.doExpressCheckoutPayment(item)
示例2: test_doExpressCheckoutPayment
# 需要导入模块: from paypal.pro.helpers import PayPalWPP [as 别名]
# 或者: from paypal.pro.helpers.PayPalWPP import doExpressCheckoutPayment [as 别名]
def test_doExpressCheckoutPayment(self, mock_request_object):
ec_token = 'EC-1234567890'
payerid = 'LXYZABC1234'
item = self.ec_item.copy()
item.update({'token': ec_token, 'payerid': payerid})
mock_request_object.return_value = 'ack=Success&token=%s&version=%spaymentinfo_0_amt=%s' % \
(ec_token, VERSION, self.ec_item['paymentrequest_0_amt'])
wpp = PayPalWPP(REQUEST)
wpp.doExpressCheckoutPayment(item)
call_args = mock_request_object.call_args
self.assertIn('VERSION=%s' % VERSION, call_args[0][1])
self.assertIn('METHOD=DoExpressCheckoutPayment', call_args[0][1])
self.assertIn('TOKEN=%s' % ec_token, call_args[0][1])
self.assertIn('PAYMENTREQUEST_0_AMT=%s' % item['paymentrequest_0_amt'],
call_args[0][1])
self.assertIn('PAYERID=%s' % payerid, call_args[0][1])
示例3: validate_confirm_form
# 需要导入模块: from paypal.pro.helpers import PayPalWPP [as 别名]
# 或者: from paypal.pro.helpers.PayPalWPP import doExpressCheckoutPayment [as 别名]
def validate_confirm_form(self):
"""
Third and final step of ExpressCheckout. Request has pressed the confirmation but
and we can send the final confirmation to PayPal using the data from the POST'ed form.
"""
wpp = PayPalWPP(self.request)
pp_data = dict(token=self.request.POST['token'], payerid=self.request.POST['PayerID'])
self.item.update(pp_data)
# @@@ This check and call could be moved into PayPalWPP.
try:
if self.is_recurring():
wpp.createRecurringPaymentsProfile(self.item)
else:
wpp.doExpressCheckoutPayment(self.item)
except PayPalFailure:
self.context['errors'] = self.errors['processing']
return self.render_payment_form()
else:
return HttpResponseRedirect(self.success_url)
示例4: process
# 需要导入模块: from paypal.pro.helpers import PayPalWPP [as 别名]
# 或者: from paypal.pro.helpers.PayPalWPP import doExpressCheckoutPayment [as 别名]
def process(self, ipaddress, user, item):
"""Process a PayPal ExpressCheckout payment."""
from paypal.pro.helpers import PayPalWPP
wpp = PayPalWPP(ipaddress, user)
params = self.cleaned_data
params.update(item)
try:
# Create single payment:
if 'billingperiod' not in params:
nvp_obj = wpp.doExpressCheckoutPayment(params)
# Create recurring payment:
else:
nvp_obj = wpp.createRecurringPaymentsProfile(params)
except PayPalFailure:
return None
return nvp_obj
示例5: validate_confirm_form
# 需要导入模块: from paypal.pro.helpers import PayPalWPP [as 别名]
# 或者: from paypal.pro.helpers.PayPalWPP import doExpressCheckoutPayment [as 别名]
def validate_confirm_form(self):
"""
Third and final step of ExpressCheckout. Request has pressed the confirmation but
and we can send the final confirmation to PayPal using the data from the POST'ed form.
"""
wpp = PayPalWPP(self.request)
pp_data = dict(token=self.request.POST['token'], payerid=self.request.POST['PayerID'])
self.item.update(pp_data)
if self.is_recurring:
success = wpp.createRecurringPaymentsProfile(self.item)
else:
success = wpp.doExpressCheckoutPayment(self.item)
if success:
payment_was_successful.send(sender=self.item)
return HttpResponseRedirect(self.success_url)
else:
self.context['errors'] = self.processing_error
return self.render_payment_form()
示例6: validate_confirm_form
# 需要导入模块: from paypal.pro.helpers import PayPalWPP [as 别名]
# 或者: from paypal.pro.helpers.PayPalWPP import doExpressCheckoutPayment [as 别名]
def validate_confirm_form(self):
"""
Final express flow step.
User has pressed the confirm button and now we send it off to PayPal.
"""
wpp = PayPalWPP(self.request)
pp_data = dict(token=self.request.POST['token'], payerid=self.request.POST['PayerID'])
self.item.update(pp_data)
if self.is_recurring:
success = wpp.createRecurringPaymentsProfile(self.item)
else:
success = wpp.doExpressCheckoutPayment(self.item)
if success:
payment_was_successful.send(sender=self.item)
return HttpResponseRedirect(self.success_url)
else:
self.context['errors'] = "There was a problem processing the payment. Please check your information and try again."
return self.render_payment_form()
示例7: paypal_end
# 需要导入模块: from paypal.pro.helpers import PayPalWPP [as 别名]
# 或者: from paypal.pro.helpers.PayPalWPP import doExpressCheckoutPayment [as 别名]
def paypal_end(request):
"""
Do payment and create order object in DB
"""
try:
wpp = PayPalWPP(request)
token = request.GET['token']
params = {"token": token}
nvp = wpp.getExpressCheckoutDetails(params)
order_dict = nvp.response_dict.copy()
params = {
"token": token,
"payerid": nvp.payerid,
"paymentrequest_0_amt": nvp.response_dict.get("paymentrequest_0_amt"),
"paymentrequest_0_currencycode" : nvp.response_dict.get("paymentrequest_0_currencycode")
}
payment = wpp.doExpressCheckoutPayment(params)
order_dict['transactionid'] = payment.response_dict.get('paymentinfo_0_transactionid')
order = create_order_from_express_paypal(order_dict)
send_order_email(order.email, order, order.items.all)
data = {
'order_id': order.id,
}
return HttpResponse(json.dumps(data), content_type='application/json')
except Exception, e:
print e
data = {
'error': e.message
}
return HttpResponseServerError(json.dumps(data), content_type='application/json')