Exemplo n.º 1
0
        private static void HandleOpen(GameSession session, PacketReader packet)
        {
            int itemId = packet.ReadInt();

            Item item = session.Player.Inventory.Items.Values.FirstOrDefault(x => x.Id == itemId);

            if (item == null)
            {
                return;
            }

            ShopMetadata shop = ShopMetadataStorage.GetShop(item.ShopID);

            if (shop == null)
            {
                Console.WriteLine($"Unknown shop ID: {item.ShopID}");
                return;
            }

            session.Send(ShopPacket.Open(shop));
            foreach (ShopItem shopItem in shop.Items)
            {
                session.Send(ShopPacket.LoadProducts(shopItem));
            }
            session.Send(ShopPacket.Reload());
            session.Send(SystemShopPacket.Open());
        }
Exemplo n.º 2
0
        public static ShopMetadata GetShopByItemUid(int itemUid)
        {
            List <ShopMetadata> shopList = shops.Values.ToList();
            ShopMetadata        shop     = shopList.FirstOrDefault(x => x.Items.Exists(z => z.UniqueId == itemUid));

            return(shop);
        }
        private void CreateNativeCheckout()
        {
            #if UNITY_IOS
            var bridge              = GetComponent <ApplePayEventReceiverBridge>();
            var checkout            = new iOSNativeCheckout(CurrentCart.State);
            var paymentSettingsJSON = new Dictionary <string, object>();
            var shopMetaData        = new ShopMetadata(StoreName, new PaymentSettings(paymentSettingsJSON));

            bridge.Receiver = checkout;
            checkout.Checkout("com.merchant.id", shopMetaData, () => {}, () => {}, (error) => {});
            #endif
        }
Exemplo n.º 4
0
        public static void HandleOpen(GameSession session, IFieldObject <Npc> npcFieldObject)
        {
            NpcMetadata metadata = NpcMetadataStorage.GetNpc(npcFieldObject.Value.Id);

            ShopMetadata shop = ShopMetadataStorage.GetShop(metadata.ShopId);

            if (shop == null)
            {
                Console.WriteLine($"Unknown shop ID: {metadata.ShopId}");
                return;
            }

            session.Send(ShopPacket.Open(shop));
            session.Send(ShopPacket.LoadProducts(shop.Items));
            session.Send(ShopPacket.Reload());
            session.Send(NpcTalkPacket.Respond(npcFieldObject, NpcType.Default, DialogType.None, 0));
        }
Exemplo n.º 5
0
        private static void HandleOpenViaItem(GameSession session, PacketReader packet)
        {
            byte unk    = packet.ReadByte();
            int  itemId = packet.ReadInt();

            List <Item> playerInventory = new(session.Player.Inventory.Items.Values);

            Item item = playerInventory.FirstOrDefault(x => x.Id == itemId);

            if (item == null)
            {
                return;
            }

            ShopMetadata shop = ShopMetadataStorage.GetShop(item.ShopID);

            session.Send(ShopPacket.Open(shop));
            session.Send(ShopPacket.LoadProducts(shop.Items));
        }
Exemplo n.º 6
0
        private static void HandleMapleArenaShop(GameSession session, PacketReader packet)
        {
            bool openShop = packet.ReadBool();

            if (!openShop)
            {
                return;
            }

            ShopMetadata shop = ShopMetadataStorage.GetShop(168);

            session.Send(ShopPacket.Open(shop));
            foreach (ShopItem shopItem in shop.Items)
            {
                session.Send(ShopPacket.LoadProducts(shopItem));
            }
            session.Send(ShopPacket.Reload());
            session.Send(SystemShopPacket.Open());
        }
