Accessing data from the subscription datafeed

MindSculptMindSculpt Member
in Help edited February 2012
I'm currently working on implementing subscriptions. I'm using the subscription php example from the wiki ( and have a few questions about accessing the data that's automatically sent by FoxyCart.

Looking at the code from the above wiki sample, all I really need is to access is the transaction_id associated with a particular subscription order. Here's the part of the for loop in that example I'm dealing with, and my attempt at what I think the right way to access the information I need is:
foreach($FoxyDataArray->subscriptions->subscription AS $subscription) {
	foreach($subscription->transaction_details->transaction_detail AS $transaction_detail) {
		// do stuff here, collect data, etc...
		$customer_transaction_id = $transaction_detail->id;

Is this the correct approach? I'm looking at the subscription datafeed example in the wiki and I only see a subscription_id, but there is no subscription_id assigned in the transaction xml that I can tell. Thoughts?

  • lancelance Member, Community Support Member
    Hi, @MindSculpt,

    If I understand correctly, you're saying that the Subscription XML datafeed that you are receiving does not include a Subscription ID. Is that right? You mention the Transaction XML, but there is a different between the Transaction XML datafeed and the Subscription XML datafeed. The schema for the Subscription XML datafeed is defined here:

    Can you verify that you are trying to process the correct feed? If I've misunderstood the question, please provide some additional details to help with the troubleshooting.

  • MindSculptMindSculpt Member
    edited February 2012
    @lance Yeah I think you may have misunderstood. Let me try to explain it a different way.

    What fields out of the subscription feed are tied to the original transaction feed? Or more specifically, does the value of 'id' in the transaction xml map to 'transaction_id' of the subscription xml?
  • lukeluke FoxyCart Team
    Yes, the "id" of a transaction is the "transaction_id" of the subscription xml. The key piece of information you want to be linking off of, however, is the sub_token. That's the unique identifier per subscription that remains constant for every subscription payment. Does that help? To get information about an order, you want to use the transaction datafeed. The subscription datafeed is only useful for additional information such as past due subscriptions, cards that are about to expire or subscriptions that have just cancelled or are about to cancel.

    Does that help?
  • @luke Gotcha. My purposes are simple, and I just need a value from a canceled subscription to be caught in the subscription data feed so I can ping my database and remove features on my end. I might store the subtoken regardless just in case :)
Sign In or Register to comment.