|
|
|
@ -1633,7 +1633,7 @@ def finalize_payment_method(): |
|
|
|
""" |
|
|
|
Finalize payment method setup after Stripe confirmation. |
|
|
|
""" |
|
|
|
try: |
|
|
|
#try: |
|
|
|
data = request.get_json() |
|
|
|
setup_intent_id = data.get('setup_intent_id') |
|
|
|
stripe_customer_id = data.get('stripe_customer_id') |
|
|
|
@ -1653,7 +1653,7 @@ def finalize_payment_method(): |
|
|
|
|
|
|
|
# Check setup intent status |
|
|
|
setup_result = processor.get_setup_intent_status(setup_intent_id) |
|
|
|
|
|
|
|
print(f"setup_result: {setup_result}") |
|
|
|
if not setup_result['success']: |
|
|
|
return jsonify({ |
|
|
|
'success': False, |
|
|
|
@ -1667,6 +1667,7 @@ def finalize_payment_method(): |
|
|
|
}), 400 |
|
|
|
|
|
|
|
payment_method = setup_result.get('payment_method') |
|
|
|
print(f"payment_method: {payment_method}") |
|
|
|
if not payment_method: |
|
|
|
return jsonify({ |
|
|
|
'success': False, |
|
|
|
@ -1723,18 +1724,18 @@ def finalize_payment_method(): |
|
|
|
'customer_id': stripe_customer_id |
|
|
|
}) |
|
|
|
|
|
|
|
except Exception as e: |
|
|
|
log_activity( |
|
|
|
user_id=current_user.id, |
|
|
|
action="finalize_payment_method_error", |
|
|
|
entity_type="payment_method", |
|
|
|
details=f"Payment method finalization error: {str(e)}", |
|
|
|
ip_address=request.remote_addr |
|
|
|
) |
|
|
|
return jsonify({ |
|
|
|
'success': False, |
|
|
|
'error': f'Payment method finalization failed: {str(e)}' |
|
|
|
}), 500 |
|
|
|
#except Exception as e: |
|
|
|
# log_activity( |
|
|
|
# user_id=current_user.id, |
|
|
|
# action="finalize_payment_method_error", |
|
|
|
# entity_type="payment_method", |
|
|
|
# details=f"Payment method finalization error: {str(e)}", |
|
|
|
# ip_address=request.remote_addr |
|
|
|
# ) |
|
|
|
# return jsonify({ |
|
|
|
# 'success': False, |
|
|
|
# 'error': f'Payment method finalization failed: {str(e)}' |
|
|
|
# }), 500 |
|
|
|
|
|
|
|
@main_bp.route('/api/get-payment-methods', methods=['POST']) |
|
|
|
@login_required |
|
|
|
|