Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
chore: update MONEI Connect documentation for signature verification
- Replaced placeholder API key usage with a direct instruction to use the actual MONEI API key.
- Simplified payment status checks by using string literals instead of imported constants for better clarity.
- Enhanced the overall readability of the webhook processing code examples.
  • Loading branch information
jimmyn committed Apr 16, 2025
commit 9e71e54e4c0cd94b783ed149ce371b0da8fae91a
16 changes: 6 additions & 10 deletions docs/guides/verify-signature.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,10 @@ try {
import os
import Monei
from Monei.errors import SignatureVerificationError
from Monei.model.payment_status import PaymentStatus # New import
from flask import Flask, request, abort, jsonify

# Set your api key. Remember to switch to your live api key in production!
# See your api key here: https://dashboard.monei.com/settings/api
# It's recommended to load the API key from environment variables
monei_api_key = os.environ.get("MONEI_API_KEY", "YOUR_API_KEY")
monei_client = Monei.MoneiClient(api_key=monei_api_key)
# Replace YOUR_API_KEY with your actual MONEI API key
monei_client = Monei.MoneiClient(api_key="YOUR_API_KEY")

app = Flask(__name__)

Expand All @@ -197,22 +193,22 @@ def callback():
print(f"Webhook received for Payment ID: {payment_id}, Status: {payment_status}")

# Update your order status based on the payment status
if payment_status == PaymentStatus.SUCCEEDED:
if payment_status == 'SUCCEEDED':
# Payment successful - fulfill the order
print(f"Payment {payment_id} succeeded. Fulfilling order...")
# Update your database, send confirmation email, etc.
pass # Placeholder from user snippet
elif payment_status == PaymentStatus.FAILED:
elif payment_status == 'FAILED':
# Payment failed - notify the customer
print(f"Payment {payment_id} failed. Notifying customer...")
# Log the failure, update your database, etc.
pass # Placeholder from user snippet
elif payment_status == PaymentStatus.AUTHORIZED:
elif payment_status == 'AUTHORIZED':
# Payment is authorized but not yet captured
print(f"Payment {payment_id} authorized. Capture if needed.")
# You can capture it later
pass # Placeholder from user snippet
elif payment_status == PaymentStatus.CANCELED:
elif payment_status == 'CANCELED':
# Payment was canceled
print(f"Payment {payment_id} was canceled.")
pass # Placeholder from user snippet
Expand Down