PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

Custom Success URL

s2Member Plugin. A Membership plugin for WordPress®.

Custom Success URL

Postby joelcpatterson » July 8th, 2011, 2:18 pm

So I'm pretty new to this plug in but not new to PHP/Wordpress.
I own pro forms, but it seems preferable to go with a custom form that I have written, as I don't like the look of the "Modify" pro form template.

Here is the process I'm trying to accomplish.
1. User registers...fills out info. Submit --->sent to step 2
2. User logs in --->Sent to step 3
3. User selects a qty per month of something I ship to them. Then subscribes to a price based on that quantity.

In my php code I'm just creating the subcription form dynamically. qty of 1 = $34, qty of 2 = $68

What I need to be able to do, is have them input a quantity, have them pay for the subscription, verify that payment went through, then update their qty entry on my site. I need to make sure they paid for the qty they selected.

I saw in the pro forms there is a success url...Is there a way to implement that with a custom form? If so, I could then just send the qty data along to paypal, redirect after paypal, verify they have a subscriber ID and update the qty in my users meta info.

Maybe there is an easier way to do this, if so, I would be delighted.

Thanks a bunch for any help!
Joel
User avatar
joelcpatterson
Registered User
Registered User
 
Posts: 4
Joined: June 14, 2011

Re: Custom Success URL

Postby Cristián Lávaque » July 8th, 2011, 5:33 pm

I suggest you take a look at this post on how to create a button in PayPal that'll work with s2Member, it'll give you an idea of what has to be there for the integration to work between s2Member and PayPal. viewtopic.php?f=36&t=309#p1333

You can customize the PayPal return URL in your form adding this input tag

Code: Select all
    <input type="hidden" name="return" value="URL goes here" />


I hope that helps. :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Custom Success URL

Postby joelcpatterson » July 20th, 2011, 9:28 am

Alright, so I was able to figure out a method that works for this. I am now sending my "qty" data along with the paypal form using the "Custom" field. So my custom field looks like this "www.webaddress.com|2".

My initial registration works great. The field gets updated perfectly. I am now having trouble with trying to modify a membership after the fact. I'm using the paypal subscription modification button. I'm not really doing a membership upgrade,(level 1 to level 2), however I'm modifying the price based on the "qty" value they specify.

I am able to successfully complete a membership modification through paypal, updating the price from $1 to $2. But the custom field is not being updated on my site accordingly.

Things that I know are WORKING:
My modify button form is correctly submitting the new Qty value. (www.mywebaddress.com|3)
Paypal handles the subscription price correctly. (updates from $1 to $2)

Not WORKING:
members Custom field is not updating (www.mywebaddress.com|2 ---> www.mywebaddress.com|3)

Thanks!
User avatar
joelcpatterson
Registered User
Registered User
 
Posts: 4
Joined: June 14, 2011

Re: Custom Success URL

Postby joelcpatterson » July 20th, 2011, 10:13 am

Code: Select all
<?php
   $user_id = S2MEMBER_CURRENT_USER_ID;
   $s2member_custom_fields = get_user_option('s2member_custom_fields', $user_id);

   $qty = $_GET["qty"];
   $step = $_GET["step"];
   if(!$qty){
      $qty = substr(S2MEMBER_CURRENT_USER_CUSTOM,26);
   }
   $a3 = ($qty * .5);
