sdk-php icon indicating copy to clipboard operation
sdk-php copied to clipboard

Possible to add order description to a subscription?

Open davellan opened this issue 10 years ago • 2 comments

I am using this php SDK and I don't see any documentation on how to add an order description for a subscription. It has been pretty frustrating, and I feel I am probably missing something obvious. I need this, as I use the description to pass along parameters needed by a third party app that are unique to each subscription (CRM Contact ID, CRM Order Id, CRM Product Id).

The only way I have found this possible is by using the old php API (https://github.com/AuthorizeNet/sdk-php/blob/master/doc/ARB.markdown), using the follow code:

define("AUTHORIZENET_API_LOGIN_ID", MERCHANT_LOGIN_ID);
define("AUTHORIZENET_TRANSACTION_KEY", MERCHANT_TRANSACTION_KEY);
$subscription = new AuthorizeNet_Subscription;
$subscription->orderDescription = $read_Description;
                
// Update Subscription
$request = new AuthorizeNetARB;
$response = $request->updateSubscription($response->getSubscriptionId(), $subscription);

This flow isn't ideal, because I am using two different APIs. I add the subscription with the new API, then update it (which is when I add the order description) with the old API.

I am hoping there is way I can use this SDK and add the order description to the subscription with one call. Any help is greatly appreciated!

davellan avatar Nov 11 '16 01:11 davellan

Hi @davellan

You can use the following code to set the description of subscription while creating a subscription:

$order = new AnetAPI\OrderType();
$order->setInvoiceNumber("1234354");        
$order->setDescription("Test description"); 
$subscription->setOrder($order); 

Note: You will also need to set the invoice number

akankaria avatar Nov 11 '16 09:11 akankaria

That worked well. Thank you @akankaria!

davellan avatar Nov 11 '16 16:11 davellan