Payment confirmation
Handle Stripe payment confirmation webhooks.
This function listens for various Stripe webhook events related to payment processing, such as payment intents, invoices, and subscriptions. It retrieves the relevant payment or subscription details, processes the data (including creating or updating contributions, transactions, and cards/bank accounts), and updates the local database accordingly.
Webhook events handled include: - payment_intent.created - payment_intent.succeeded - invoice.created - invoice.paid - invoice.updated - invoice.payment_failed - setup_intent.succeeded - financial_connections.account.created - subscription_schedule.created - subscription_schedule.canceled - refund.created - refund.failed - charge.refunded
:param church_id: The Church ID :param request: The HTTP request object containing the Stripe webhook event. :param church_id: The ID of the church associated with the payment. :return: A success response if the payment or subscription is successfully processed, or an error response otherwise. :raises ValueError: If there is an error with the webhook payload. :raises stripe.error.SignatureVerificationError: If the Stripe signature verification fails.
false
POST /api/give/contributions/payment-confirmation/{church_id} HTTP/1.1
Host: prosper-api-test.churchpad.com
Authorization: Bearer JWT
Content-Type: application/json
Accept: */*
Content-Length: 1360
{
"user_id": "123e4567-e89b-12d3-a456-426614174000",
"contributions": [
{
"recurring": false,
"description": "text",
"interval_length": 1,
"interval_unit": "text",
"total_occurrences": 1,
"frequency": "text",
"start_date": "2025-07-23",
"amount": "text",
"legacy_id": "text",
"nextgen_legacy_id": "text",
"created_at": "2025-07-23T12:49:07.920Z",
"processor": "stripe",
"memo": "text",
"date": "2025-07-23T12:49:07.920Z",
"type": "123e4567-e89b-12d3-a456-426614174000",
"guest": "123e4567-e89b-12d3-a456-426614174000"
}
],
"card": {
"user": "123e4567-e89b-12d3-a456-426614174000",
"legacy_id": "text",
"nextgen_legacy_id": "text",
"created_at": "2025-07-23T12:49:07.920Z",
"number": "text",
"cvv": "text",
"expiration_month": "text",
"expiration_year": "text",
"holder_name": "text",
"is_default": true,
"token": "text",
"brand": "text",
"type": "token",
"is_hidden": true,
"processor": "text",
"guest": "123e4567-e89b-12d3-a456-426614174000"
},
"church_id": "123e4567-e89b-12d3-a456-426614174000",
"about_user": {
"first_name": "text",
"last_name": "text",
"email": "[email protected]",
"phone_number": "text"
},
"cover_transaction_fees": false,
"start_date": "2025-07-23",
"payment_method": "text",
"card_token": "text",
"cvv": "text",
"customer_acceptance": {
"ip_address": "text",
"user_agent": "text"
},
"card_details": {
"cc_number": "text",
"cc_expiration": "text",
"cvv": "text"
},
"bank_details": {
"account_number": "text",
"routing_number": "text"
},
"processor_id": "text"
}
{
"user_id": "123e4567-e89b-12d3-a456-426614174000",
"contributions": [
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"description": "text",
"interval_length": 1,
"interval_unit": "text",
"total_occurrences": 1,
"frequency": "text",
"start_date": "2025-07-23",
"amount": "text",
"legacy_id": "text",
"nextgen_legacy_id": "text",
"created_at": "2025-07-23T12:49:07.920Z",
"updated_at": "2025-07-23T12:49:07.920Z",
"processor": "stripe",
"payment_id": "text",
"status": "PENDING",
"memo": "text",
"date": "2025-07-23T12:49:07.920Z",
"user": "123e4567-e89b-12d3-a456-426614174000",
"type": "123e4567-e89b-12d3-a456-426614174000",
"church": "123e4567-e89b-12d3-a456-426614174000",
"guest": "123e4567-e89b-12d3-a456-426614174000"
}
],
"church_id": "123e4567-e89b-12d3-a456-426614174000",
"about_user": {
"first_name": "text",
"last_name": "text",
"email": "[email protected]",
"phone_number": "text"
},
"start_date": "2025-07-23",
"payment_method": "text",
"card_token": "text",
"cvv": "text",
"customer_acceptance": {
"ip_address": "text",
"user_agent": "text"
},
"card_details": {
"cc_number": "text",
"cc_expiration": "text",
"cvv": "text"
},
"bank_details": {
"account_number": "text",
"routing_number": "text"
},
"processor_id": "text"
}