/// <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 ACHRecurringSaleResponse ParseApiResponse(string apiResponse) { 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]); } } ACHRecurringSaleResponse response = new ACHRecurringSaleResponse() { AuthCode = GetDictionaryItem(responseDictionary, "AUTHCODE"), ProfileId = GetDictionaryItem(responseDictionary, "PROFILEID"), RespMsg = GetDictionaryItem(responseDictionary, "RESPMSG"), Result = GetDictionaryItem(responseDictionary, "RESULT"), Rpref = GetDictionaryItem(responseDictionary, "RPREF"), TrxPnref = GetDictionaryItem(responseDictionary, "TRXPNREF"), TrxRespMsg = GetDictionaryItem(responseDictionary, "TRXRESPMSG"), TrxResult = GetDictionaryItem(responseDictionary, "TRXRESULT") }; return response; }
/// <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 ACHRecurringSaleResponse ProcessTransaction(ACHRecurringSaleRequest request) { ACHRecurringSaleResponse response = new ACHRecurringSaleResponse(); PayflowNETAPI payflowNetApi = new PayflowNETAPI(request.HostAddress, request.HostPort, request.TimeOut); string apiResponse = payflowNetApi.SubmitTransaction(request.ParmList.ToString(), PayflowUtility.RequestId); response = ParseApiResponse(apiResponse); return response; }