?>
<!-- noformat on -->   
<div class="contentBackground setHeight">
<div class="contentHeader">Modify Membership</div>
<table>
    <tr>
    <?php
   if($step == 1){
      echo "<th class='selected' style='width:306px;'>Update Quantity</th>";
   }else{
      echo "<th style='width:306px;'>Update Quantity</th>";
   }
   if($step == 2){
      echo "<th class='selected' style='width:306px;'>Submit Modification</th>";
   }else{
      echo "<th style='width:306px;'>Submit Modification</th>";
   }
    ?>
    </tr>
    <tr>
    <td colspan=2>
   <?php if($step == 1){ ?>
   <form action="http://www.MyWebAddress.org/" method="get">
      <fieldset>
      <legend>Quantity:</legend>
      <input type="hidden" name="page_id" value="561">
       <input type="hidden" name="step" value="2">
      <label>I would like to receive </label>
      <input type="text" value="<?php echo $qty; ?>" name="qty" style="width:20px;">
      <label> Bible(s) a month.</label>
      <input type="submit" value="Update Quantity" name="submit">
      </fieldset>
   </form>
   <?php } ?>
   <?php if($step == 2){ ?>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
   <fieldset>
   <legend>Place Order:</legend>
   <label>I want <strong><?php echo $qty; ?></strong> Bible(s) per month, for a total cost of <strong>$<?php echo $a3; ?></strong> per month.</label>
   <input type="hidden" name="business" value="webmaster@MyWebAddress.org" />
   <input type="hidden" name="cmd" value="_xclick-subscriptions" />
   <input type="hidden" name="notify_url" value="http://www.MyWebAddress.org/?s2member_paypal_notify=1" />
   <input type="hidden" name="cancel_return" value="http://www.MyWebAddress.org/" />
   <input type="hidden" name="return" value="http://www.MyWebAddress.org/?s2member_paypal_return=1" />
   <input type="hidden" name="rm" value="2" />
   <input type="hidden" name="lc" value="" />
   <input type="hidden" name="no_shipping" value="1" />
   <input type="hidden" name="no_note" value="1" />
   <input type="hidden" name="custom" value="www.MyWebAddress.org|<?php echo $qty; ?>" />
   <input type="hidden" name="currency_code" value="USD" />
   <input type="hidden" name="page_style" value="paypal" />
   <input type="hidden" name="charset" value="utf-8" />
   <input type="hidden" name="item_name" value="Description and pricing details here." />
   <input type="hidden" name="item_number" value="1" />
   <input type="hidden" name="on0" value="<?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0; ?>" />
   <input type="hidden" name="os0" value="<?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0; ?>" />
   <input type="hidden" name="on1" value="<?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1; ?>" />
   <input type="hidden" name="os1" value="<?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS1; ?>" />
   <input type="hidden" name="modify" value="1" />
   <input type="hidden" name="src" value="1" />
   <input type="hidden" name="srt" value="" />
   <input type="hidden" name="sra" value="1" />
   <input type="hidden" name="a3" value="<?php echo $a3; ?>" style="width:40px;" />
   <input type="hidden" name="p3" value="1" />
   <input type="hidden" name="t3" value="M" />
   <input type="submit" value="Submit Order Modification" />
   
   <input type="hidden" name="first_name" value="[s2Get user_field="first_name" /]">
        <input type="hidden" name="last_name" value="[s2Get user_field="last_name" /]">
        <input type="hidden" name="address1" value="[s2Get user_field="address" /]">
        <input type="hidden" name="address2" value="[s2Get user_field="address2" /]">
        <input type="hidden" name="state" value="[s2Get user_field="state" /]">
        <input type="hidden" name="city" value="[s2Get user_field="city" /]">
        <input type="hidden" name="zip" value="[s2Get user_field="zip_code" /]">
        <input type="hidden" name="night_ phone_a" value="[s2Get user_field="phone_number" /]">
        <input type="hidden" name="email" value="[s2Get constant="S2MEMBER_CURRENT_USER_EMAIL" /]">
   </fieldset>
</form>
<strong>NOTE:</strong>You must process this modification through your paypal account. This will remove your previous montly subscription and update it to your desired subscription.<br /><br />
   <?php } ?>
    </td>
</table>
</div>
<!-- noformat off -->   
User avatar
joelcpatterson
Registered User
Registered User
 
Posts: 4
Joined: June 14, 2011

Re: Custom Success URL

Postby Cristián Lávaque » July 20th, 2011, 9:51 pm

joelcpatterson wrote:Not WORKING:
members Custom field is not updating (http://www.mywebaddress.com|2 ---> http://www.mywebaddress.com|3)


The custom shortcode attribute is not the same as a custom profile field.

What you could try is use the Notifications API to give the custom value with the quantity to a script that'll update the user's custom profile field. WP Admin -> s2Member -> API / Notifications
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Custom Success URL

Postby joelcpatterson » July 20th, 2011, 11:07 pm

So I'm not using the shortcode, I'm actually using the form field called custom, which is specified in s2member documentation (see below).
Code: Select all
<input type="hidden" name="custom" value="www.MyWebsite.org|<?php echo $qty; ?>" />

in my initial subscription process, the code above gets submitted to paypal and then gets put into the users custom field upon payment finalization (see image).
Image

The issue is when the user does a paypal subscription modification, even though I am sending a different value to paypal, it doesn't ever come back and update the users custom field quantity.

I'm not sure if that is the intended process? If it is, then I will look into the alternative you mentioned. If it isn't then something isn't updating correctly. The code I posted in my previous post is the code for the subscription modification page that contains the custom field input. The form itself is actually pulled directly from the modification button.

Image
User avatar
joelcpatterson
Registered User
Registered User
 
Posts: 4
Joined: June 14, 2011


Return to s2Member Plugin

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 1 guest

cron