Reply
Contributor
Posts: 26
Registered: ‎10-27-2014
Accepted Solution

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;
      }
    }

 


Accepted Solutions
Solution
Accepted by topic author bobbydoogle
‎08-21-2015 01:58 AM
Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: ARB Update Subscription, Only Certain Fields C# .NET


All Replies
Solution
Accepted by topic author bobbydoogle
‎08-21-2015 01:58 AM
Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: ARB Update Subscription, Only Certain Fields C# .NET

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

Contributor
Posts: 26
Registered: ‎10-27-2014

Re: ARB Update Subscription, Only Certain Fields C# .NET

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.