Esempio n. 1
0
        private void CheckoutWithTokenizedPayment(TokenizedPaymentInput tokenizedPaymentInput, Checkout checkout, ApplePayEventHandlerCompletion callback)
        {
            CartState.CheckoutWithTokenizedPayment(tokenizedPaymentInput, (ShopifyError error) => {
                if (error == null)
                {
                    callback(null);
                }
                else
                {
                    ApplePayEventResponse response = new ApplePayEventResponse(ApplePayAuthorizationStatus.Failure);

                    // Check to see if this is a recoverable user error
                    if (error.Type == ShopifyError.ErrorType.UserError)
                    {
                        var userErrors = CartState.UserErrors;
                        var status     = GetUpdateRequestStatusFromCheckoutUserErrors(userErrors);

                        if (status.AuthorizationStatus != ApplePayAuthorizationStatus.Failure)
                        {
                            var summaryItems = GetSummaryItemsFromCheckout(CartState.CurrentCheckout);
                            response         = new ApplePayEventResponse(status.AuthorizationStatus, summaryItems, GetShippingMethods(), status.Errors);
                        }
                    }

                    callback(response);
                }
            });
        }
Esempio n. 2
0
        private void SetFinalCheckoutFieldsForPayment(NativePayment payment, Checkout checkout, ApplePayEventHandlerCompletion callback)
        {
            ShippingFields?shippingFields = null;

            if (checkout.requiresShipping())
            {
                shippingFields = new ShippingFields(payment.ShippingAddress, payment.ShippingIdentifier);
            }

            CartState.SetFinalCheckoutFields(payment.Email, shippingFields, (ShopifyError error) => {
                if (error == null)
                {
                    callback(null);
                }
                else
                {
                    ApplePayEventResponse response = new ApplePayEventResponse(ApplePayAuthorizationStatus.Failure);

                    // Check to see if this is a recoverable user error
                    if (error.Type == ShopifyError.ErrorType.UserError)
                    {
                        var userErrors = CartState.UserErrors;
                        var status     = GetUpdateRequestStatusFromShippingUserErrors(userErrors);

                        var summaryItems = GetSummaryItemsFromCheckout(CartState.CurrentCheckout);
                        if (status.AuthorizationStatus == ApplePayAuthorizationStatus.InvalidShippingPostalAddress)
                        {
                            response =
                                new ApplePayEventResponse(
                                    authorizationStatus: status.AuthorizationStatus,
                                    summaryItems: summaryItems,
                                    errors: status.Errors
                                    );
                        }
                        else if (status.AuthorizationStatus == ApplePayAuthorizationStatus.InvalidShippingContact)
                        {
                            response =
                                new ApplePayEventResponse(
                                    status.AuthorizationStatus,
                                    summaryItems,
                                    GetShippingMethods(),
                                    status.Errors
                                    );
                        }
                    }

                    callback(response);
                }
            });
        }