public static void IncludeOption(InterfaceOptions option)
 {
     if (!_interfaceLookup.Contains(option))
     {
         _interfaceLookup.Add(option);
         _interfaces.Add(option);
     }
 }
Пример #2
0
 protected override StageResult Init()
 {
     if (!Success(base.Init(), out StageResult r))
     {
         return(r);
     }
     InterfaceOptions.Add("Title", "Toxic Comment Classification Challenge Label Annotator.");
     return(StageResult.SUCCESS);
 }
Пример #3
0
        public void UserSelectionInInterfaceOptions(string strUserInterfaceResponse)
        {
            strUserInterfaceResponse = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(strUserInterfaceResponse.ToLower());

            if (!InterfaceOptions.TryParse(strUserInterfaceResponse, out this.myInterfaceOptions) /*|| !IsValidInterfaceOption(strUserInterfaceResponse)*/)
            {
                this.myInterfaceOptions = InterfaceOptions.NotValid;
            }
        }
        public static InitializePaymentRequest CreateSimple(Guid orderId, decimal totalAmount)
        {
            var interfaceOptions = new InterfaceOptions(
                InterfaceId.Aero,
                "SWE",
                "https://foo.com/payments/success".ToUri(),
                "https://foo.com/payments/cancel".ToUri(),
                "https://foo.com/payments/pending".ToUri());

            return(new InitializePaymentRequest(orderId, totalAmount, PaymentChannelId.Web, interfaceOptions));
        }
        public InitializePaymentRequestTests()
        {
            var interfaceOptions = new InterfaceOptions(
                InterfaceId.Aero,
                "SWE",
                "https://foo.com/payments/success".ToUri(),
                "https://foo.com/payments/cancel".ToUri(),
                "https://foo.com/payments/pending".ToUri());

            SUT = new InitializePaymentRequest(Guid.NewGuid(), 112.75m, PaymentChannelId.Web, interfaceOptions);
        }
        protected virtual InitializePaymentRequest InitInitializePaymentRequest()
        {
            var interfaceOptions = new InterfaceOptions(
                InterfaceId.Aero,
                "SWE",
                "https://foo.com/payments/success".ToUri(),
                "https://foo.com/payments/cancel".ToUri(),
                "https://foo.com/payments/pending".ToUri());

            var r = new InitializePaymentRequest(CreateOrderResponse.OrderId, CreateOrderRequest.TotalAmount, PaymentChannelId.Web, interfaceOptions);

            return(CreateOrderRequest.LineItems.Any()
                ? r.WithLineItems(CreateOrderRequest.LineItems)
                : r);
        }
