/// <summary> /// Handle ConfirmPreapproval API call /// </summary> /// <param name="context"></param> private void ConfirmPreapproval(HttpContext context) { NameValueCollection parameters = context.Request.Params; ConfirmPreapprovalRequest req = new ConfirmPreapprovalRequest(new RequestEnvelope("en_US"), parameters["preapprovalKey"]); // Set optional parameters if (parameters["pin"] != "") req.pin = parameters["pin"]; if (parameters["fundingSourceId"] != "") req.fundingSourceId = parameters["fundingSourceId"]; // All set. Fire the request AdaptivePaymentsService service = new AdaptivePaymentsService(); ConfirmPreapprovalResponse resp = null; try { resp = service.ConfirmPreapproval(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)) { //nothing to add } displayResponse(context, "ConfirmPreapproval", keyResponseParams, service.getLastRequest(), service.getLastResponse(), resp.error, redirectUrl); }
/// <summary> /// Handle ConfirmPreapproval API call /// </summary> /// <param name="contextHttp"></param> private void ConfirmPreapproval(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. // preapproval key : (Required) A preapproval key that identifies the preapproval for which you want to retrieve details. The preapproval key is returned in the PreapprovalResponse message ConfirmPreapprovalRequest request = new ConfirmPreapprovalRequest(new RequestEnvelope("en_US"), parameters["preapprovalKey"]); // Set optional parameters //The sender's personal identification number, which was specified //when the sender signed up for a preapproval. if (parameters["pin"] != string.Empty) request.pin = parameters["pin"]; //Funding source ID. if (parameters["fundingSourceId"] != string.Empty) request.fundingSourceId = parameters["fundingSourceId"]; AdaptivePaymentsService service = null; ConfirmPreapprovalResponse 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.ConfirmPreapproval(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)) { //nothing to add } Display(contextHttp, "ConfirmPreapproval", responseValues, service.getLastRequest(), service.getLastResponse(), response.error, redirectUrl); }