对于正常的支付,我使用的是一个通过RESTAPI进行的修复。我现在正在尝试创建计费周期,但无论我做什么,都会出现错误。有人能帮我把它放在烧瓶上吗
基本上我想做以下几点:
这是我到目前为止写的:
@app.route('/payment')
def payment():
redirect(create_billing_agreement())
# HELPERS
def create_billing_agreement():
billing_agreement = BillingAgreement({
"name": 'Stocked Lab Subscription Agreement',
'description': "Agreement for Stocked Lab Subscription Plan",
'start_date': datetime.datetime.now().replace(microsecond=0).isoformat(),
"plan": {'id': create_billing_plan()}})
if billing_agreement.create():
for link in billing_agreement.links:
if link.method == "REDIRECT":
redirect_url = str(link.href)
return redirect_url
else:
print(billing_agreement.error)
def create_billing_plan():
plan = BillingPlan({
"name": 'Stocked Lab Subscription',
'description': 'The base subscription for Stocked Lab',
"type": 'INFINITE',
"payment_definitions": [{
"name": "Standard Plan",
"type": "REGULAR",
"frequency_interval": "1",
"frequency": "MONTH",
"cycles": '0',
"amount": {
"currency": "USD",
"value": "15"
}
}],
"merchant_preferences": {
"auto_bill_amount": "yes",
"cancel_url": "http://localhost:5000/cancel_subscription",
"initial_fail_amount_action": "continue",
"max_fail_attempts": "1",
"return_url": "http://localhost:5000/",
"currency": "USD",
"value": '0'
}
})
if plan.create():
print(f'Billing Plan [{plan.id}] created successfully')
if plan.activate():
plan = BillingPlan.find(plan.id)
print(f"Billing Plan [{plan.id}] state changed to {plan.state}")
return plan.id
else:
print(plan.error)
else:
print(plan.error)
谢谢你的帮助
将订阅计划传递给智能支付按钮的说明如下:https://developer.paypal.com/docs/subscriptions/integrate/#subscriptions-with-smart-payment-buttons
相关问题 更多 >
编程相关推荐