I am working on ARB Subscription and all the events relative to my needs are implemented, but i am having trouble in one of the events `net.authorize.payment.refund.created` where i try to get the subscription id against the transaction response when the event is fired and posted to my API endpoint.
I currently use the `GetTransactionDetailsController()` to execute the request like `$controller->executeWithApiReponse(AnetConstants\ANetEnvironment::SANDBOX)` and once response is received i use the following to get the subscription details from the transaction details response
$response->getTransaction()->getSubscription()->getId()
but this gives me error
"Call to a member function getId() on null" which means the `getSubscription()` isnt returning the object, the same code works for the normal transaction or `net.authorize.payment.authcapture.created` and display the subscription id associated with the transaction.
What am i doin wrong here , do i need to use some other route to get the subscription id when the Refund response is received?
โ01-10-2019 02:49 AM
What i have currently done is get the referenced Transaction Id by using
$response->getTransaction()->getRefTransId()
and then lokoup into my local databases for the transaction_id in the payment Logs table and backtrack the Subscription id saved against the user.
I would love to adapt the conventional way, other developers are following in order to aacomplish the same task i would be waiting for a reply.
โ01-10-2019 08:57 AM
โ01-10-2019 09:19 AM
โ01-10-2019 09:33 AM
I might have not explained it correctly but the $response is not for the refund request the refund request is made via backend admin panel on my site using the Authorize.net API PHP SDK , the request when completes, it fires the webhook net.authorize.payment.refund.created, the webhook is targetting my custom API endpoint where i need to send the notifications, there i get the payload for the event and the Refund Transaction ID i pick that id and send a transaction details request and in response to the request i am trying to get the subscription, i hope i made it more clear what i am trying to do.
โ01-10-2019 11:00 AM
โ01-10-2019 11:58 AM
You can call the getTransactionDetails API to get the subscriptionID linked to it .
subscription | Contains subscription information. |
|
id | The subscription ID. |
Numeric string.
|
payNum | Identifies the number of this transaction, in terms of how many transactions have been submitted for this subscription. For example, the third transaction processed for this subscription will return payNum set to 3 . |
Numeric string, between 1 and 999.
|
โ01-13-2019 08:03 PM