# Stripe Giving

Stripe Giving lets your church accept credit and debit card gifts directly on your Digital Church giving pages. Digital Church uses Stripe Connect for this integration, which means payments are created through the Digital Church platform and routed to your church’s connected Stripe account.

> This setup requires access to both your Digital Church dashboard and Stripe Dashboard. If Digital Church manages your Stripe Connect onboarding, ask support for the platform keys and connected account ID before you start.

## What you need before you begin

Before you turn on Stripe Giving, gather these values:

- **Stripe mode**: Test mode or Live mode.
- **Platform publishable key**: Starts with `pk_test_` or `pk_live_`.
- **Platform secret key**: Starts with `sk_test_` or `sk_live_`.
- **Connected account ID**: Starts with `acct_`.
- **Webhook signing secret**: Starts with `whsec_`.

The connected account ID tells Stripe which church account should receive the funds. Do not use a customer ID, payment ID, or price ID in this field.

## Add your Stripe settings in Digital Church

1. Sign in to your Digital Church dashboard.
2. Go to **Admin → Integrations**.
3. Open **Stripe Giving**.
4. Turn on **Enable Stripe Giving**.
5. Choose **Test mode** while you are setting things up.
6. Enter the platform publishable key.
7. Enter the platform secret key.
8. Enter the connected account ID for the church Stripe account.
9. Save the integration.

After the integration is saved, the Giving provider list can use Stripe as the direct **Credit/Debit** option. If you also use the older Gravity Forms Stripe option, Digital Church labels that older option as **Form** so the two options are easier to tell apart.

## Set up the Stripe webhook

The webhook lets Stripe tell Digital Church when a payment succeeds. This is important because a donor’s browser might close or lose connection after Stripe completes the payment.

Use this webhook endpoint URL:

```
https://your-domain.com/wp-json/dc/v1/giving/stripe/webhook
```

Replace `your-domain.com` with your church website domain.

To create the webhook in Stripe:

1. Open your Stripe Dashboard.
2. Make sure you are in the same mode you selected in Digital Church: **Test mode** or **Live mode**.
3. Go to **Developers → Webhooks**.
4. Click **Add endpoint**.
5. If Stripe asks which account should send events, choose **Your account** or **Account events**. Digital Church creates the payment on the platform account and routes the funds to the connected church account.
6. Paste the endpoint URL from above.
7. Select the event `payment_intent.succeeded`.
8. Save the endpoint.
9. Open the new webhook endpoint and reveal the **Signing secret**.
10. Copy the `whsec_...` value.
11. Go back to **Admin → Integrations → Stripe Giving** in Digital Church.
12. Paste the signing secret into **Webhook Signing Secret**.
13. Save the integration again.

> Test mode and live mode have different keys and different webhook signing secrets. If you switch modes, update the publishable key, secret key, connected account ID, and webhook signing secret for that mode.

## Test the integration

Before accepting real gifts, test the full flow.

1. Keep Stripe Giving in **Test mode**.
2. Open a Campaign or giving page that uses the Stripe **Credit/Debit** provider.
3. Enter a small gift amount, such as `$1.00`.
4. Use Stripe’s test card number:

```
4242 4242 4242 4242
```

Use any future expiration date, any three-digit CVC, and any ZIP code.

After the test payment succeeds, check two places:

- In Digital Church, confirm the Campaign gift or Giving transaction appears as confirmed.
- In Stripe, confirm the PaymentIntent succeeded and the funds are routed to the connected account.

## Go live

When the test flow works:

1. Switch **Stripe Mode** to **Live mode**.
2. Replace the test publishable key with the live publishable key.
3. Replace the test secret key with the live secret key.
4. Confirm the connected account ID is correct for live payments.
5. Create or update the live-mode webhook endpoint in Stripe.
6. Paste the live webhook signing secret into Digital Church.
7. Save the integration.
8. Run one small live gift and confirm it appears in both Digital Church and Stripe.

> Do not reuse test keys or a test webhook signing secret in live mode. Stripe treats test and live mode as separate environments.

## Troubleshooting

### “Cookie check failed”

This means the giving form request was rejected by WordPress before it reached the Stripe Giving endpoint. Refresh the giving page and try again. If the problem continues, make sure your site has the latest Digital Church Stripe Giving update installed.

### “Stripe Giving is not configured”

At least one required setting is missing. Check that Stripe Giving is enabled and that the platform publishable key, platform secret key, and connected account ID are saved.

### The gift succeeds in Stripe but does not appear in Digital Church

Check the webhook setup. The endpoint should use this URL:

```
https://your-domain.com/wp-json/dc/v1/giving/stripe/webhook
```

It should listen for `payment_intent.succeeded`, and the signing secret in Digital Church should match the webhook endpoint’s `whsec_...` value.

If Stripe asks for the event source, use **Your account** or **Account events** for this integration. Choosing connected-account events can prevent Digital Church from seeing the PaymentIntent created by the giving form.

### The connected account does not receive the funds

Check the connected account ID. It should begin with `acct_`. If you are not sure which account ID to use, contact Digital Church support before accepting live gifts.
