/// <summary> /// Process a payment transaction /// </summary> /// <param name="request">A PayPalRequest object containing the information to process.</param> /// <returns>A PayPalResponse object with the payment gateway's response.</returns> public RecurringCreditCardInquiryResponse ProcessTransaction(RecurringCreditCardInquiryRequest request) { RecurringCreditCardInquiryResponse response = new RecurringCreditCardInquiryResponse(); PayflowNETAPI payflowNetApi = new PayflowNETAPI(request.HostAddress, request.HostPort, request.TimeOut); string apiResponse = payflowNetApi.SubmitTransaction(request.ParmList.ToString(),PayflowUtility.RequestId); response = ParseApiResponse(apiResponse); return response; }
/// <summary> /// Parse a string response from PayPal into the PayPalResponse object. /// </summary> /// <param name="apiResponse">PayPal's API response</param> /// <returns>Our PayPalResponse Service object.</returns> private RecurringCreditCardInquiryResponse ParseApiResponse(string apiResponse) { RecurringCreditCardInquiryResponse response = new RecurringCreditCardInquiryResponse(); Dictionary<string, string> responseDictionary = new Dictionary<string, string>(); string[] splitResponse = apiResponse.Split('&'); foreach (string s in splitResponse) { string[] pair = s.Split('='); if (pair.Length >= 2) { responseDictionary.Add(pair[0], pair[1]); } } response.Acct = GetDictionaryItem(responseDictionary, "ACCT"); response.ExpDate = GetDictionaryItem(responseDictionary, "EXPDATE"); response.AggregateAmt = GetDictionaryItem(responseDictionary, "AGGREGATEAMT"); response.AggregateOptionalAmt = GetDictionaryItem(responseDictionary, "AGGREGATEOPTIONALAMT"); response.Amt = GetDictionaryItem(responseDictionary, "AMT"); response.City = GetDictionaryItem(responseDictionary, "CITY"); response.CompanyName = GetDictionaryItem(responseDictionary, "COMPANYNAME"); response.Country = GetDictionaryItem(responseDictionary, "COUNTRY"); response.Email = GetDictionaryItem(responseDictionary, "EMAIL"); response.End = GetDictionaryItem(responseDictionary, "END"); response.FirstName = GetDictionaryItem(responseDictionary, "FIRSTNAME"); response.LastName = GetDictionaryItem(responseDictionary, "LASTNAME"); response.MaxFailPayments = GetDictionaryItem(responseDictionary, "MAXFAILPAYMENTS"); response.MiddleName = GetDictionaryItem(responseDictionary, "MIDDLENAME"); response.Name = GetDictionaryItem(responseDictionary, "NAME"); response.NextPayment = GetDictionaryItem(responseDictionary, "NEXTPAYMENT"); response.NumFailPayments = GetDictionaryItem(responseDictionary, "NUMFAILPAYMENTS"); response.PaymentsLeft = GetDictionaryItem(responseDictionary, "PAYMENTSLEFT"); response.PayPeriod = GetDictionaryItem(responseDictionary, "PAYPERIOD"); response.PhoneNum = GetDictionaryItem(responseDictionary, "PHONENUM"); response.ProfileId = GetDictionaryItem(responseDictionary, "PROFILEID"); response.ProfileName = GetDictionaryItem(responseDictionary, "PROFILENAME"); response.RespMsg = GetDictionaryItem(responseDictionary, "RESPMSG"); response.Result = GetDictionaryItem(responseDictionary, "RESULT"); response.RetryNumDays = GetDictionaryItem(responseDictionary, "RETRYNUMDAYS"); response.Start = GetDictionaryItem(responseDictionary, "START"); response.State = GetDictionaryItem(responseDictionary, "STATE"); response.Status = GetDictionaryItem(responseDictionary, "STATUS"); response.Street = GetDictionaryItem(responseDictionary, "STREET"); response.Tender = GetDictionaryItem(responseDictionary, "TENDER"); response.Term = GetDictionaryItem(responseDictionary, "TERM"); response.Zip = GetDictionaryItem(responseDictionary, "ZIP"); return response; }