Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do you set 'includeTransactions'? #102

Closed
sjordan1975 opened this issue Jan 21, 2018 · 9 comments
Closed

How do you set 'includeTransactions'? #102

sjordan1975 opened this issue Jan 21, 2018 · 9 comments

Comments

@sjordan1975
Copy link

sjordan1975 commented Jan 21, 2018

The AuthorizeNet documentation references being able to set includeTransactions property:

[BOOLEAN] Indicates whether to include information about transactions for this subscription.

If set to true, information about the most recent 20 transactions for this subscription will be included in the response.

How is this done with the SDK?

Similar to #280

Thank you

@enterlight
Copy link

Could somebody paste the required code to get the recent transactions from the Get Subscription SDK call?

@enterlight
Copy link

@sjordan1975 I fiddled and fiddled and ended up making a php curl call using json just for that specific request. I will look at your forked project. Thanks for your help

@sjordan1975
Copy link
Author

sjordan1975 commented Jan 30, 2018

I suspect that includeTransactions support has been implemented in the underlying Authorize.net API; however, the PHP SDK is woefully out of date. And no sample code has been forthcoming from Authorize.net (earliest request is from June 2016)

So, for my purposes, I forked the PHP SDK:
https://github.com/sjordan1975/sdk-php

I implemented get ARB Transaction from Get Subscription sufficient for what I needed.

Specifically, I modified the following 4 files:
lib/net/authorize/api/contract/v1/ARBGetSubscriptionRequest.php
lib/net/authorize/api/contract/v1/ARBSubscriptionMaskedType.php
lib/net/authorize/api/yml/v1/ARBGetSubscriptionRequest.yml
lib/net/authorize/api/yml/v1/ARBSubscriptionMaskedType.yml

Immediately after setting setSubscriptionID in the sample code (https://github.com/AuthorizeNet/sample-code-php/blob/master/RecurringBilling/get-subscription-status.php) add the following:

$request->setIncludeTransactions(true);

Note: I have used TransactionDetailsType whereas I suspect the actual type should be something like ARBTransactionType, but the yaml definition is missing and I have not defined it

The result is for now not all transaction data is populated; HOWEVER, transId IS populated and this is good enough to make an additional API call to get Transaction Details.

Feel free to have at it. Code provided AS IS to the Community. YMMV

@brianmc
Copy link
Contributor

brianmc commented Feb 2, 2018

This is coming soon in the SDKs and we'll make sure to include it in sample code as well. We're trying to keep not more than a month behind API updates but the latest release has been a little delayed.

@ashtru
Copy link
Contributor

ashtru commented Feb 21, 2018

includeTransactions has been added to the ARBGetSubscription request as part of the latest release!
Kindly change your composer.json to use version 1.9.5 of authorizenet/authorizenet similar to the sample code composer.

@ashtru ashtru closed this as completed Feb 21, 2018
@sjordan1975
Copy link
Author

sjordan1975 commented Feb 21, 2018

@ashtru Thank you. I'll check it out.

It would also be nice to update the sample code to demonstrate how to use this functionality.

@ashtru
Copy link
Contributor

ashtru commented Feb 22, 2018

Thanks @sjordan1975 . The sample code is updated.

Happy Coding!
Authorize.Net

@sjordan1975
Copy link
Author

sjordan1975 commented Feb 22, 2018

Hi @ashtru I see you updated the sample code to set setIncludeTransactions to true

I think it would be helpful to update the section of code which displays results...

Example

Current code snippet:

{
    // Success
    echo "SUCCESS: GetSubscription:" . "\n";
    // Displaying the details
    echo "Subscription Name: " . $response->getSubscription()->getName(). "\n";
    echo "Subscription amount: " . $response->getSubscription()->getAmount(). "\n";
    echo "Subscription status: " . $response->getSubscription()->getStatus(). "\n";
    echo "Subscription Description: " . $response->getSubscription()->getProfile()->getDescription(). "\n";
    echo "Customer Profile ID: " .  $response->getSubscription()->getProfile()->getCustomerProfileId() . "\n";
    echo "Customer payment Profile ID: ". $response->getSubscription()->getProfile()->getPaymentProfile()->getCustomerPaymentProfileId() . "\n";
}

I suggest something like the follow (see comments inline):

{
    // Success
    echo "SUCCESS: GetSubscription:" . "\n";
    // Displaying the details
    echo "Subscription Name: " . $response->getSubscription()->getName(). "\n";
    echo "Subscription amount: " . $response->getSubscription()->getAmount(). "\n";
    echo "Subscription status: " . $response->getSubscription()->getStatus(). "\n";
    echo "Subscription Description: " . $response->getSubscription()->getProfile()->getDescription(). "\n";
    echo "Customer Profile ID: " .  $response->getSubscription()->getProfile()->getCustomerProfileId() . "\n";
    echo "Customer payment Profile ID: ". $response->getSubscription()->getProfile()->getPaymentProfile()->getCustomerPaymentProfileId() . "\n";

    echo "Previous transactions: " . "\n";
    // INSERT EXAMPLE LOOP OVER TRANSACTIONS RETURNED FROM CALL TO ARBGetSubscriptionRequest
}

The goal is to help future devs as much as possible; you want to make it easy for people to use and want to use the SDK (IMHO)

I integrated the updated code into my codebase and it's working. Thank you. However ...

I noticed that from the documentation for arbTransaction:

* response 
* Contains explanatory text about the transaction.  
* String.For example, "The credit card has expired."

There is no success flag/code for payment. If I want to know if a payment was actually successful, I have to check the value of response which is This transaction has been approved. on success.

This seems very fragile and prone to potential error if the SDK message changes even slightly in the future. I might suggest a success code of some kind.

@ashtru
Copy link
Contributor

ashtru commented Feb 23, 2018

Thanks again for the suggestion, @sjordan1975 . @kikmak42 has updated the sample code .

Happy Coding!
Authorize.Net

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants