/// <summary> /// Handle GetFundingPlans API call /// </summary> /// <param name="context"></param> private void GetFundingPlans(HttpContext context) { NameValueCollection parameters = context.Request.Params; GetFundingPlansRequest req = new GetFundingPlansRequest(new RequestEnvelope("en_US"), parameters["payKey"]); // All set. Fire the request AdaptivePaymentsService service = new AdaptivePaymentsService(); GetFundingPlansResponse resp = null; try { resp = service.GetFundingPlans(req); } catch (System.Exception e) { context.Response.Write(e.Message); return; } // Display response values. Dictionary<string, string> keyResponseParams = new Dictionary<string, string>(); string redirectUrl = null; if (!(resp.responseEnvelope.ack == AckCode.FAILURE) && !(resp.responseEnvelope.ack == AckCode.FAILUREWITHWARNING)) { int idx = 1; foreach (FundingPlan plan in resp.fundingPlan) { keyResponseParams.Add("Funding plan Id " + idx, plan.fundingPlanId); keyResponseParams.Add("Funding plan amount " + idx, plan.fundingAmount.amount + plan.fundingAmount.code ); idx++; } } displayResponse(context, "GetFundingPlans", keyResponseParams, service.getLastRequest(), service.getLastResponse(), resp.error, redirectUrl); }
/// <summary> /// Handle GetFundingPlans API call /// </summary> /// <param name="contextHttp"></param> private void GetFundingPlans(HttpContext contextHttp) { NameValueCollection parameters = contextHttp.Request.Params; // error language : (Required) RFC 3066 language in which error // messages are returned; by default it is en_US, which is the only language currently supported. // paykey : The key used to create the payment whose funding sources you want to determine. GetFundingPlansRequest request = new GetFundingPlansRequest(new RequestEnvelope("en_US"), parameters["payKey"]); AdaptivePaymentsService service = null; GetFundingPlansResponse response = null; try { // Configuration map containing signature credentials and other required configuration. // For a full list of configuration parameters refer in wiki page // (https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters) Dictionary<string, string> configurationMap = Configuration.GetAcctAndConfig(); // Creating service wrapper object to make an API call and loading // configuration map for your credentials and endpoint service = new AdaptivePaymentsService(configurationMap); response = service.GetFundingPlans(request); } catch (System.Exception e) { contextHttp.Response.Write(e.Message); return; } Dictionary<string, string> responseValues = new Dictionary<string, string>(); string redirectUrl = null; if (!(response.responseEnvelope.ack == AckCode.FAILURE) && !(response.responseEnvelope.ack == AckCode.FAILUREWITHWARNING)) { int idx = 1; foreach (FundingPlan plan in response.fundingPlan) { responseValues.Add("Funding plan Id " + idx, plan.fundingPlanId); responseValues.Add("Funding plan amount " + idx, plan.fundingAmount.amount + plan.fundingAmount.code ); idx++; } } Display(contextHttp, "GetFundingPlans", responseValues, service.getLastRequest(), service.getLastResponse(), response.error, redirectUrl); }