Only showing Stripe update form to Stripe customers

Hi guys,

I’m moving my site from PayPal buttons to Stripe.

It will mean I’ll have a few hundred users who are on legacy plans, paid via PayPal.

All new customers will use Stripe - and thus I want to have a Stripe billing update form, linked from my Members’ Area.

If a PayPal subscriber went to that page, I’d want to hide the form, and tell them that all their updates are done via PayPal - or offer a cancelation PP button.

I can show or hide via simple conditionals on membership level - but is there any way of hiding stuff dependent on which gateway they used to sign up?

Thanks in advance.

Ross :slight_smile:

Any idea if we can hide content based on S2 payment gateway folks?

Probably, but you’d need custom code. What I’d do is give the new Stripe customers a different level; then you can use the conditionals as usual.

I could definitely do that @KTS915 - but I have quite a few custom templates with hard-coded sections for =level1 calls.

I could change those, but it would be cool if we could tap into the gateway from the user dashboard, as a simple conditional.

@jaswsinc - would you ever consider that Jason?

It would mean we could show the correct cancel form, depending on gateway?

Ross :slight_smile:

Here is one way to do this, following the information in this article.

<?php
$gateway = get_user_option('s2member_subscr_gateway');
?>
<?php if ($gateway === 'paypal') : ?>
    Insert PayPal Pro-Form shortcode for cancellation here.
<?php elseif ($gateway === 'stripe') : ?>
    Insert Stripe Pro-Form shortcode for cancellation here.
<?php endif; ?>

Possible values for s2member_subscr_gateway are as follows:

  • paypal
  • stripe
  • authnet
  • clickbank

and some of the older codes can be found here in the dashboard.

@jaswsinc - you’re a legend mate - thanks so much for this.

For those wanting to do something similar, here’s the code I used, in conjunction with the ‘Insert php’ plugin - it has 100k+ downloads, and let’s you insert php into posts and pages, via a shortcode.

Here is the code I used, after activating that plugin.

I may get this coded into a template though, if allowing php execution on posts and pages causes a security issue.

If you are logged into a paid PREMIUM account - you will see your cancellation options below.

[insert_php] 
$gateway = get_user_option('s2member_subscr_gateway');
if ($gateway === 'paypal') : ?>
<strong>It looks like you paid for your PREMIUM subscription via PayPal.</strong>

Hit the 'Unsubscribe' button below and log in to your PayPal account to cancel your recurring subscription.

Your PREMIUM membership will be downgraded to a FREE account at the end of your current subscription term.
[s2Member-PayPal-Button cancel="1" image="default" output="anchor" /]

<?php elseif ($gateway === 'stripe') : ?>
<strong>It looks like you paid for your PREMIUM subscription via credit/debit card.</strong>

Complete the security validation below, then hit 'Submit Form' to cancel your payments now.

Your PREMIUM membership will be downgraded to a FREE account at the end of your current subscription term.
[s2Member-Pro-Stripe-Form cancel="1" desc="This will cancel your account. Are you sure?" unsub="0" captcha="light" /]
<?php endif; [/insert_php]

It seems to work very well.

@rossagrant:

@jaswsinc was too modest to tell you that he has written a plugin with similar functionality. So I’ll do that for him:

@KTS915 - ahh, nice one - I didn’t know Jason had coded a similar plugin.

Great stuff! :slight_smile: