1

I created an endpoint (Endpoint) for the webhook part in Authorize.Net and when I create subscription for a user from web app, I get the following in the request body (Am using Beeceptor for the endpoint):

{
    "notificationId": "79780e46-c62d-4620-b4fb-e8c29366b2ec",
    "eventType": "net.authorize.customer.subscription.created",
    "eventDate": "2021-05-08T17:23:57.7129026Z",
    "webhookId": "3b2fd08b-a7c4-4f29-95b5-8330958d6031",
    "payload": {
        "name": "AT",
        "amount": 3.00,
        "status": "active",
        "profile": {
            "customerProfileId": 1518406781,
            "customerPaymentProfileId": 1517676588
        },
        "entityName": "subscription",
        "id": "7397362"
    }
}

I followed the link to create the endpoint - Webhook

I believe, am close enough for webhook notifications. But can anyone suggest when the monthly subscription is charged using Authorize.Net, how the response body is passed to endpoint with the webhook like is it jSon data or something similar (Obviously jSon, I believe) or what fields will it return in response (SubscriptionId, Date)? In the documentation, they trigger different event to notify with Webhook. My final goal is to retrieve that a subscriber has been charged for a month and this should be saved in database for future use. Though I just started trying with it, will like to have some feedback on it in advance - Thanks.

N.B: Below image is the output when an event is triggered using Webhook.

For regular transaction, I get the following using webhook notification:

{
    "notificationId": "c453f527-8b7c-407d-8ec7-b022188af4a7",
    "eventType": "net.authorize.payment.authcapture.created",
    "eventDate": "2021-05-08T17:51:20.5783303Z",
    "webhookId": "3b2fd08b-a7c4-4f29-95b5-8330958d6031",
    "payload": {
        "responseCode": 1,
        "authCode": "OT3UUE",
        "avsResponse": "Y",
        "authAmount": 1.00,
        "entityName": "transaction",
        "id": "60167299547"
    }
}

C# sample Code: Web request from C# web app

public string GetNotificationWithWebhook()
{
  string response = "";
 
  var url = "beeceptor endpoint here";

  var httpRequest = (HttpWebRequest)WebRequest.Create(url);
  var httpResponse = (HttpWebResponse)httpRequest.GetResponse();

  using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
  {
    response = streamReader.ReadToEnd();
  }

  return response;
}

Request body and response:

Request Details

John Conde
  • 217,595
  • 99
  • 455
  • 496
AT-2017
  • 3,114
  • 3
  • 23
  • 39

2 Answers2

1

The webhook notification will be almost exactly like a "regular" transaction but a subscription ID will also be included. So it should resemble:

{
    "notificationId": "c453f527-8b7c-407d-8ec7-b022188af4a7",
    "eventType": "net.authorize.payment.authcapture.created",
    "eventDate": "2021-05-08T17:51:20.5783303Z",
    "webhookId": "3b2fd08b-a7c4-4f29-95b5-8330958d6031",
    "payload": {
        "responseCode": 1,
        "authCode": "OT3UUE",
        "avsResponse": "Y",
        "authAmount": 1.00,
        "entityName": "transaction",
        "id": "60167299547",
        "subscriptionId": "1234567890"
    }
}
John Conde
  • 217,595
  • 99
  • 455
  • 496
  • So you mean I'll get this in the response body of that endpoint (The one I provided in the webhook settings) when the subscription charge is done? – AT-2017 May 12 '21 at 07:45
  • 1
    Correct. It's just another payment with a special characteristic: the subscription ID – John Conde May 12 '21 at 11:41
  • I got to learn many things on `Authorize.Net`. Thanks a lot for your time @John Conde and the documentation provided in the official website with sample codes. Though I learnt it in the official website but suppose in any case, the recurring payment failed (As it should be charged from `Authorize.Net` using user card details automatically), I believe, a response will be sent to website with subscription id as above that you shared. The failure could be anything, say endpoint exception or card expiration. – AT-2017 May 13 '21 at 14:40
1

I just tested. The subscriptionId field is not the part of Payload of net.authorize.payment.authcapture.created.

So the solution is to use id(transactionid) to call "Get Transaction Details" API which returns the subscription fields.

Reference: https://community.developer.cybersource.com/t5/Integration-and-Testing/net-authorize-payment-authcapture-created-does-not-have/td-p/63234

findcaiyzh
  • 647
  • 3
  • 7