如何解决如何在我的烧瓶应用程序上集成条带连接板载
enter image description here我试图使用https://github.com/stripe-samples/connect-onboarding-for-express中的代码在我的烧瓶上集成条纹快递。代码如下所示。
html
<button id="submit">Setup payouts on Stripe</button>
javaScript
let elmButton = document.querySelector("#submit");
if (elmButton) {
elmButton.addEventListener(
"click",e => {
elmButton.setAttribute("disabled","disabled");
elmButton.textContent = "Opening...";
fetch("/onboard-user",{
method: "POST",headers: {
"Content-Type": "application/json"
}
})
.then(response => response.json())
.then(data => {
if (data.url) {
window.location = data.url;
} else {
elmButton.removeAttribute("disabled");
elmButton.textContent = "<Something went wrong>";
console.log("data",data);
}
});
},false
);
}
python
@posts.route('/onboard-user',methods=['POST'])
def onboard_user():
account = stripe.Account.create(
type='express',business_type='individual',country='US'
)
#account = stripe.Account.create(type='express')
# Store the account ID.
session['account_id'] = account.id
origin = request.headers['origin']
account_link_url = _generate_account_link(account.id,origin)
try:
return jsonify({'url': account_link_url})
except Exception as e:
return jsonify(error=str(e)),403
@posts.route('/onboard-user/refresh',methods=['GET'])
def onboard_user_refresh():
if 'account_id' not in session:
return redirect('/')
account_id = session['account_id']
origin = ('https://' if request.is_secure else 'http://') + request.headers['host']
account_link_url = _generate_account_link(account_id,origin)
return redirect(account_link_url)
def _generate_account_link(account_id,origin):
account_link = stripe.AccountLink.create(
type='account_onboarding',account=account_id,refresh_url=f'{origin}/onboard-user/refresh',return_url=f'{origin}/success.html',)
return account_link.url
当我按html中的按钮时,我得到“正在打开...”。但不会处理。我收到如下所示的错误!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。