I was able to create stripe payment whereby a seller and the website owner shares amount paid by a buyer for a product online via application_fee. The problem is that when a buy buys multiple product, I find it difficult to transfer funds to multiple sellers after successful transaction with the buyer. For now I am find it difficult to implement the code successfully to implement the task. The code below is python (Flask).
@posts.route('/chkout')
def checkout():
res = Cart.query.filter_by(username = current_user.u, status='pending').all()
line = []
#acc = []
for r in res:
amt = int(r.amount * 100)
course_img = Post.query.filter_by(id = r.c).first()
te = {
'price_data': {
'currency': 'usd',
'unit_amount_decimal': amt,
'product_data': {
'name': r.course,
'images': ['https://www.sssssssss.com/static/stylesheets/course_cover/'+ course_img.course_cover],
},
},
'quantity': 1,
}
line.append(te)
#acc.append(owner_id.connect_accnt_id)
session = stripe.checkout.Session.create(
payment_method_types=['card'],
line_items=line,
payment_intent_data={
'application_fee_amount': 1,
'transfer_data': {
'destination': 'acct_xxxxxxxxxxxxxxxx',
},
},
customer_email='a@b.c',
mode='payment',
success_url=url_for('posts.processing', _external=True) + '?session_id={CHECKOUT_SESSION_ID}',
cancel_url=url_for('posts.viewcart', _external=True),
)
return jsonify(checkout_session_id=session['id'], checkout_public_key=config.get('STRIPE_PUBLIC_KEY'))
I really appreciate if you assist me
Aucun commentaire:
Enregistrer un commentaire