/// <summary> /// Gets the payment options. /// </summary> /// <param name="storefront">The storefront.</param> /// <param name="visitorContext">The visitor context.</param> /// <returns> /// The manager response where the payment option list is returned in the Result. /// </returns> public ManagerResponse <GetPaymentOptionsResult, IEnumerable <PaymentOption> > GetPaymentOptions([NotNull] CommerceStorefront storefront, [NotNull] VisitorContext visitorContext) { Assert.ArgumentNotNull(storefront, "storefront"); Assert.ArgumentNotNull(visitorContext, "visitorContext"); var result = new GetPaymentOptionsResult { Success = false }; var cartResult = this.CartManager.GetCurrentCart(storefront, visitorContext); if (!cartResult.ServiceProviderResult.Success || cartResult.Result == null) { result.SystemMessages.ToList().AddRange(cartResult.ServiceProviderResult.SystemMessages); return(new ManagerResponse <GetPaymentOptionsResult, IEnumerable <PaymentOption> >(result, null)); } // TODO: CS Connect does not sport passing in a Cart. // var request = new GetPaymentOptionsRequest(storefront.ShopName, cart); var request = new GetPaymentOptionsRequest(storefront.ShopName); result = this.PaymentServiceProvider.GetPaymentOptions(request); Helpers.LogSystemMessages(result.SystemMessages, result); return(new ManagerResponse <GetPaymentOptionsResult, IEnumerable <PaymentOption> >(result, result.PaymentOptions.ToList())); }
public ManagerResponse <GetPaymentOptionsResult, IEnumerable <Entities.Payments.PaymentOption> > GetPaymentOptions(string shopName, Cart cart) { var request = new GetPaymentOptionsRequest(shopName, cart); GetPaymentOptionsResult paymentOptions = this.paymentServiceProvider.GetPaymentOptions(request); return(new ManagerResponse <GetPaymentOptionsResult, IEnumerable <Entities.Payments.PaymentOption> >(paymentOptions, paymentOptions.PaymentOptions.ToList())); }
private ReadOnlyCollection <PaymentOption> GetPaymentOptions(string shopName) { var paymentService = new PaymentServiceProvider(); var request = new GetPaymentOptionsRequest(shopName); return(paymentService.GetPaymentOptions(request).PaymentOptions); }
/** * 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)); }
/** * */ public GetPaymentOptionsResponse GetPaymentOptions(GetPaymentOptionsRequest GetPaymentOptionsRequest, string apiUsername) { string resp = call("GetPaymentOptions", GetPaymentOptionsRequest.toNVPString(""), apiUsername); NVPUtil util = new NVPUtil(); return(new GetPaymentOptionsResponse(util.parseNVPString(resp), "")); }
public virtual GetPaymentOptionsResponse GetPaymentOptions(GetPaymentOptionsRequest request) { Ensure.That(request, "request").IsNotNull(); var httpRequest = GetPaymentOptionsHttpRequestFactory.Create(request); var httpResponse = Connection.Send(httpRequest); return(ResponseFactory.Create <GetPaymentOptionsResponse>(httpResponse)); }
public GetPaymentOptionsResult GetPaymentOptions(string shopName, Cart cart) { Assert.ArgumentNotNullOrEmpty(shopName, nameof(shopName)); Assert.ArgumentNotNull(cart, nameof(cart)); var request = new GetPaymentOptionsRequest(shopName, cart); return(this.Execute(request, this.paymentServiceProvider.GetPaymentOptions)); }
/// <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> /// 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); 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); } displayResponse(context, "GetPaymentOptions", keyResponseParams, service.getLastRequest(), service.getLastResponse(), resp.error, redirectUrl); }
public ManagerResponse <GetPaymentOptionsResult, IEnumerable <PaymentOption> > GetPaymentOptions(string userId) { var result = new GetPaymentOptionsResult { Success = false }; var cartResult = CartManager.GetCart(userId); if (!cartResult.ServiceProviderResult.Success || cartResult.Result == null) { result.SystemMessages.ToList().AddRange(cartResult.ServiceProviderResult.SystemMessages); return(new ManagerResponse <GetPaymentOptionsResult, IEnumerable <PaymentOption> >(result, null)); } if (StorefrontContext.Current == null) { throw new InvalidOperationException("Cannot be called without a valid storefront context."); } var request = new GetPaymentOptionsRequest(StorefrontContext.Current.ShopName, cartResult.Result); result = PaymentServiceProvider.GetPaymentOptions(request); result.WriteToSitecoreLog(); return(new ManagerResponse <GetPaymentOptionsResult, IEnumerable <PaymentOption> >(result, result.PaymentOptions.ToList())); }
// # 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); }
/// <summary> /// /// </summary> ///<param name="getPaymentOptionsRequest"></param> public GetPaymentOptionsResponse GetPaymentOptions(GetPaymentOptionsRequest getPaymentOptionsRequest) { return(GetPaymentOptions(getPaymentOptionsRequest, (string)null)); }
public GetPaymentOptionsResponse GetPaymentOptions(GetPaymentOptionsRequest GetPaymentOptionsRequest) { return(GetPaymentOptions(GetPaymentOptionsRequest, null)); }