Beispiel #1
0
        private void RespondToUpdateAddressSuccessForMessage(NativeMessage message)
        {
            var shippingMethods = GetShippingMethods();

            if (shippingMethods.Count > 0)
            {
                // Set the first shipping method as the default
                CartState.SetShippingLine(shippingMethods[0].Identifier, (ShopifyError error) => {
                    if (error == null)
                    {
                        var summaryItems = GetSummaryItemsFromCheckout(CartState.CurrentCheckout);
                        message.Respond(new ApplePayEventResponse(ApplePayAuthorizationStatus.Success, summaryItems, shippingMethods).ToJsonString());
                    }
                    else
                    {
                        message.Respond(new ApplePayEventResponse(ApplePayAuthorizationStatus.Failure).ToJsonString());
                    }
                });
            }
            else
            {
                // Since there are no shipping methods available, it means that the shipping address that was set is unserviceable
                var summaryItems = GetSummaryItemsFromCheckout(CartState.CurrentCheckout);
                var payErrors    = new List <ApplePayError>();
                payErrors.Add(new ApplePayShippingAddressUnservicableError("Shipping address is in an unserviceable area"));
                message.Respond(new ApplePayEventResponse(ApplePayAuthorizationStatus.InvalidShippingPostalAddress, summaryItems, shippingMethods, payErrors).ToJsonString());
            }
        }
Beispiel #2
0
 /// <summary>
 /// Updates the shipping line and responds to Android plugin with the update status.
 /// </summary>
 /// <param name="shippingMethod">
 /// A <see cref="ShippingMethod"> object that will be used to update the shipping line.
 /// </param>
 /// <param name="message">
 /// A <see cref="NativeMessage"> object used to respond to the Android plugin side
 /// about the shipping line update.
 /// </param>
 private void UpdateShippingLine(ShippingMethod shippingMethod, NativeMessage message)
 {
     CartState.SetShippingLine(shippingMethod.Identifier, (ShopifyError error) => {
         if (error == null)
         {
             message.Respond(GetAndroidPayEventResponse().ToJsonString());
         }
         else
         {
             RespondError(message, error);
             OnFailure(error);
         }
     });
 }
Beispiel #3
0
        public void UpdateSummaryItemsForShippingIdentifier(string serializedMessage)
        {
            var message = NativeMessage.CreateFromJSON(serializedMessage);

            CartState.SetShippingLine(message.Content, (ShopifyError error) => {
                if (error == null)
                {
                    var summaryItems = GetSummaryItemsFromCheckout(CartState.CurrentCheckout);
                    message.Respond(new ApplePayEventResponse(ApplePayAuthorizationStatus.Success, summaryItems).ToJsonString());
                }
                else
                {
                    message.Respond(new ApplePayEventResponse(ApplePayAuthorizationStatus.Failure).ToJsonString());
                }
            });
        }