问题描述
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 (将#修改为@)