Skip to main content

Use a non-USD currency for buy-ups in a specific market

Free Beginner Since v1.0.0

StripeBuyupProvisioner runs apply_filters( 'benecaster_buyup_currency', 'usd', $buyup_id ) when minting Stripe Prices. Return a different ISO-4217 currency code to provision in that currency instead. The same Price is reused across every signup, so changing the filter for an existing buy-up only affects future Price mints — existing subscribers continue paying in whatever currency the cached Price was minted in.

Code

<?php
add_filter( 'benecaster_buyup_currency', function ( string $default, int $buyup_id ): string {
    // Use GBP for buy-ups whose token type starts with "uk_".
    $repo  = new \Benecaster\Membership\BuyupRepository();
    $buyup = $repo->find( $buyup_id );
    if ( $buyup && str_starts_with( (string) $buyup['token_type'], 'uk_' ) ) {
        return 'gbp';
    }
    return $default;
}, 10, 2 );

View on GitHub →

Hooks Used

  • benecaster_buyup_currency