latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

use PayPal Api to prorate account

Home Forums Community Forum use PayPal Api to prorate account

This topic contains 2 replies, has 2 voices. Last updated by  Bruce 3 years, 6 months ago.

Topic Author Topic
Posted: Tuesday Jun 18th, 2013 at 6:49 pm #52153

Hello-
We are in the process of migrating to a new website domain and at the same time modifying our payment levels for access – actually reducing our monthly fee. The problem of course is that current members will need to opt in to the new payment and will do so at various times before their next charge cycle.

Is it feasible to use s2member_pro_payflow_rbp_for_user() array and grab the NEXTPAYMENT, AMT, and PAYPERIOD to create vars for the s2member modify account code?

We could manually set EOTs for these members, but we think it would be much better to notify them that a change need to be made and send them to an account update page that will allow them to update on the same schedule they are already on – so if the next payment is due on the 20th, and the come in to update, a check of time till next payment is made, and those days are added to the short code via variables for the trial period value.

I’m thinking the logic would go like this:
get user nextpayment value from paypal api array
if amt = current amt exit else if 2999 then
trim the year from the date
get today’s date and subtract from nextpayment date
set difference as trial period in short code

Has this been done before? Is there a better way of doing this?

Thanks.

List Of Topic Replies

Viewing 2 replies - 1 through 2 (of 2 total)
Author Replies
Author Replies
Posted: Wednesday Jun 19th, 2013 at 2:27 am #52170

All-righty then.

Solved my issue and thought i would share in case anyone else is in the same boat. Please note that this is specific processing for PayPal Pro Payflow accounts.

This allows you to offer the remainder of the current subscription as a free trial when users are updating. I’m using it with a “modify=1” form, which will recharge a user immediately when they submit. This way the renewal will come at the end of their subscription.

Solved this by pulling the nextpayment date from the s2member_pro_payflow_rbp_for_user() array.

<?php
    $arr=(s2member_pro_payflow_rbp_for_user()); //grab the paypal pro payflow array for the current user
    $theDate = $arr['NEXTPAYMENT']; //grab the 'mmddyyy' fromt he array
    $newDate = preg_replace("/(\d{2})(\d{2})(\d{4})/", "$1/$2/$3","$theDate"); //regex and insert to create mm/dd/yyyy date
    $now = strtotime("now");
    $fixed_time = strtotime("$newDate");
    $days_until_fixed_time = round(($fixed_time - $now) / ($seconds_in_one_day = 86400));
    $days_until_fixed_time = max(0,$days_until_fixed_time); //if less than 0, set at 0
    //echo $fixed_time." - " . $now . " = " . $days_until_fixed_time; // unmark to outout for testing
?>
<h2 id="bodytitle">We've lowered our pricing, and renamed your plan!</h2>
<div><p>To take advantage of our new lower pricing, you'll need to complete the information below before your account expires. We value your continued support!</p>
<?php if ($days_until_fixed_time < 0){ ?><p>Update today for this special offer!</p><?php } else { ?><p>You have <strong><?php echo $days_until_fixed_time; ?></strong> days to take advantage of this offer!</p><?php } ?></div>

set your trial period value in your short code with:

tp="<?php echo $days_until_fixed_time; ?>"
Posted: Wednesday Jun 19th, 2013 at 2:48 pm #52233
Bruce
Username: Bruce
Staff Member

Thanks for the info! Let us know if you have any other questions.

Viewing 2 replies - 1 through 2 (of 2 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.