cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

ARB Update Subscription, Only Certain Fields C# .NET

I am trying to update certain parameters of a subscription in C# .net MVC, as opposed to all, I am wondering if the following code approach is correct, and will leave other parameters (specified in the original subscription) unchanged. For instance, I am not specifying (or wanting to change) start date or remaning number of cycles. Would those remain unchanged, or am I approaching this wrong:

 

    public string UpdateCCSubscription( SubscriptionGateway gate, string subscriptionId, string customerId, string email, string subscriptionName, decimal amount, string cardNumber, int cardMonth, int cardYear, string billToFirst, string billToLast, string billToState, bool isMonthly ) {
      
      ISubscriptionRequest subscription;
      
      if (isMonthly)
      subscription = SubscriptionRequest.CreateMonthly( email, subscriptionName, amount );
      else
      subscription = SubscriptionRequest.CreateAnnual( email, subscriptionName, amount );

      subscription.SubscriptionID = subscriptionId;
      subscription.CardNumber = cardNumber;
      subscription.CardExpirationMonth = cardMonth;
      subscription.CardExpirationYear = cardYear;
      subscription.CustomerID = customerId;

      AuthorizeNet.Address billToAddress = new AuthorizeNet.Address();
      billToAddress.First = billToFirst;
      billToAddress.Last = billToLast;
      billToAddress.State = billToState;
      subscription.BillingAddress = billToAddress;

      try {
        gate.UpdateSubscription( subscription );
        return "Updated"; 
      }
      catch( Exception e ) {
        string s = e.Message;
        Console.WriteLine( "Failed to update SUB: " + e.ToString() );
        return null;
      }
    }

 

bobbydoogle
Contributor
1 ACCEPTED SOLUTION

Accepted Solutions
RaynorC1emen7
Expert
2 REPLIES 2

Look comparable to the sdks test

https://github.com/AuthorizeNet/sdk-dotnet/blob/master/AuthorizeNETtest/SubscriptionGatewayTest.cs

 

You can also test it with a test account

RaynorC1emen7
Expert

Okay the examples seem to show just required change fields being specified, I'll try to run some tests but it looks like it will not overwright fields that are not specified/changed.