The Foxy forums are on the move!

We're in the process of moving our forums over to a new system, and so these forums are now read-only.
If you have a question about your store in the meantime, please don't hesitate to reach out to us via email.

questions about the FoxySubscriptionData

itisnot_meitisnot_me Member
in Help edited January 2011
ok so i have started to take my next phase in my development and i have some questions so i get it right. its just mostly what i need to put where.
if (isset($_POST["FoxySubscriptionData"])) {
		$FoxyData_encrypted = urldecode($_POST["FoxySubscriptionData"]);
		$FoxyData_decrypted = rc4crypt::decrypt($DataFeedKey,$FoxyData_encrypted);
 
		// make sure we have a valid character encoding
		$enc = mb_detect_encoding($FoxyData_decrypted);
		$FoxyData_decrypted = mb_convert_encoding($FoxyData_decrypted, 'UTF-8', $enc);
		$FoxyDataArray = new SimpleXMLElement($FoxyData_decrypted);
		foreach($FoxyDataArray->subscriptions->subscription AS $subscription) {
			foreach($subscription->transaction_details->transaction_detail AS $transaction_detail) {
// do stuff here, collect data, etc...
What kind of stuff do i do here? collect the CC info and payment info?
			}
			$canceled = 0;
			$sendReminder = 0;
			if (date("Y-m-d",strtotime("now")) == date("Y-m-d", strtotime($subscription->end_date))) {
				// this entry was cancelled today...
				$canceled = 1;
			}
			if (!$canceled && $subscription->past_due_amount > 0) {
				$failedDays = floor((strtotime("now") - strtotime($subscription->transaction_date)) / (60 * 60 * 24));
				if ($failedDays > $failedDaysBeforeCancel) {
					$canceled = 1;
				} else {
					if (($failedDays % $billingReminderFrequencyInDays) == 0) {
						$sendReminder = 1;
					}
				}
			}
			if ($canceled) {
// send emails, update your database, etc...
This is where i cancel the account that i have created for them and maybe a goodbye email?
			}
			if ($sendReminder) {
// send reminder emails, etc...
Not sure what this one is supposed to do.
			}
		}
		// send emails to customers with soon to expire credit cards. Ignore already expired cards, since they should have already been
		// sent an email when their payment failed.
		if (in_array(date("j"),$updatePaymentMethodReminderDaysOfTheMonth)) {
			foreach($FoxyDataArray->payment_methods_soon_to_expire->customer AS $customer) {
				if (mktime(0,0,0,$customer->cc_exp_month+1, 1, $customer->cc_exp_year+0) > strtotime("now")) {
// email reminders
This is where i send reminder emails saying that there CC is going to exprire soon and they should update there info?
				}
			}
		}
	} else {
		print "error";
	}
Comments
  • brettbrett FoxyCart Team
    We'll see if we can flesh out that example script with usable defaults. Ping this thread in a few days if you don't see a response.
  • Ping
    

    Pong.. haha i had to do it.

    i know that it is the weekend but this will hopefully be one the top for monday.
  • brettbrett FoxyCart Team
    @itisnot_me, can you clarify what you'd _like_ to see? To answer your original question...
    // do stuff here, collect data, etc...
    What kind of stuff do i do here? collect the CC info and payment info?

    That's where you could look at the transaction (the products within it) to figure out what you're dealing with. For example, is this for a VIP Membership or a Peon Membership? What is the product code to enable or disable access in a separate system? Is it for a customer that exists in your database already? Etc. You don't really have to do anything here unless you have specific needs.
    // send emails, update your database, etc...
    This is where i cancel the account that i have created for them and maybe a goodbye email?
    Yup on both counts. A goodbye email is probably worth doing. (We do it for FoxyCart, fwiw.)
    // send reminder emails, etc...
    Not sure what this one is supposed to do.
    That could be for sending reminder emails if the sub has a billing error or past due amount. Like, "Hi, you need to bring your account current, or click here to update your billing info, or click here to cancel."
    // email reminders
    This is where i send reminder emails saying that there CC is going to exprire soon and they should update there info?
    Yup. Exactly.

    So, all that said, does that cover the bases for you? If you're willing to put in a little elbow grease we're definitely willing to help you along, but at this moment we don't have the manpower to actually flesh this whole thing out with nice and tidy ready to go PHP.
  • i can do the elbow grease. i just didnt know what exactly everything ment to-do.

    if you could flush out the details about what each area does on the example script that would be helpful in the future for others to understand.

    if it helps i will put that on my todo list with that other project we talked about. Just have been really busy with all kinds of stuff
  • By the way, I wasn't wanting heavy lifting either, just more of a discussion of good business practices in general. For example, what types of dunning process make the most sense for cancellation, how frequently contacts should be made, how to handle cancellations, etc. Your last feedback Brett was really helpful, so thank you! But there's still some more that could be discussed I think.
  • lukeluke FoxyCart Team
    edited January 2011
    We'd love anyone's feedback on this. Each business will have different needs and requirements based on their services, customers and industry standards.

    Just to be transparent, we (FoxyCart) currently send out billing reminder emails every three days and we send "your card is about to expire" emails twice a month. If it's helpful, here's some of the types of decisions we make in the code:
    $failedDays = floor((strtotime("now") - strtotime($subscription->transaction_date)) / (60 * 60 * 24));
    if (date("Y-m-d",strtotime("now")) == date("Y-m-d", strtotime($subscription->end_date))) {
    if (($failedDays % $billingReminderFrequencyInDays) == 0) {
    if (in_array(date("j"),$updatePaymentMethodReminderDaysOfTheMonth)) {
    
  • Wish I had some clever. I just use the data to tableJoin with another DB to track who paid

    if (isset($_POST["FoxyData"])) {
    // decrypt the XML
    $FoxyData_encrypted = urldecode($_POST["FoxyData"]);
    $FoxyData_decrypted = rc4crypt::decrypt($key,$FoxyData_encrypted);


    // make sure we have a valid character encoding
    $enc = mb_detect_encoding($FoxyData_decrypted);
    $FoxyData_decrypted = mb_convert_encoding($FoxyData_decrypted, 'UTF-8', $enc);
    $FoxyDataArray = new SimpleXMLElement($FoxyData_decrypted);

    $custID = $FoxyDataArray->transactions->transaction->transaction_details->transaction_detail->transaction_detail_options->transaction_detail_option->product_option_value;
    $f_name = $FoxyDataArray->transactions->transaction->customer_first_name;
    $l_name = $FoxyDataArray->transactions->transaction->customer_last_name;
    $custPhone = $FoxyDataArray->transactions->transaction->customer_phone;
    $duesPaid = $FoxyDataArray->transactions->transaction->transaction_details->transaction_detail->product_price;
    $datePurchase = $FoxyDataArray->transactions->transaction->transaction_date;


    if (!mysql_connect('localhost','user','password')) die("no connection to MySQL");
    if (!mysql_select_db('myDB')) die("couldn't select database");

    mysql_query("INSERT INTO myTable (CUSTOMERID, FNAME, LNAME, PHONE, AMT_PAID, DATE_PURCHASED ) VALUES ('".mysql_escape_string($custID) ."', '".mysql_escape_string($f_name) ."', '".mysql_escape_string($l_name) ."','".mysql_escape_string($custPhone) ."','".mysql_escape_string($duesPaid) ."','".mysql_escape_string($datePurchase) ."')");
    }
  • lukeluke FoxyCart Team
    Hello @alloyking. Do you have a question for us or...? Sorry, I'm just a bit confused by your post.
Sign In or Register to comment.