上海全国关键词排名优化_小程序引流推广平台_专业团队张伟图片_东莞网站建设基础型
= ''def paypal_refund(requset):from paypalrestsdk import Salesale = Sale.find("流水号")refund = sale.refund({"amount": {"total": "0.01","currency": "USD"}})if refund.success():print("Refund[%s] Success" % (refund.id))else:print("Unable to Refund")print(refund.error)def paypal_execute(request):if request.method == 'GET':import paypalrestsdkpaymentid = request.GET.get("paymentId") payerid = request.GET.get("payerId") payment = paypalrestsdk.Payment.find(paymentid)if payment.execute({"payer_id": payerid}):print("Payment execute successfully")return HttpResponse("支付成功")else:print(payment.error) return HttpResponse("支付失败")def paypal_payment(request):import paypalrestsdkpaypalrestsdk.configure({"mode": "sandbox", "client_id": paypal_client_id,"client_secret": paypal_client_secret,})payment = paypalrestsdk.Payment({"intent": "sale","payer": {"payment_method": "paypal"},"redirect_urls": {"return_url": "http://localhost:8000/paypal/pay", "cancel_url": "http://localhost:8000/paypal/cancel/"}, "transactions": [{"amount": {"total": "0.01","currency": "USD"},"description": "test_real"}]})if payment.create():print("Payment created successfully")for link in payment.links:if link.rel == "approval_url":approval_url = str(link.href)print("Redirect for approval: %s" % (approval_url))return redirect(approval_url)else:print(payment.error)return HttpResponse("支付失败")def paypal_pay(request):back_url = request.get_full_path()if 'paymentId=' and 'token=' and 'PayerID=' in back_url:paymentid = back_url.split('paymentId=')[1].split('&token=')[0]token = back_url.split('&token=')[1].split('&PayerID=')[0]payerid = back_url.split('PayerID=')[1]pay = {'paymentid': paymentid,'token': token,'payerid': payerid,}else:pay = {}return render(request, 'paypal_pay.html', pay)">