Пример #7
0
        /// <summary>
        /// Creates a request object used with <see cref="IPaynovaClient.InitializePayment"/>
        /// to create a payment Session within Paynova's system.
        /// </summary>
        /// <param name="orderId">
        /// The unique identifier (GUID) that you received from Paynova
        /// in the response from <see cref="IPaynovaClient.CreateOrder(CreateOrderRequest)"/>.
        /// </param>
        /// <param name="totalAmount">
        /// The total amount that should be processed for this payment.
        /// This must be equal to or less than the original order amount
        /// and less than the original order amount minus any payments
        /// which have been already made on the order.
        /// For the majority of implementors, this will always be equal to
        /// the original amount. Lesser amounts would typically only be used
        /// in the use case where multiple payments are being made on the
        /// same order.
        /// </param>
        /// <param name="paymentChannelId">
        /// The channel of payment.
        /// Using helper factory method on <see cref="Model.PaymentChannelId"/>:
        /// PaymentChannelId.Web()
        /// Or if not yet added to helpers:
        /// new PaymentChannelId(1)
        /// </param>
        /// <param name="interfaceOptions">Used to configure the rendering of the interface.</param>
        public InitializePaymentRequest(Guid orderId, decimal totalAmount, PaymentChannelId paymentChannelId, InterfaceOptions interfaceOptions)
        {
            Ensure.That(orderId, "orderId").IsNotEmpty();
            Ensure.That(totalAmount, "totalAmount").IsGt(0);
            Ensure.That(interfaceOptions, "interfaceOptions").IsNotNull();

            OrderId          = orderId;
            TotalAmount      = totalAmount;
            PaymentChannelId = paymentChannelId;
            InterfaceOptions = interfaceOptions;

            InternalPaymentMethods = new List <PaymentMethod>();
            InternalCustomData     = new List <CustomDataField>();
            InternalLineItems      = new List <LineItem>();
        }
        /// <summary>
        /// To determine whether the given Interface is defined.<br />
        /// 判断给定的接口是否定义。
        /// </summary>
        /// <param name="type"></param>
        /// <param name="interfaceType"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        public static bool IsInterfaceDefined(Type type, Type interfaceType, InterfaceOptions options = InterfaceOptions.Default)
        {
            if (type is null || interfaceType is null)
            {
                return(false);
            }

            if (!interfaceType.IsInterface)
            {
                return(false);
            }

            var sourceInterfaceTypes = type.GetInterfaces();

            return(options switch
            {
                InterfaceOptions.Default => sourceInterfaceTypes.Contains(interfaceType),
                InterfaceOptions.IgnoreGenericArgs => IsInterfaceDefinedImpl(sourceInterfaceTypes, interfaceType),
                _ => sourceInterfaceTypes.Contains(interfaceType)
            });
Пример #9
0
        public PacketHandlers()
        {
            setPacketSizes();
            PacketHandler temp;

            temp = new ActionButton();
            handlers.Add(PacketId.CLOSE, temp); //Close
            handlers.Add(PacketId.ACTIONBUTTON, temp); //Actionbutton #1
            handlers.Add(PacketId.ACTIONBUTTON2, temp); //Actionbutton #2
            handlers.Add(PacketId.ACTIONBUTTON3, temp); //Actionbutton #3

            temp = new ClientAction();
            handlers.Add(PacketId.IDLE, temp); //Idle
            handlers.Add(PacketId.MOVE_CAMERA, temp); //Move camera
            handlers.Add(PacketId.PING, temp); //Ping
            handlers.Add(PacketId.FOCUS, temp); //Window focus
            handlers.Add(PacketId.CLICK_MOUSE, temp); //Mouse
            handlers.Add(PacketId.WINDOW_TYPE, temp); //Window type
            handlers.Add(PacketId.SOUND_SETTINGS, temp); //Toggle sound (sounds)

            temp = new Command();
            handlers.Add(PacketId.COMMAND, temp); //Commands

            temp = new Communication();
            handlers.Add(PacketId.ADD_FRIEND, temp); //Add friend
            handlers.Add(PacketId.DELETE_FRIEND, temp); //Delete friend
            handlers.Add(PacketId.ADD_IGNORE, temp); //Add ignore
            handlers.Add(PacketId.DELETE_IGNORE, temp); //Delete ignore
            handlers.Add(PacketId.SEND_PM, temp); //Send PM
            handlers.Add(PacketId.CLAN_RANKS, temp); //Set clan ranks
            handlers.Add(PacketId.CLAN_CHAT, temp); //Join clan chat
            handlers.Add(PacketId.PUBLIC, temp); //Public chat
            handlers.Add(PacketId.CLAN_KICK, temp); //Clan chat kick
            handlers.Add(PacketId.PRIVACY_SETTINGS, temp); //public/private/trade chat settings

            temp = new Walk();
            handlers.Add(PacketId.WALK_1, temp); //Walk
            handlers.Add(PacketId.WALK_2, temp); //Walk
            handlers.Add(PacketId.WALK_3, temp); //Walk

            temp = new PlayerInteract();
            handlers.Add(PacketId.ATTACK_PLAYER, temp); //Attack
            handlers.Add(PacketId.FOLLOW, temp); //Follow
            handlers.Add(PacketId.TRADE, temp); //Trade
            handlers.Add(PacketId.MAGIC_ON_PLAYER, temp); //Magic on player

            temp = new NPCInteract();
            handlers.Add(PacketId.NPC_FIRST_CLICK, temp); //Attack
            handlers.Add(PacketId.NPC_SECOND_CLICK, temp); //Second click
            handlers.Add(PacketId.NPC_THIRD_CLICK, temp); //Third click
            handlers.Add(PacketId.NPC_FOURTH_CLICK, temp); //Fourth click
            handlers.Add(PacketId.NPC_FIFTH_CLICK, temp); //Fifth click
            handlers.Add(PacketId.NPC_EXAMINE, temp); //Examine Npc
            handlers.Add(PacketId.MAGIC_ON_NPC, temp); //Magic on NPC
            handlers.Add(PacketId.ITEM_ON_NPC, temp); //Item on NPC

            temp = new ObjectInteract();
            handlers.Add(PacketId.OBJECT_FIRST_CLICK, temp); //First click
            handlers.Add(PacketId.OBJECT_SECOND_CLICK, temp); //Second click
            handlers.Add(PacketId.OBJECT_THIRD_CLICK, temp); //Third click
            handlers.Add(PacketId.OBJECT_FOURTH_CLICK, temp); //Fourth click
            handlers.Add(PacketId.OBJECT_EXAMINE, temp); //object examine

            temp = new ItemInteract();
            handlers.Add(PacketId.EQUIP, temp); //Equip item
            handlers.Add(PacketId.ITEM_ON_ITEM, temp); //Item used on item
            handlers.Add(PacketId.INV_CLICK, temp); //Inventory click item
            handlers.Add(PacketId.ITEM_ON_OBJECT, temp); //Item used on object
            handlers.Add(PacketId.ITEM_ON_GROUND_ITEM, temp); //Item used on ground item.
            handlers.Add(PacketId.INV_OPERATE, temp); //Operate option
            handlers.Add(PacketId.INV_DROP, temp); //Drop item
            handlers.Add(PacketId.PICKUP, temp); //Pick up item
            handlers.Add(PacketId.INV_SWAP_SLOT, temp); //Swap item slot 1
            handlers.Add(PacketId.INV_SWAP_SLOT2, temp); //Swap item slot 2
            handlers.Add(PacketId.INV_RIGHT_CLICK_OPTION1, temp); //Right click option 1
            handlers.Add(PacketId.INV_RIGHT_CLICK_OPTION2, temp); //Right click option 2
            handlers.Add(PacketId.INV_EXAMINE_ITEM, temp); //Inventory item examine

            temp = new InterfaceOptions();
            handlers.Add(PacketId.ENTER_AMOUNT, temp); //Enter amount
            handlers.Add(PacketId.ENTER_TEXT, temp); // Enter text
            handlers.Add(PacketId.INTERFACE_CLICK_1, temp); //Option 1
            handlers.Add(PacketId.INTERFACE_CLICK_2, temp); //Option 2
            handlers.Add(PacketId.INTERFACE_CLICK_3, temp); //Option 3
            handlers.Add(PacketId.INTERFACE_CLICK_4, temp); //Option 4
            handlers.Add(PacketId.INTERFACE_CLICK_5, temp); //Option 5
            handlers.Add(PacketId.INTERFACE_CLICK_6, temp); //Option 6
            handlers.Add(PacketId.INTERFACE_CLICK_7, temp); //Option 7
            handlers.Add(PacketId.INTERFACE_CLICK_8, temp); //Option 8
            handlers.Add(PacketId.INTERFACE_CLICK_9, temp); //Option 9
            handlers.Add(PacketId.INTERFACE_CLICK_10, temp); //Option 9
            handlers.Add(PacketId.GE_SEARCH, temp); //Grand exchange search

            temp = new Unused();
            handlers.Add(PacketId.REIGON_LOADING, temp); //Region loading, varied size
            handlers.Add(PacketId.PACKET_COUNT, temp); //Sent after any click which increases 'count' in getPackets
            handlers.Add(PacketId.CLIENT_VARIABLE_30, temp); //Sent if a client variable is 30..unknown
            handlers.Add(PacketId.DODGY_PACKET, temp); //Caused by a dodgy packet

            Console.WriteLine("Binded packetHandlers");
        }
Пример #10
0
        public override PaymentHtmlForm GenerateHtmlForm( Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary<string, string> settings )
        {
            order.MustNotBeNull( "order" );
              settings.MustNotBeNull( "settings" );
              settings.MustContainKey( "customerLanguageCode", "settings" );
              settings.MustContainKey( "testMode", "settings" );

              PaymentHtmlForm htmlForm = new PaymentHtmlForm();

              IPaynovaClient client = GetClient( settings );

              Currency currency = CurrencyService.Instance.Get( order.StoreId, order.CurrencyId );
              if ( !Iso4217CurrencyCodes.ContainsKey( currency.IsoCode ) ) {
            throw new Exception( "You must specify an ISO 4217 currency code for the " + currency.Name + " currency" );
              }
              try {
            //Create order request
            CreateOrderRequest createOrderRequest = new CreateOrderRequest( order.CartNumber, currency.IsoCode, order.TotalPrice.Value.WithVat ) {
              Customer = new Customer(),
              BillTo = new NameAndAddress(),
              ShipTo = new NameAndAddress()
            };

            #region Customer information

            createOrderRequest.Customer.EmailAddress = order.PaymentInformation.Email;
            createOrderRequest.Customer.Name.CompanyName = createOrderRequest.BillTo.Name.CompanyName = order.Properties[ settings.ContainsKey( "companyPropertyAlias" ) && !string.IsNullOrEmpty( settings[ "companyPropertyAlias" ] ) ? settings[ "companyPropertyAlias" ] : "company" ];
            createOrderRequest.Customer.Name.Title = createOrderRequest.BillTo.Name.Title = order.Properties[ settings.ContainsKey( "titlePropertyAlias" ) && !string.IsNullOrEmpty( settings[ "titlePropertyAlias" ] ) ? settings[ "titlePropertyAlias" ] : "title" ];
            createOrderRequest.Customer.Name.FirstName = createOrderRequest.BillTo.Name.FirstName = order.PaymentInformation.FirstName;
            createOrderRequest.Customer.Name.MiddleNames = createOrderRequest.BillTo.Name.MiddleNames = order.Properties[ settings.ContainsKey( "middleNamesPropertyAlias" ) && !string.IsNullOrEmpty( settings[ "middleNamesPropertyAlias" ] ) ? settings[ "middleNamesPropertyAlias" ] : "middleNames" ];
            createOrderRequest.Customer.Name.LastName = createOrderRequest.BillTo.Name.LastName = order.PaymentInformation.LastName;
            createOrderRequest.Customer.Name.Suffix = createOrderRequest.BillTo.Name.Suffix = order.Properties[ settings.ContainsKey( "suffixPropertyAlias" ) && !string.IsNullOrEmpty( settings[ "suffixPropertyAlias" ] ) ? settings[ "suffixPropertyAlias" ] : "suffix" ];
            createOrderRequest.Customer.HomeTelephone = order.Properties[ settings.ContainsKey( "homeTelephonePropertyAlias" ) && !string.IsNullOrEmpty( settings[ "homeTelephonePropertyAlias" ] ) ? settings[ "homeTelephonePropertyAlias" ] : "phone" ];
            createOrderRequest.Customer.WorkTelephone = order.Properties[ settings.ContainsKey( "workTelephonePropertyAlias" ) && !string.IsNullOrEmpty( settings[ "workTelephonePropertyAlias" ] ) ? settings[ "workTelephonePropertyAlias" ] : "workPhone" ];
            createOrderRequest.Customer.MobileTelephone = order.Properties[ settings.ContainsKey( "mobileTelephonePropertyAlias" ) && !string.IsNullOrEmpty( settings[ "mobileTelephonePropertyAlias" ] ) ? settings[ "mobileTelephonePropertyAlias" ] : "mobile" ];
            createOrderRequest.BillTo.Address.Street1 = order.Properties[ settings.ContainsKey( "street1PropertyAlias" ) && !string.IsNullOrEmpty( settings[ "street1PropertyAlias" ] ) ? settings[ "street1PropertyAlias" ] : "streetAddress" ];
            createOrderRequest.BillTo.Address.Street2 = order.Properties[ settings.ContainsKey( "street2PropertyAlias" ) && !string.IsNullOrEmpty( settings[ "street2PropertyAlias" ] ) ? settings[ "street2PropertyAlias" ] : "streetAddress2" ];
            createOrderRequest.BillTo.Address.Street3 = order.Properties[ settings.ContainsKey( "street3PropertyAlias" ) && !string.IsNullOrEmpty( settings[ "street3PropertyAlias" ] ) ? settings[ "street3PropertyAlias" ] : "streetAddress3" ];
            createOrderRequest.BillTo.Address.Street4 = order.Properties[ settings.ContainsKey( "street4PropertyAlias" ) && !string.IsNullOrEmpty( settings[ "street4PropertyAlias" ] ) ? settings[ "street4PropertyAlias" ] : "streetAddress4" ];
            createOrderRequest.BillTo.Address.City = order.Properties[ settings.ContainsKey( "cityPropertyAlias" ) && !string.IsNullOrEmpty( settings[ "cityPropertyAlias" ] ) ? settings[ "cityPropertyAlias" ] : "city" ];
            createOrderRequest.BillTo.Address.PostalCode = order.Properties[ settings.ContainsKey( "postalCodePropertyAlias" ) && !string.IsNullOrEmpty( settings[ "postalCodePropertyAlias" ] ) ? settings[ "postalCodePropertyAlias" ] : "zipCode" ];
            if ( order.PaymentInformation.CountryRegionId != null ) {
              createOrderRequest.BillTo.Address.RegionCode = CountryRegionService.Instance.Get( order.StoreId, order.PaymentInformation.CountryRegionId.Value ).RegionCode;
            }
            createOrderRequest.BillTo.Address.CountryCode = CountryService.Instance.Get( order.StoreId, order.PaymentInformation.CountryId ).RegionCode;

            createOrderRequest.ShipTo.Name.CompanyName = order.Properties[ settings.ContainsKey( "shipping_companyPropertyAlias" ) && !string.IsNullOrEmpty( settings[ "shipping_companyPropertyAlias" ] ) ? settings[ "shipping_companyPropertyAlias" ] : "shipping_company" ];
            createOrderRequest.ShipTo.Name.Title = order.Properties[ settings.ContainsKey( "shipping_titlePropertyAlias" ) && !string.IsNullOrEmpty( settings[ "shipping_titlePropertyAlias" ] ) ? settings[ "shipping_titlePropertyAlias" ] : "shipping_title" ];
            createOrderRequest.ShipTo.Name.FirstName = order.Properties[ settings.ContainsKey( "shipping_firstNamePropertyAlias" ) && !string.IsNullOrEmpty( settings[ "shipping_firstNamePropertyAlias" ] ) ? settings[ "shipping_firstNamePropertyAlias" ] : "shipping_firstName" ];
            createOrderRequest.ShipTo.Name.MiddleNames = order.Properties[ settings.ContainsKey( "shipping_middleNamesPropertyAlias" ) && !string.IsNullOrEmpty( settings[ "shipping_middleNamesPropertyAlias" ] ) ? settings[ "shipping_middleNamesPropertyAlias" ] : "shipping_middleNames" ];
            createOrderRequest.ShipTo.Name.LastName = order.Properties[ settings.ContainsKey( "shipping_lastNamePropertyAlias" ) && !string.IsNullOrEmpty( settings[ "shipping_lastNamePropertyAlias" ] ) ? settings[ "shipping_lastNamePropertyAlias" ] : "shipping_lastName" ];
            createOrderRequest.ShipTo.Name.Suffix = order.Properties[ settings.ContainsKey( "shipping_suffixPropertyAlias" ) && !string.IsNullOrEmpty( settings[ "shipping_suffixPropertyAlias" ] ) ? settings[ "shipping_suffixPropertyAlias" ] : "shipping_suffix" ];
            createOrderRequest.ShipTo.Address.Street1 = order.Properties[ settings.ContainsKey( "shipping_street1PropertyAlias" ) && !string.IsNullOrEmpty( settings[ "shipping_street1PropertyAlias" ] ) ? settings[ "shipping_street1PropertyAlias" ] : "shipping_streetAddress" ];
            createOrderRequest.ShipTo.Address.Street2 = order.Properties[ settings.ContainsKey( "shipping_street2PropertyAlias" ) && !string.IsNullOrEmpty( settings[ "shipping_street2PropertyAlias" ] ) ? settings[ "shipping_street2PropertyAlias" ] : "shipping_streetAddress2" ];
            createOrderRequest.ShipTo.Address.Street3 = order.Properties[ settings.ContainsKey( "shipping_street3PropertyAlias" ) && !string.IsNullOrEmpty( settings[ "shipping_street3PropertyAlias" ] ) ? settings[ "shipping_street3PropertyAlias" ] : "shipping_streetAddress3" ];
            createOrderRequest.ShipTo.Address.Street4 = order.Properties[ settings.ContainsKey( "shipping_street4PropertyAlias" ) && !string.IsNullOrEmpty( settings[ "shipping_street4PropertyAlias" ] ) ? settings[ "shipping_street4PropertyAlias" ] : "shipping_streetAddress4" ];
            createOrderRequest.ShipTo.Address.City = order.Properties[ settings.ContainsKey( "shipping_cityPropertyAlias" ) && !string.IsNullOrEmpty( settings[ "shipping_cityPropertyAlias" ] ) ? settings[ "shipping_cityPropertyAlias" ] : "shipping_city" ];
            createOrderRequest.ShipTo.Address.PostalCode = order.Properties[ settings.ContainsKey( "shipping_postalCodePropertyAlias" ) && !string.IsNullOrEmpty( settings[ "shipping_postalCodePropertyAlias" ] ) ? settings[ "shipping_postalCodePropertyAlias" ] : "shipping_zipCode" ];
            if ( order.ShipmentInformation.CountryRegionId != null ) {
              createOrderRequest.ShipTo.Address.RegionCode = CountryRegionService.Instance.Get( order.StoreId, order.ShipmentInformation.CountryRegionId.Value ).RegionCode;
            }
            if ( order.ShipmentInformation.CountryId != null ) {
              createOrderRequest.ShipTo.Address.CountryCode = CountryService.Instance.Get( order.StoreId, order.ShipmentInformation.CountryId.Value ).RegionCode;
            }

            #endregion

            CreateOrderResponse createOrderResponse = client.CreateOrder( createOrderRequest );

            //Initialize payment request
            InterfaceOptions interfaceOptions = new InterfaceOptions( InterfaceId.Aero, settings[ "customerLanguageCode" ], new Uri( teaCommerceContinueUrl ), new Uri( teaCommerceCancelUrl ), new Uri( teaCommerceContinueUrl ) );
            InitializePaymentRequest initializePaymentRequest = new InitializePaymentRequest( createOrderResponse.OrderId, order.TotalPrice.Value.WithVat, PaymentChannelId.Web, interfaceOptions );

            if ( settings.ContainsKey( "paymentMethods" ) && !string.IsNullOrEmpty( settings[ "paymentMethods" ] ) ) {
              initializePaymentRequest.WithPaymentMethods( settings[ "paymentMethods" ].Split( ',' ).Select( i => PaynovaPaymentMethod.Custom( int.Parse( i ) ) ) );
            }

            InitializePaymentResponse initializePaymentResponse = client.InitializePayment( initializePaymentRequest );
            htmlForm.Action = initializePaymentResponse.Url;
              } catch ( Exception e ) {

              }

              return htmlForm;
        }
        public PacketHandlers()
        {
            setPacketSizes();
            PacketHandler temp;

            temp = new ActionButton();
            handlers.Add(PacketId.CLOSE, temp);         //Close
            handlers.Add(PacketId.ACTIONBUTTON, temp);  //Actionbutton #1
            handlers.Add(PacketId.ACTIONBUTTON2, temp); //Actionbutton #2
            handlers.Add(PacketId.ACTIONBUTTON3, temp); //Actionbutton #3

            temp = new ClientAction();
            handlers.Add(PacketId.IDLE, temp);           //Idle
            handlers.Add(PacketId.MOVE_CAMERA, temp);    //Move camera
            handlers.Add(PacketId.PING, temp);           //Ping
            handlers.Add(PacketId.FOCUS, temp);          //Window focus
            handlers.Add(PacketId.CLICK_MOUSE, temp);    //Mouse
            handlers.Add(PacketId.WINDOW_TYPE, temp);    //Window type
            handlers.Add(PacketId.SOUND_SETTINGS, temp); //Toggle sound (sounds)

            temp = new Command();
            handlers.Add(PacketId.COMMAND, temp); //Commands

            temp = new Communication();
            handlers.Add(PacketId.ADD_FRIEND, temp);       //Add friend
            handlers.Add(PacketId.DELETE_FRIEND, temp);    //Delete friend
            handlers.Add(PacketId.ADD_IGNORE, temp);       //Add ignore
            handlers.Add(PacketId.DELETE_IGNORE, temp);    //Delete ignore
            handlers.Add(PacketId.SEND_PM, temp);          //Send PM
            handlers.Add(PacketId.CLAN_RANKS, temp);       //Set clan ranks
            handlers.Add(PacketId.CLAN_CHAT, temp);        //Join clan chat
            handlers.Add(PacketId.PUBLIC, temp);           //Public chat
            handlers.Add(PacketId.CLAN_KICK, temp);        //Clan chat kick
            handlers.Add(PacketId.PRIVACY_SETTINGS, temp); //public/private/trade chat settings

            temp = new Walk();
            handlers.Add(PacketId.WALK_1, temp); //Walk
            handlers.Add(PacketId.WALK_2, temp); //Walk
            handlers.Add(PacketId.WALK_3, temp); //Walk

            temp = new PlayerInteract();
            handlers.Add(PacketId.ATTACK_PLAYER, temp);   //Attack
            handlers.Add(PacketId.FOLLOW, temp);          //Follow
            handlers.Add(PacketId.TRADE, temp);           //Trade
            handlers.Add(PacketId.MAGIC_ON_PLAYER, temp); //Magic on player

            temp = new NPCInteract();
            handlers.Add(PacketId.NPC_FIRST_CLICK, temp);  //Attack
            handlers.Add(PacketId.NPC_SECOND_CLICK, temp); //Second click
            handlers.Add(PacketId.NPC_THIRD_CLICK, temp);  //Third click
            handlers.Add(PacketId.NPC_FOURTH_CLICK, temp); //Fourth click
            handlers.Add(PacketId.NPC_FIFTH_CLICK, temp);  //Fifth click
            handlers.Add(PacketId.NPC_EXAMINE, temp);      //Examine Npc
            handlers.Add(PacketId.MAGIC_ON_NPC, temp);     //Magic on NPC
            handlers.Add(PacketId.ITEM_ON_NPC, temp);      //Item on NPC


            temp = new ObjectInteract();
            handlers.Add(PacketId.OBJECT_FIRST_CLICK, temp);  //First click
            handlers.Add(PacketId.OBJECT_SECOND_CLICK, temp); //Second click
            handlers.Add(PacketId.OBJECT_THIRD_CLICK, temp);  //Third click
            handlers.Add(PacketId.OBJECT_FOURTH_CLICK, temp); //Fourth click
            handlers.Add(PacketId.OBJECT_FIFTH_CLICK, temp);  //Fifth click
            handlers.Add(PacketId.OBJECT_EXAMINE, temp);      //object examine

            temp = new ItemInteract();
            handlers.Add(PacketId.EQUIP, temp);                   //Equip item
            handlers.Add(PacketId.ITEM_ON_ITEM, temp);            //Item used on item
            handlers.Add(PacketId.INV_CLICK, temp);               //Inventory click item
            handlers.Add(PacketId.ITEM_ON_OBJECT, temp);          //Item used on object
            handlers.Add(PacketId.ITEM_ON_GROUND_ITEM, temp);     //Item used on ground item.
            handlers.Add(PacketId.INV_OPERATE, temp);             //Operate option
            handlers.Add(PacketId.INV_DROP, temp);                //Drop item
            handlers.Add(PacketId.PICKUP, temp);                  //Pick up item
            handlers.Add(PacketId.INV_SWAP_SLOT, temp);           //Swap item slot 1
            handlers.Add(PacketId.INV_SWAP_SLOT2, temp);          //Swap item slot 2
            handlers.Add(PacketId.INV_RIGHT_CLICK_OPTION1, temp); //Right click option 1
            handlers.Add(PacketId.INV_RIGHT_CLICK_OPTION2, temp); //Right click option 2
            handlers.Add(PacketId.INV_EXAMINE_ITEM, temp);        //Inventory item examine
            handlers.Add(PacketId.INV_EXAMINE_ITEM_GE, temp);     //Inventory item examine in GE_SELL_ITEM

            temp = new InterfaceOptions();
            handlers.Add(PacketId.ENTER_AMOUNT, temp);       //Enter amount
            handlers.Add(PacketId.ENTER_TEXT, temp);         // Enter text
            handlers.Add(PacketId.INTERFACE_CLICK_1, temp);  //Option 1
            handlers.Add(PacketId.INTERFACE_CLICK_2, temp);  //Option 2
            handlers.Add(PacketId.INTERFACE_CLICK_3, temp);  //Option 3
            handlers.Add(PacketId.INTERFACE_CLICK_4, temp);  //Option 4
            handlers.Add(PacketId.INTERFACE_CLICK_5, temp);  //Option 5
            handlers.Add(PacketId.INTERFACE_CLICK_6, temp);  //Option 6
            handlers.Add(PacketId.INTERFACE_CLICK_7, temp);  //Option 7
            handlers.Add(PacketId.INTERFACE_CLICK_8, temp);  //Option 8
            handlers.Add(PacketId.INTERFACE_CLICK_9, temp);  //Option 9
            handlers.Add(PacketId.INTERFACE_CLICK_10, temp); //Option 9
            handlers.Add(PacketId.GE_SEARCH, temp);          //Grand exchange search

            temp = new Unused();
            handlers.Add(PacketId.REIGON_LOADING, temp);     //Region loading, varied size
            handlers.Add(PacketId.PACKET_COUNT, temp);       //Sent after any click which increases 'count' in getPackets
            handlers.Add(PacketId.CLIENT_VARIABLE_30, temp); //Sent if a client variable is 30..unknown
            handlers.Add(PacketId.DODGY_PACKET, temp);       //Caused by a dodgy packet

            Console.WriteLine("Binded packetHandlers");
        }
Пример #12
0
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("customerLanguageCode", "settings");
            settings.MustContainKey("testMode", "settings");

            PaymentHtmlForm htmlForm = new PaymentHtmlForm();

            IPaynovaClient client = GetClient(settings);

            Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);

            if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
            {
                throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
            }
            try
            {
                //Create order request
                CreateOrderRequest createOrderRequest = new CreateOrderRequest(order.CartNumber, currency.IsoCode, order.TotalPrice.Value.WithVat)
                {
                    Customer = new Customer(),
                    BillTo   = new NameAndAddress(),
                    ShipTo   = new NameAndAddress()
                };

                #region Customer information

                createOrderRequest.Customer.EmailAddress     = order.PaymentInformation.Email;
                createOrderRequest.Customer.Name.CompanyName = createOrderRequest.BillTo.Name.CompanyName = order.Properties[settings.ContainsKey("companyPropertyAlias") && !string.IsNullOrEmpty(settings["companyPropertyAlias"]) ? settings["companyPropertyAlias"] : "company"];
                createOrderRequest.Customer.Name.Title       = createOrderRequest.BillTo.Name.Title = order.Properties[settings.ContainsKey("titlePropertyAlias") && !string.IsNullOrEmpty(settings["titlePropertyAlias"]) ? settings["titlePropertyAlias"] : "title"];
                createOrderRequest.Customer.Name.FirstName   = createOrderRequest.BillTo.Name.FirstName = order.PaymentInformation.FirstName;
                createOrderRequest.Customer.Name.MiddleNames = createOrderRequest.BillTo.Name.MiddleNames = order.Properties[settings.ContainsKey("middleNamesPropertyAlias") && !string.IsNullOrEmpty(settings["middleNamesPropertyAlias"]) ? settings["middleNamesPropertyAlias"] : "middleNames"];
                createOrderRequest.Customer.Name.LastName    = createOrderRequest.BillTo.Name.LastName = order.PaymentInformation.LastName;
                createOrderRequest.Customer.Name.Suffix      = createOrderRequest.BillTo.Name.Suffix = order.Properties[settings.ContainsKey("suffixPropertyAlias") && !string.IsNullOrEmpty(settings["suffixPropertyAlias"]) ? settings["suffixPropertyAlias"] : "suffix"];
                createOrderRequest.Customer.HomeTelephone    = order.Properties[settings.ContainsKey("homeTelephonePropertyAlias") && !string.IsNullOrEmpty(settings["homeTelephonePropertyAlias"]) ? settings["homeTelephonePropertyAlias"] : "phone"];
                createOrderRequest.Customer.WorkTelephone    = order.Properties[settings.ContainsKey("workTelephonePropertyAlias") && !string.IsNullOrEmpty(settings["workTelephonePropertyAlias"]) ? settings["workTelephonePropertyAlias"] : "workPhone"];
                createOrderRequest.Customer.MobileTelephone  = order.Properties[settings.ContainsKey("mobileTelephonePropertyAlias") && !string.IsNullOrEmpty(settings["mobileTelephonePropertyAlias"]) ? settings["mobileTelephonePropertyAlias"] : "mobile"];
                createOrderRequest.BillTo.Address.Street1    = order.Properties[settings.ContainsKey("street1PropertyAlias") && !string.IsNullOrEmpty(settings["street1PropertyAlias"]) ? settings["street1PropertyAlias"] : "streetAddress"];
                createOrderRequest.BillTo.Address.Street2    = order.Properties[settings.ContainsKey("street2PropertyAlias") && !string.IsNullOrEmpty(settings["street2PropertyAlias"]) ? settings["street2PropertyAlias"] : "streetAddress2"];
                createOrderRequest.BillTo.Address.Street3    = order.Properties[settings.ContainsKey("street3PropertyAlias") && !string.IsNullOrEmpty(settings["street3PropertyAlias"]) ? settings["street3PropertyAlias"] : "streetAddress3"];
                createOrderRequest.BillTo.Address.Street4    = order.Properties[settings.ContainsKey("street4PropertyAlias") && !string.IsNullOrEmpty(settings["street4PropertyAlias"]) ? settings["street4PropertyAlias"] : "streetAddress4"];
                createOrderRequest.BillTo.Address.City       = order.Properties[settings.ContainsKey("cityPropertyAlias") && !string.IsNullOrEmpty(settings["cityPropertyAlias"]) ? settings["cityPropertyAlias"] : "city"];
                createOrderRequest.BillTo.Address.PostalCode = order.Properties[settings.ContainsKey("postalCodePropertyAlias") && !string.IsNullOrEmpty(settings["postalCodePropertyAlias"]) ? settings["postalCodePropertyAlias"] : "zipCode"];
                if (order.PaymentInformation.CountryRegionId != null)
                {
                    createOrderRequest.BillTo.Address.RegionCode = CountryRegionService.Instance.Get(order.StoreId, order.PaymentInformation.CountryRegionId.Value).RegionCode;
                }
                createOrderRequest.BillTo.Address.CountryCode = CountryService.Instance.Get(order.StoreId, order.PaymentInformation.CountryId).RegionCode;

                createOrderRequest.ShipTo.Name.CompanyName   = order.Properties[settings.ContainsKey("shipping_companyPropertyAlias") && !string.IsNullOrEmpty(settings["shipping_companyPropertyAlias"]) ? settings["shipping_companyPropertyAlias"] : "shipping_company"];
                createOrderRequest.ShipTo.Name.Title         = order.Properties[settings.ContainsKey("shipping_titlePropertyAlias") && !string.IsNullOrEmpty(settings["shipping_titlePropertyAlias"]) ? settings["shipping_titlePropertyAlias"] : "shipping_title"];
                createOrderRequest.ShipTo.Name.FirstName     = order.Properties[settings.ContainsKey("shipping_firstNamePropertyAlias") && !string.IsNullOrEmpty(settings["shipping_firstNamePropertyAlias"]) ? settings["shipping_firstNamePropertyAlias"] : "shipping_firstName"];
                createOrderRequest.ShipTo.Name.MiddleNames   = order.Properties[settings.ContainsKey("shipping_middleNamesPropertyAlias") && !string.IsNullOrEmpty(settings["shipping_middleNamesPropertyAlias"]) ? settings["shipping_middleNamesPropertyAlias"] : "shipping_middleNames"];
                createOrderRequest.ShipTo.Name.LastName      = order.Properties[settings.ContainsKey("shipping_lastNamePropertyAlias") && !string.IsNullOrEmpty(settings["shipping_lastNamePropertyAlias"]) ? settings["shipping_lastNamePropertyAlias"] : "shipping_lastName"];
                createOrderRequest.ShipTo.Name.Suffix        = order.Properties[settings.ContainsKey("shipping_suffixPropertyAlias") && !string.IsNullOrEmpty(settings["shipping_suffixPropertyAlias"]) ? settings["shipping_suffixPropertyAlias"] : "shipping_suffix"];
                createOrderRequest.ShipTo.Address.Street1    = order.Properties[settings.ContainsKey("shipping_street1PropertyAlias") && !string.IsNullOrEmpty(settings["shipping_street1PropertyAlias"]) ? settings["shipping_street1PropertyAlias"] : "shipping_streetAddress"];
                createOrderRequest.ShipTo.Address.Street2    = order.Properties[settings.ContainsKey("shipping_street2PropertyAlias") && !string.IsNullOrEmpty(settings["shipping_street2PropertyAlias"]) ? settings["shipping_street2PropertyAlias"] : "shipping_streetAddress2"];
                createOrderRequest.ShipTo.Address.Street3    = order.Properties[settings.ContainsKey("shipping_street3PropertyAlias") && !string.IsNullOrEmpty(settings["shipping_street3PropertyAlias"]) ? settings["shipping_street3PropertyAlias"] : "shipping_streetAddress3"];
                createOrderRequest.ShipTo.Address.Street4    = order.Properties[settings.ContainsKey("shipping_street4PropertyAlias") && !string.IsNullOrEmpty(settings["shipping_street4PropertyAlias"]) ? settings["shipping_street4PropertyAlias"] : "shipping_streetAddress4"];
                createOrderRequest.ShipTo.Address.City       = order.Properties[settings.ContainsKey("shipping_cityPropertyAlias") && !string.IsNullOrEmpty(settings["shipping_cityPropertyAlias"]) ? settings["shipping_cityPropertyAlias"] : "shipping_city"];
                createOrderRequest.ShipTo.Address.PostalCode = order.Properties[settings.ContainsKey("shipping_postalCodePropertyAlias") && !string.IsNullOrEmpty(settings["shipping_postalCodePropertyAlias"]) ? settings["shipping_postalCodePropertyAlias"] : "shipping_zipCode"];
                if (order.ShipmentInformation.CountryRegionId != null)
                {
                    createOrderRequest.ShipTo.Address.RegionCode = CountryRegionService.Instance.Get(order.StoreId, order.ShipmentInformation.CountryRegionId.Value).RegionCode;
                }
                if (order.ShipmentInformation.CountryId != null)
                {
                    createOrderRequest.ShipTo.Address.CountryCode = CountryService.Instance.Get(order.StoreId, order.ShipmentInformation.CountryId.Value).RegionCode;
                }

                #endregion

                CreateOrderResponse createOrderResponse = client.CreateOrder(createOrderRequest);

                //Initialize payment request
                InterfaceOptions         interfaceOptions         = new InterfaceOptions(InterfaceId.Aero, settings["customerLanguageCode"], new Uri(teaCommerceContinueUrl), new Uri(teaCommerceCancelUrl), new Uri(teaCommerceContinueUrl));
                InitializePaymentRequest initializePaymentRequest = new InitializePaymentRequest(createOrderResponse.OrderId, order.TotalPrice.Value.WithVat, PaymentChannelId.Web, interfaceOptions);

                if (settings.ContainsKey("paymentMethods") && !string.IsNullOrEmpty(settings["paymentMethods"]))
                {
                    initializePaymentRequest.WithPaymentMethods(settings["paymentMethods"].Split(',').Select(i => PaynovaPaymentMethod.Custom(int.Parse(i))));
                }


                InitializePaymentResponse initializePaymentResponse = client.InitializePayment(initializePaymentRequest);
                htmlForm.Action = initializePaymentResponse.Url;
            }
            catch (Exception e)
            {
            }

            return(htmlForm);
        }
Пример #13
0
 public static bool IsInterfaceDefined <TInterface>(Type type, InterfaceOptions options = InterfaceOptions.Default) =>
 TypeReflections.IsInterfaceDefined <TInterface>(type, options);