PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.13
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.13
1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 1.7.0.9 All 211 releases
charitable / includes / stripe / connect / charitable-stripe-connect-functions.php

charitable-stripe-connect-functions.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.13, at includes/stripe/connect/charitable-stripe-connect-functions.php

47 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Stripe Connect helper functions.
4 *
5 * @package Charitable Stripe/Functions/Connect
6 * @author David Bisset
7 * @copyright Copyright (c) 2021-2022, David Bisset
8 * @license http://opensource.org/licenses/gpl-3.0.php GNU Public License
9 * @since 1.4.0
10 * @version 1.4.0
11 */
12
13 // Exit if accessed directly.
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit;
16 }
17
18 /**
19 * Returns the connected Stripe account id for a campaign.
20 *
21 * @since 1.4.0
22 *
23 * @param int $campaign_id The campaign id.
24 * @return string|false Returns account id if one is connected and Charitable
25 * Stripe Connect is active. Otherwise, returns false.
26 */
27 function charitable_stripe_get_connected_account_for_campaign( $campaign_id ) {
28 if ( ! class_exists( 'Charitable_Stripe_Connect' ) ) {
29 return false;
30 }
31
32 $connected_user_id = get_post_meta( $campaign_id, '_campaign_stripe_connect_user_id', true );
33
34 if ( ! $connected_user_id ) {
35 return false;
36 }
37
38 $stripe_user = new Charitable_Stripe_Connect_User( $connected_user_id );
39 $connected_account = $stripe_user->get( 'stripe_user_id' );
40
41 /* We don't have an access token for the user, so we're just going to send the funds to the platform. */
42 if ( ! $connected_account || ! $stripe_user->is_token_valid_for_current_mode() ) {
43 return false;
44 }
45
46 return $connected_account;
47 }