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.

Modifying monthly recurring amt w/ Authorize

Home Forums Community Forum Modifying monthly recurring amt w/ Authorize

This topic contains 4 replies, has 2 voices. Last updated by  Jason (Lead Developer) 3 years, 10 months ago.

Topic Author Topic
Posted: Tuesday Feb 12th, 2013 at 11:57 am #41572

Hey Guys,

I am a bit corn-fused…

I am using authorized.net and need to change my monthly billing amount based on the number of widgets being rented.

I was super concerned when I read this: http://www.s2member.com/forums/topic/how-to-setup-a-variable-monthly-bill/

Its says that once the amount is set it cant be changed due to the authorized.net rules. This didnt sound right because i quadruple checked with my authorized rep before pulling the trigger and was assured that from their side it could be done anytime.

Well i started digging into the links in the above post. and according to this doc: https://support.authorize.net/authkb/index?page=content&id=A507
Amount is NOT one of the restricted fields. so I contacted their tech support to reconfirm, and was once again assured the the amount field was definitely changeable within an active subscription.

So… (breathing) How can I go about this if my customers add or subtract a widget from their profile?

Thanks and please forgive me and this has been answered a million times, and I just couldn’t findificate it.

Craig

List Of Topic Replies

Viewing 4 replies - 1 through 4 (of 4 total)
Author Replies
Author Replies
Posted: Friday Feb 15th, 2013 at 12:31 am #41766
Staff Member

Thanks for your inquiry. ~ We appreciate your patience :-)

I’m reviewing this topic now.

Posted: Friday Feb 15th, 2013 at 1:10 am #41769
Staff Member

Thanks for your patience.

Yes, it appears this IS now possible. If you’re looking for a way to update the amount dynamically (i.e. based on a custom event that you have on your site), here is a PHP function that will accomplish this for you.

Please create this directory and file:
/wp-content/mu-plugins/s2-hacks.php
(NOTE: these are MUST USE plugins, see: http://codex.wordpress.org/Must_Use_Plugins)
(See also: http://www.s2member.com/kb/hacking-s2member/)

<?php
function update_authnet_arb_amount_for_user($user_id, $amount)
	{
		$xml = '<?xml version="1.0" encoding="utf-8"?>';
		
		$xml .= '<ARBUpdateSubscriptionRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">';
		
			$xml .= '<merchantAuthentication>';
				$xml .= '<name>'.esc_html($GLOBALS['WS_PLUGIN__']['s2member']['o']['pro_authnet_api_login_id']).'</name>';
				$xml .= '<transactionKey>'.esc_html($GLOBALS['WS_PLUGIN__']['s2member']['o']['pro_authnet_api_trans_key']).'</transactionKey>';
			$xml .= '</merchantAuthentication>';
		
			$xml .= '<subscriptionId>'.esc_html(get_user_option('s2member_subscr_id', $user_id)).'</subscriptionId>';
			
			$xml .= '<subscription>';
				$xml .= '<amount>'.esc_html($amount).'</amount>';
			$xml .= '</subscription>';
			
		$xml .= '</ARBUpdateSubscriptionRequest>';
		
		$url = 'https://'.
			(($GLOBALS['WS_PLUGIN__']['s2member']['o']['pro_authnet_sandbox'])
			? 'apitest.authorize.net' : 'api.authorize.net').
			'/xml/v1/request.api';
		
		$req['headers']['Accept'] = 'application/xml; charset=UTF-8';
		$req['headers']['Content-Type'] = 'application/xml; charset=UTF-8';
		
		return c_ws_plugin__s2member_utils_urls::remote($url, $xml, array_merge($req, array('timeout' => 20)));
	}

Now, you would simply call upon this function when you need to update the amount a User/Member is being charged. Here we obtain the current User’s ID, and then we pass in the new amount we want to charge them.

<?php update_authnet_arb_amount_for_user(get_current_user_ID(), '20.00'); ?>

The recurring amount is now changed to bill 20.00 on each recurring interval going forward.

Posted: Friday Feb 15th, 2013 at 3:51 am #41803

Jason, you are SO much smarter than you look…. WOOT WOOT !!!!

Really appreciate your help.

Craig.

Posted: Friday Feb 15th, 2013 at 8:24 pm #41920
Staff Member
Thanks (I think). lol
~ Glad I could help.
Viewing 4 replies - 1 through 4 (of 4 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.