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.

Struggling with commissions

Home Forums Community Forum Struggling with commissions

This topic contains 2 replies, has 1 voice. Last updated by  Don Pezet 3 years, 4 months ago.

Topic Author Topic
Posted: Wednesday Aug 21st, 2013 at 10:40 pm #56390
Don Pezet
Username: dpezet

First, a little about my setup:
– WordPress Multisite v3.6
– s2Member Pro v130816
– Authorize.net is my payment processor
– iDevAffiliate Gold Edition v7.2

I am really struggling with getting commissions setup properly for my environment. Here is what I am trying to achieve:

1) Commissions should not be issued for people who cancel in their 7 day trial period.
2) Commissions should only be issued for the first payment, and not ARB renewals.

I have two types of access on my system: a monthly subscription and an annual subscription. Both subscriptions have a 7 day free trial. I use affiliate coupon codes entered in my Authorize.net pro forms to identify who the affiliate was that referred the customer. I want to issue a one time flat fee commission to the affiliate when I receive payment from the customer. I do not want to issue a commission in the event the customer cancels in the 7 day trial period. I also do not want to issue a commission for any ARB renewals (monthly or annual) that the customer may make. Here is what I have tried, and the issues I have run in to with each:

1) I started out using API/Signup Notifications. This worked well as only one commission notification was sent to iDevAffiliate and commissions were not issued on ARB renewals. However, this notification is sent out immediately upon signup, so if the user cancels during the 7 day trial iDevAffiliate still shows a commission. Is there a way to trigger a cancellation notification to iDevAffiliate if they cancel in their trial?

2) Next, I switched to API/Payment Notifications. This worked well as it wouldn’t issue a commission while a customer was in their trial period. As soon as they paid, the commission was issued. That solved the problem of issuing commissions on free trial cancellations. However, this notification triggers on ARB renewals so iDevAffiliate was receiving commission notices for payments I don’t want to issue commission for. Is there a variable I can include that indicates the payment number so I can filter it out on the iDevAffiliate side? For example, this is the customers 1st, 2nd, 3rd, 84th payment?

3) At this point, I decided the API.Notification and API/Tracking system wasn’t going to suite my needs as it is out of the box. So, I took a shot at writing my own filter. I figured I could do a hook in to the API/Payment Notification and filter the notifications based on how long it had been since the user signed up. I figured I could query s2member_paid_registration_time() I could limit when the notification was fired. For example, I could wait until after the 7 day trial period but cut it off before a monthly subscription renewed. So, only fire the payment notification if the s2member_paid_registration_time() returned a value between 8 and 27 days. With 8 days being greater than the 7 day trial, and 27 days being one day less than the shortest month of the year. However (and I’m guessing a little) this wasn’t precise enough. The free trial ends and the first payment occurs at the same time. So I couldn’t get this to work. Would I need to change the ranges to greater than 6 days 23 hours and 59 minutes to ensure that I catch the payment notification? Or is there another trick here?

4) Now I’m looking for other options. Is there a way to query what payment number this is? e.g. Is it the user’s first payment, or second? If so, I could use that to allow the payment notification to go through, or otherwise filter it out.

I suppose I should add a fifth option which would be that I could be a giant bone-head and there is some super simple way to do this and I am making it harder than I should. Either way, I am open to suggestions and willing to try anything.

If you have made it this far in my post you already deserve an award.

Thanks for all of your help,

Don Pezet

List Of Topic Replies

Viewing 2 replies - 1 through 2 (of 2 total)
Author Replies
Author Replies
Posted: Thursday Aug 22nd, 2013 at 5:40 pm #56467
Don Pezet
Username: dpezet

OK, here’s my latest stab at this one. First, I created an API/Signup Notification as follows:

http://www.idevaffiliate.com/12345/sale.php?idev_commission=%%cv1%%&idev_ordernum=%%subscr_id%%&affiliate_id=%%coupon_affiliate_id%%&ip_address=%%user_ip%%

Next, I created an API/Cancellation Notification as follows:

http://edutainmentlive.com/dpcustom/cancel-commission.php?subscr_id=%%subscr_id%%&user_id=%%user_id%%

Lastly, I created cancel-commission.php as follows:

<html>
<body>
<?php
include "../wp-load.php";
if(!empty($_GET['subscr_id']) && !empty($_GET['user_id']))
  {
    $user_id = (integer)$_GET['user_id'];
    $subscr_id = (integer)$_GET['subscr_id'];
    $user = new WP_User($user_id);
//    $s2member_paid_registration_times = get_user_option('s2member_paid_registration_times', $user_id);
    if(s2member_paid_registration_time('level',$user_id) < strtotime('8 days'))
      {
	    $url = 'http://www.idevaffiliate.com/12345/API/scripts/terminate_commission.php?secret=1234512345&order_number=' . $subscr_id;
	    @file_get_contents( $url );
      }
  }
  exit;
}
?>
</body>
</html>

I figured this would knock it out of the park. Commissions are only issued for initial payments. Then, if someone cancels during their 7 day trial, revoke the commission. If they are beyond their 7 day trial, let the commission stand. Unfortunately, it doesn’t work. It looks like s2member_paid_registration_time() is not returning a value when used this way. Can you spot what is wrong with my code?

Thanks,

Don

  • This reply was modified 3 years, 4 months ago by  Don Pezet.
Posted: Thursday Aug 22nd, 2013 at 9:35 pm #56489
Don Pezet
Username: dpezet

I think I figured this out. Does s2member_paid_registration_time() return a paid timestamp if the user is still in a free trial period? My guess is no, which is what was causing my issue. We don’t have free registrations on our site, so I just switched over to s2member_registration_time() and it worked like a champ. In case anyone finds this thread later on down the road, here is my working file for canceling the commission if the account is canceled while it is still in the trial period (7 days for my site):

<html>
<body>
<?php
include "../wp-load.php";
$user_id = (integer)$_GET['user_id'];
$subscr_id = (integer)$_GET['subscr_id'];
$user = new WP_User($user_id);
if(s2member_registration_time($user_id) < strtotime('8 days'))
  {
    $url = 'http://www.idevaffiliate.com/12345/API/scripts/terminate_commission.php?secret=12345678&order_number=' . $subscr_id;
    @file_get_contents( $url );
    exit;
  }
exit;
?>
</body>
</html>

Now that I have it working this way, I need to see if I can rewrite it as a notification hook instead so I am not dependent on PHP calls outside of WordPress. At least I know it does work.

Don

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.