Browse Source

Fixed BECS Payment Method

master
Alan Woodman 4 months ago
parent
commit
39a332150d
  1. 29
      blueprints/main.py
  2. 2
      config.py
  3. 6
      stripe_payment_processor.py
  4. 2
      templates/main/add_payment_method.html

29
blueprints/main.py

@ -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

2
config.py

@ -32,7 +32,7 @@ class Config:
# Threading configuration
MAX_PAYMENT_THREADS = 5 # Number of concurrent payment processing threads
MAX_PAYMENT_THREADS = 15 # Number of concurrent payment processing threads
THREAD_TIMEOUT = 60 # Timeout in seconds for payment processing threads
# Stripe API Keys

6
stripe_payment_processor.py

@ -1083,7 +1083,8 @@ class StripePaymentProcessor:
'created': payment_method.created
}
if payment_method.card:
#if payment_method.card:
if pm_details['type'] == "card":
pm_details['card'] = {
'brand': payment_method.card.brand,
'last4': payment_method.card.last4,
@ -1091,7 +1092,8 @@ class StripePaymentProcessor:
'exp_month': payment_method.card.exp_month,
'exp_year': payment_method.card.exp_year
}
elif payment_method.au_becs_debit:
#elif payment_method.au_becs_debit:
elif pm_details['type'] == "au_becs_debit":
pm_details['au_becs_debit'] = {
'bsb_number': payment_method.au_becs_debit.bsb_number,
'last4': payment_method.au_becs_debit.last4

2
templates/main/add_payment_method.html

@ -187,7 +187,7 @@
<div class="field">
<div class="control">
<label class="checkbox">
<input type="checkbox" id="setAsDefault" checked>
<input type="checkbox" id="setAsDefault">
Set as default payment method for this customer
</label>
</div>

Loading…
Cancel
Save