public GetPaymentOptionsResponse GetPaymentOptions(GetPaymentOptionsRequest GetPaymentOptionsRequest) { return GetPaymentOptions(GetPaymentOptionsRequest, null); }
/// <summary> /// Handle GetPaymentOptions API call /// </summary> /// <param name="context"></param> private void GetPaymentOptions(HttpContext context) { NameValueCollection parameters = context.Request.Params; GetPaymentOptionsRequest req = new GetPaymentOptionsRequest( new RequestEnvelope("en_US"), parameters["payKey"]); // All set. Fire the request AdaptivePaymentsService service = new AdaptivePaymentsService(); GetPaymentOptionsResponse resp = null; try { resp = service.GetPaymentOptions(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(ReceiverOptions option in resp.receiverOptions) { keyResponseParams.Add("Receiver option " + idx, option.description); if(option.receiver.email != null) keyResponseParams.Add("Receiver email " + idx, option.receiver.email); idx++; } if(resp.displayOptions != null) { keyResponseParams.Add("Business name", resp.displayOptions.businessName); keyResponseParams.Add("Header image", resp.displayOptions.headerImageUrl); keyResponseParams.Add("Email header image", resp.displayOptions.emailHeaderImageUrl); } keyResponseParams.Add("Shipping address Id", resp.shippingAddressId); //Selenium Test Case keyResponseParams.Add("Acknowledgement", resp.responseEnvelope.ack.ToString()); } displayResponse(context, "GetPaymentOptions", keyResponseParams, service.getLastRequest(), service.getLastResponse(), resp.error, redirectUrl); }
/** * */ public GetPaymentOptionsResponse GetPaymentOptions(GetPaymentOptionsRequest GetPaymentOptionsRequest, string apiUsername) { string resp = call("GetPaymentOptions", GetPaymentOptionsRequest.toNVPString(""), apiUsername); NVPUtil util = new NVPUtil(); return new GetPaymentOptionsResponse(util.parseNVPString(resp), ""); }
/// <summary> /// /// </summary> ///<param name="getPaymentOptionsRequest"></param> ///<param name="credential">An explicit ICredential object that you want to authenticate this call against</param> public GetPaymentOptionsResponse GetPaymentOptions(GetPaymentOptionsRequest getPaymentOptionsRequest, ICredential credential) { IAPICallPreHandler apiCallPreHandler = new PlatformAPICallPreHandler(this.config, getPaymentOptionsRequest.ToNVPString(string.Empty), ServiceName, "GetPaymentOptions", credential); ((PlatformAPICallPreHandler) apiCallPreHandler).SDKName = SDKName; ((PlatformAPICallPreHandler) apiCallPreHandler).SDKVersion = SDKVersion; ((PlatformAPICallPreHandler) apiCallPreHandler).PortName = "AdaptivePayments"; NVPUtil util = new NVPUtil(); return GetPaymentOptionsResponse.CreateInstance(util.ParseNVPString(Call(apiCallPreHandler)), string.Empty, -1); }
/// <summary> /// /// </summary> ///<param name="getPaymentOptionsRequest"></param> public GetPaymentOptionsResponse GetPaymentOptions(GetPaymentOptionsRequest getPaymentOptionsRequest) { return GetPaymentOptions(getPaymentOptionsRequest,(string) null); }
/// <summary> /// Handle GetPaymentOptions API call /// </summary> /// <param name="contextHttp"></param> private void GetPaymentOptions(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 : (Required) The pay key that identifies the payment for which you want to get payment options. // This is the pay key you used to set the payment options. GetPaymentOptionsRequest request = new GetPaymentOptionsRequest(new RequestEnvelope("en_US"), parameters["payKey"]); AdaptivePaymentsService service = null; GetPaymentOptionsResponse 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.GetPaymentOptions(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(ReceiverOptions option in response.receiverOptions) { // Specifies information about each receiver. responseValues.Add("Receiver option " + idx, option.description); if(option.receiver.email != null) responseValues.Add("Receiver email " + idx, option.receiver.email); idx++; } if(response.displayOptions != null) { // The business name to display. // Note: // The headerImageUrl and businessName parameters are mutually exclusive; // only one of these fields can be used. If you specify both, the image will // take precedence over the business name. responseValues.Add("Business name", response.displayOptions.businessName); // The URL of the image that displays in the header of a payment page. // Use this to configure payment flows by passing a different image URL // for different scenarios. If set, it overrides the header image URL // specified in your account's Profile. The image dimensions // are 90 pixels high x 750 pixels wide. // Note: // The headerImageUrl and businessName parameters are mutually exclusive; // only one of these fields can be used. If you specify both, the image // will take precedence over the business name. responseValues.Add("Header image", response.displayOptions.headerImageUrl); // The URL of the image that displays in the in the header of customer emails. // The image dimensions are 43 pixels high x 240 pixels wide. responseValues.Add("Email header image", response.displayOptions.emailHeaderImageUrl); } // Sender's shipping address ID. responseValues.Add("Shipping address Id", response.shippingAddressId); responseValues.Add("Acknowledgement", response.responseEnvelope.ack.ToString()); } Display(contextHttp, "GetPaymentOptions", responseValues, service.getLastRequest(), service.getLastResponse(), response.error, redirectUrl); }
// # GetPaymentOptions API Operation // You use the GetPaymentOptions API operation to retrieve the payment options passed with the SetPaymentOptionsRequest. public GetPaymentOptionsResponse GetPaymentOptionsAPIOperation() { // Create the GetPaymentOptionsResponse object GetPaymentOptionsResponse responseGetPaymentOptions = new GetPaymentOptionsResponse(); try { // Request envelope object RequestEnvelope envelopeRequest = new RequestEnvelope(); // The code for the language in which errors are returned envelopeRequest.errorLanguage = "en_US"; // GetPaymentOptionsRequest which takes, // // * `Request Envelope` - Information common to each API operation, such // as the language in which an error message is returned. // * `Pay Key` - The pay key that identifies the payment for which you // want to set payment options. This is the pay key returned in the // PayResponse message. Action Type in PayRequest must be `CREATE` GetPaymentOptionsRequest getPaymentOptionsRequest = new GetPaymentOptionsRequest( envelopeRequest, "AP-1VB65877N5917862M"); // Create the service wrapper object to make the API call AdaptivePaymentsService service = new AdaptivePaymentsService(); // # API call // Invoke the GetPaymentOptions method in service wrapper object responseGetPaymentOptions = service.GetPaymentOptions(getPaymentOptionsRequest); // Response envelope acknowledgement string acknowledgement = "GetPaymentOptions API Operation - "; acknowledgement += responseGetPaymentOptions.responseEnvelope.ack.ToString(); logger.Info(acknowledgement + "\n"); Console.WriteLine(acknowledgement + "\n"); // # Success values if (responseGetPaymentOptions.responseEnvelope.ack.ToString().Trim().ToUpper().Equals("SUCCESS")) { // Response envelope acknowledgement acknowledgement = responseGetPaymentOptions.responseEnvelope.ack.ToString().Trim().ToUpper(); logger.Info(acknowledgement + "\n"); Console.WriteLine(acknowledgement + "\n"); // # Success values if (acknowledgement.Equals("SUCCESS")) { // Business Name you set in SetPaymentOptions logger.Info("Business Name : " + responseGetPaymentOptions.displayOptions.businessName + "\n"); Console.WriteLine("Business Name : " + responseGetPaymentOptions.displayOptions.businessName + "\n"); } // # Error Values else { List<ErrorData> errorMessages = responseGetPaymentOptions.error; foreach (ErrorData error in errorMessages) { logger.Debug("API Error Message : " + error.message); Console.WriteLine("API Error Message : " + error.message + "\n"); } } } } // # Exception log catch (System.Exception ex) { // Log the exception message logger.Debug("Error Message : " + ex.Message); Console.WriteLine("Error Message : " + ex.Message); } return responseGetPaymentOptions; }
/** *AUTO_GENERATED */ public GetPaymentOptionsResponse GetPaymentOptions(GetPaymentOptionsRequest getPaymentOptionsRequest, string apiUserName) { string response = Call("GetPaymentOptions", getPaymentOptionsRequest.ToNVPString(""), apiUserName); NVPUtil util = new NVPUtil(); return GetPaymentOptionsResponse.CreateInstance(util.ParseNVPString(response), "", -1); }