Exemplo n.º 7
0
        /// <summary>
        /// Starts the native checkout flow.
        /// </summary>
        /// <param name="key">
        /// A Base64-encoded Android Pay public key found on the Shopify admin page.
        /// </param>
        /// <param name="shopMetadata">
        /// Some metadata associated with the current shop, such as name and payment settings.
        /// </param>
        /// <param name="success">
        /// Callback to be invoked when the checkout flow is successfully completed.
        /// </param>
        /// <param name="canceled">
        /// Callback to be invoked when the checkout flow is canceled by the user.
        /// </param>
        /// <param name="failure">
        /// Callback to be called when the checkout flow fails.
        /// </param>
        public void Checkout(
            string key,
            ShopMetadata shopMetadata,
            CheckoutSuccessCallback success,
            CheckoutCancelCallback canceled,
            CheckoutFailureCallback failure
            )
        {
            // TODO: Store callbacks and extract items we need from the cart to pass to Android Pay.
            OnSuccess  = success;
            OnCanceled = canceled;
            OnFailure  = failure;

            var checkout = CartState.CurrentCheckout;

            MerchantName = shopMetadata.Name; // TODO: Replace with Shop name
            var pricingLineItems       = GetPricingLineItemsFromCheckout(checkout);
            var pricingLineItemsString = pricingLineItems.ToJsonString();
            var currencyCodeString     = checkout.currencyCode().ToString("G");

            CountryCodeString = shopMetadata.PaymentSettings.countryCode().ToString("G");
            var requiresShipping = checkout.requiresShipping();

#if !SHOPIFY_MONO_UNIT_TEST
            object[] args =
            {
                MerchantName,
                key,
                pricingLineItemsString,
                currencyCodeString,
                CountryCodeString,
                requiresShipping
            };
            AndroidPayCheckoutSession.Call("checkoutWithAndroidPay", args);
            if (AndroidPayEventBridge == null)
            {
                AndroidPayEventBridge          = GlobalGameObject.AddComponent <AndroidPayEventReceiverBridge>();
                AndroidPayEventBridge.Receiver = this;
            }
#endif
        }
        /// <summary>
        /// Starts the process of making a payment through Apple Pay.
        /// </summary>
        /// <remarks>
        ///  Displays a payment interface to the user based on the contents of the Cart
        /// </remarks>
        /// <param name="key">Merchant ID for Apple Pay from the Apple Developer Portal</param>
        /// <param name="shopMetadata">The shop's metadata containing name and payment settings</param>
        /// <param name="success">Delegate method that will be notified upon a successful payment</param>
        /// <param name="failure">Delegate method that will be notified upon a failure during the checkout process</param>
        /// <param name="cancelled">Delegate method that will be notified upon a cancellation during the checkout process</param>
        public void Checkout(string key, ShopMetadata shopMetadata, CheckoutSuccessCallback success, CheckoutCancelCallback cancelled, CheckoutFailureCallback failure)
        {
            OnSuccess   = success;
            OnCancelled = cancelled;
            OnFailure   = failure;
            StoreName   = shopMetadata.Name;

#if !(SHOPIFY_MONO_UNIT_TEST || SHOPIFY_TEST)
            var checkout = CartState.CurrentCheckout;

            var supportedNetworksString = SerializedPaymentNetworksFromCardBrands(shopMetadata.PaymentSettings.acceptedCardBrands());

            var summaryItems  = GetSummaryItemsFromCheckout(checkout);
            var summaryString = Json.Serialize(summaryItems);

            var currencyCodeString = checkout.currencyCode().ToString("G");
            var countryCodeString  = shopMetadata.PaymentSettings.countryCode().ToString("G");

            var requiresShipping = checkout.requiresShipping();

            if (ApplePayEventBridge == null)
            {
                ApplePayEventBridge          = GlobalGameObject.AddComponent <ApplePayEventReceiverBridge>();
                ApplePayEventBridge.Receiver = this;
            }

            if (_CreateApplePaySession(GlobalGameObject.Name, key, countryCodeString, currencyCodeString, supportedNetworksString, summaryString, null, requiresShipping))
            {
                _PresentApplePayAuthorization();
            }
            else
            {
                var error = new ShopifyError(ShopifyError.ErrorType.NativePaymentProcessingError, "Unable to create an Apple Pay payment request. Please check that your merchant ID is valid.");
                OnFailure(error);
            }
#endif
        }
Exemplo n.º 9
0
        public static Packet Open(ShopMetadata shop)
        {
            PacketWriter pWriter = PacketWriter.Of(SendOp.SHOP);

            pWriter.WriteEnum(ShopMode.Open);
            pWriter.WriteInt(shop.TemplateId);
            pWriter.WriteInt(shop.Id);
            pWriter.WriteLong(shop.NextRestock);
            pWriter.WriteInt();
            pWriter.WriteShort(15);
            pWriter.WriteInt(shop.Category);
            pWriter.WriteBool(false);
            pWriter.WriteBool(shop.RestrictSales);
            pWriter.WriteBool(shop.CanRestock);
            pWriter.WriteBool(false);
            pWriter.WriteEnum(shop.ShopType);
            pWriter.WriteBool(shop.AllowBuyback);
            pWriter.WriteBool(false);
            pWriter.WriteBool(true);
            pWriter.WriteBool(false);
            pWriter.WriteMapleString(shop.Name);

            return(pWriter);
        }