Created
June 4, 2025 19:42
-
-
Save rickalday/cf548ab4bb5524192136c982b9da3f70 to your computer and use it in GitHub Desktop.
Include fund in Stripe payment metadata - Visual Builder Forms
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use GiveFunds\Models\Fund; | |
use GiveFunds\Repositories\Funds; | |
use GiveFunds\Repositories\Revenue; | |
function give_stripe_custom_payment_meta( $args ) { | |
// Sanitize the input posted data to the form. | |
$posted_data = give_clean( filter_input_array( INPUT_POST ) ); | |
/* @var Funds $fundRepository */ | |
$fundRepository = give( Funds::class ); | |
$revenueRepository = give( Revenue::class ); | |
$fundId = $posted_data['fundId']; | |
$fund = ( $fundId ) ? $fundRepository->getFund( $fundId ) : $fundRepository->getDefaultFund(); | |
$fundTitle = $fund->getTitle(); | |
/** Uncomment this block to get the $purchase_data array listed in Donations -> Tools -> Logs | |
* \Give\Framework\PaymentGateways\Log\PaymentGatewayLog::success('Contents of the variables', | |
* [ | |
* 'Purchase Data' => $purchase_data, | |
* 'Subscription' => $subscription, | |
* ] | |
* ); | |
**/ | |
// Prepare metadata fields list. | |
$custom_meta_fields = array( | |
'Fund' => $fundTitle, | |
); | |
$args = array_merge( $args, $custom_meta_fields ); | |
return $args; | |
} | |
add_filter( 'give_stripe_prepare_metadata', 'give_stripe_custom_payment_meta', 10 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment