2

When using the recurly API in PHP

$transaction = Recurly_Transaction::get($uuid);

the $transaction variable doesn't have an original_transaction_id field like there is in an exported csv of the transactions:

https://yoursubdomain.recurly.com/exports/new#transactions

How does someone get the original_transaction_id via the API?

Github issue opened: https://github.com/recurly/recurly-client-php/issues/216

PHPDave
  • 904
  • 1
  • 7
  • 15

2 Answers2

0

Looks like this is being discussed at https://github.com/recurly/recurly-client-php/issues/216

Rachel Quick
  • 1,804
  • 9
  • 8
0

::UPDATE 8.2.2016::
They have added the original_transaction_id in Version 2.6.0 of the PHP client:

Issue: https://github.com/recurly/recurly-client-php/issues/216#issuecomment-197558757

Pull: https://github.com/recurly/recurly-client-php/pull/238

::END UPDATE 8.2.2016::

//::HACK:: Only works when there is 1 purchase transaction.
$all_account_transactions = Recurly_TransactionList::getForAccount($refund_transaction->details[0]->account_code);
foreach ($all_account_transactions as $account_transaction) 
{
    if($account_transaction->action=="purchase" && 
       $account_transaction->subscription->get()->uuid == $refund_transaction->subscription->get()->uuid )
    {
        //This is a purchase transaction and its from the same subscription as the $refund_transaction.
        //If there's only 1 purchase transaction then this is your transaction that was refunded.
        //If there's multiple purchase transactions you'll have to figure out which one you want to apply the refund to
    }
}
PHPDave
  • 904
  • 1
  • 7
  • 15