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