Esempio n. 1
0
        public PayRequest PreapprovalPayment(string key, string payPalId, string userId, decimal rate)
        {
            // # PayRequest
            // The code for the language in which errors are returned
            RequestEnvelope envelopeRequest = new RequestEnvelope();

            envelopeRequest.errorLanguage = "en_US";

            List <Receiver> listReceiver = new List <Receiver>();

            // Amount to be credited to the receiver's account
            Receiver receive = new Receiver(rate);

            // A receiver's email address
            //receive.email = "*****@*****.**";
            receive.email = "*****@*****.**";
            listReceiver.Add(receive);
            ReceiverList listOfReceivers = new ReceiverList(listReceiver);

            PayRequest requestPay = new PayRequest();

            requestPay.senderEmail        = payPalId;
            requestPay.preapprovalKey     = key;
            requestPay.receiverList       = listOfReceivers;
            requestPay.requestEnvelope    = envelopeRequest;
            requestPay.returnUrl          = System.Configuration.ConfigurationManager.AppSettings["RETURN_URL"] + "/DoctorInformation/PayPalSubscription/?pstatus=success&userId=" + userId;
            requestPay.cancelUrl          = System.Configuration.ConfigurationManager.AppSettings["CANCEL_URL"] + "/DoctorInformation/PayPalSubscription/?pstatus=cancel&userid=" + userId;
            requestPay.currencyCode       = "USD";
            requestPay.actionType         = "PAY";
            requestPay.ipnNotificationUrl = System.Configuration.ConfigurationManager.AppSettings["IPN_URL"] + "/DoctorInformation/PayPalIPN/";
            return(requestPay);
        }
Esempio n. 2
0
    // # Parallel Payment
    // `Note:
    // For parallel Payment all the above mentioned request parameters in
    // SimplePay() are required, but in receiverList we can have multiple
    // receivers`
    public PayRequest ParallelPayment()
    {
        // Payment operation
        PayRequest requestPay = Payment();

        List <Receiver> receiverLst = new List <Receiver>();

        // Amount to be credited to the receiver's account
        Receiver receiverA = new Receiver(Convert.ToDecimal("4.00"));

        // A receiver's email address
        receiverA.email = "*****@*****.**";
        receiverLst.Add(receiverA);

        // Amount to be credited to the receiver's account
        Receiver receiverB = new Receiver(Convert.ToDecimal("2.00"));

        // A receiver's email address
        receiverB.email = "*****@*****.**";
        receiverLst.Add(receiverB);

        ReceiverList receiverList = new ReceiverList(receiverLst);

        requestPay.receiverList = receiverList;

        // IPN URL
        //
        // * PayPal Instant Payment Notification is a call back system that is initiated when a transaction is completed
        // * The transaction related IPN variables will be received on the call back URL specified in the request
        // * The IPN variables have to be sent back to the PayPal system for validation, upon validation PayPal will send a response string "VERIFIED" or "INVALID"
        // * PayPal would continuously resend IPN if a wrong IPN is sent
        requestPay.ipnNotificationUrl = "http://IPNhost";

        return(requestPay);
    }
Esempio n. 3
0
        public ActionResult Index(int?id)
        {
            //decimal price = 50;
            //Bids bid = db.Bids.Find(id);
            ReceiverList receiverList = new ReceiverList();

            receiverList.receiver = new List <Receiver>();
            Receiver receiver = new Receiver(50);

            //var query = from v in db.Ventures where v.Id == bid.ventureID select v.investorID;
            //string receiverID = query.ToList().ElementAt(0);
            //ApplicationUser recvUser = HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>().FindById(receiverID.ToString());
            receiver.email   = "*****@*****.**";
            receiver.primary = true;
            receiverList.receiver.Add(receiver);
            Receiver receiver2 = new Receiver(10);

            //var query = from v in db.Ventures where v.Id == bid.ventureID select v.investorID;
            //string receiverID = query.ToList().ElementAt(0);
            //ApplicationUser recvUser = HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>().FindById(receiverID.ToString());
            receiver2.email   = "*****@*****.**";
            receiver2.primary = false;
            receiverList.receiver.Add(receiver2);

            RequestEnvelope requestEnvelope = new RequestEnvelope("en_US");
            string          actionType      = "PAY";

            string successUrl = "http://" + System.Web.HttpContext.Current.Request.Url.Authority + "/PayPal/SuccessView/{0}";
            string failureUrl = "http://" + System.Web.HttpContext.Current.Request.Url.Authority + "/PayPal/FailureView/{0}";

            successUrl = String.Format(successUrl, id);
            failureUrl = String.Format(failureUrl, id);
            string returnUrl = successUrl;
            string cancelUrl = failureUrl;

            string     currencyCode = "USD";
            PayRequest payRequest   = new PayRequest(requestEnvelope, actionType, cancelUrl, currencyCode, receiverList, returnUrl);

            payRequest.ipnNotificationUrl = "http://de3b6191.ngrok.io";

            Dictionary <string, string> sdkConfig = new Dictionary <string, string>();

            sdkConfig.Add("mode", "sandbox");
            sdkConfig.Add("account1.apiUsername", "mattjheller-facilitator_api1.yahoo.com");                    //PayPal.Account.APIUserName
            sdkConfig.Add("account1.apiPassword", "DG6GB55TRBWLESWG");                                          //PayPal.Account.APIPassword
            sdkConfig.Add("account1.apiSignature", "AFcWxV21C7fd0v3bYYYRCpSSRl31AafAKKwBsAp2EBV9PExGkablGWhj"); //.APISignature
            sdkConfig.Add("account1.applicationId", "APP-80W284485P519543T");                                   //.ApplicatonId

            AdaptivePaymentsService adaptivePaymentsService = new AdaptivePaymentsService(sdkConfig);
            PayResponse             payResponse             = adaptivePaymentsService.Pay(payRequest);

            ViewData["paykey"] = payResponse.payKey;
            //string payKey = payResponse.payKey; ////////
            //string paymentExecStatus = payResponse.paymentExecStatus;
            //string payURL = String.Format("https://www.sandbox.paypal.com/webscr?cmd=_ap-payment&paykey={0}", payKey);
            SimpleListenerExample("localhost: 80");
            return(View());
        }
Esempio n. 4
0
        private bool ChargePayPalSuccess(Subscription sub, ManBoxEntities ent, string thankYouUrl, string cancelUrl)
        {
            var payPalAccount = ConfigurationManager.AppSettings[AppConstants.AppSettingsKeys.PayPalAccount] as string;
            var paymentInfo   = GetPaymentInfo(sub, ent);

            var receiverList = new ReceiverList();

            receiverList.receiver = new List <Receiver>();
            receiverList.receiver.Add(new Receiver(paymentInfo.Total)
            {
                email = payPalAccount
            });

            var         service  = new AdaptivePaymentsService();
            PayResponse response = service.Pay(new PayRequest(
                                                   new RequestEnvelope("en_US"),
                                                   "PAY",
                                                   cancelUrl,
                                                   "EUR",
                                                   receiverList,
                                                   thankYouUrl)
            {
                senderEmail    = sub.PayPalSenderEmail,
                preapprovalKey = sub.PayPalPreapprovalKey
            });

            if (response == null)
            {
                logger.Log(LogType.Fatal, "No Response was received from PayPal Payrequest service");
            }

            logger.Log(LogType.Info, string.Format("paykey is {0} . exec status is {1}", response.payKey ?? "", response.paymentExecStatus ?? ""));

            // error handling
            if (response.error != null && response.error.FirstOrDefault() != null)
            {
                logger.Log(LogType.Error, string.Format("error {0}", response.error.FirstOrDefault().message));
            }

            // error handling
            if (response.payErrorList != null && response.payErrorList.payError.FirstOrDefault() != null)
            {
                logger.Log(LogType.Error, string.Format("payerror {0}", response.payErrorList.payError.FirstOrDefault().error.message));
            }

            //payment exec status must be : COMPLETED
            if (!string.IsNullOrEmpty(response.paymentExecStatus) &&
                response.paymentExecStatus.ToLower() == PayPalConstants.PaymentExecStatus.Completed.ToLower())
            {
                return(true);
            }

            return(false);
        }
Esempio n. 5
0
        private void AddReceiver(decimal amount, string email, ReceiverList receiverList)
        {
            Check.Require(email.Length < 127);

            Receiver receiver = new Receiver();

            // (Required) Amount to be paid to the receiver
            receiver.amount = amount;
            // Receiver's email address. This address can be unregistered with
            // paypal.com. If so, a receiver cannot claim the payment until a PayPal
            // account is linked to the email address. The PayRequest must pass
            // either an email address or a phone number. Maximum length: 127 characters
            receiver.email = email;
            receiverList.receiver.Add(receiver);
        }
Esempio n. 6
0
        public PayRequest ParallelPayment(int rate, string payPalId, long id, long appointmentId)
        {
            // Payment operation
            // PayRequest requestPay = Payment();
            RequestEnvelope envelopeRequest = new RequestEnvelope();

            envelopeRequest.errorLanguage = "en_US";

            List <Receiver> receiverLst = new List <Receiver>();

            // Amount to be credited to the receiver's account
            Receiver receiverA = new Receiver(Convert.ToDecimal(rate));

            // A receiver's email address
            receiverA.email = payPalId;

            receiverLst.Add(receiverA);

            // Amount to be credited to the receiver's account
            Receiver receiverB = new Receiver(Convert.ToDecimal("4.00"));

            // A receiver's email address
            receiverB.email = "*****@*****.**";
            receiverLst.Add(receiverB);

            ReceiverList receiverList = new ReceiverList(receiverLst);

            PayRequest requestPay = new PayRequest(envelopeRequest, "PAY", System.Configuration.ConfigurationManager.AppSettings["CANCEL_URL"] + "/PatientProfile/BookYourAppointment/?pstatus=cancel&id=" + id + "&tabvalue=tab1" + "&appointmentId=" + appointmentId, "USD", receiverList, System.Configuration.ConfigurationManager.AppSettings["RETURN_URL"] + "/PatientProfile/BookYourAppointment/?pstatus=success&appointmentId=" + appointmentId + "&tabvalue=tab3" + "&id=" + id + "&pay=" + rate);

            //requestPay.senderEmail = "*****@*****.**";
            //return requestPay;


            requestPay.receiverList = receiverList;



            // IPN URL
            //
            // * PayPal Instant Payment Notification is a call back system that is initiated when a transaction is completed
            // * The transaction related IPN variables will be received on the call back URL specified in the request
            // * The IPN variables have to be sent back to the PayPal system for validation, upon validation PayPal will send a response string "VERIFIED" or "INVALID"
            // * PayPal would continuously resend IPN if a wrong IPN is sent
            requestPay.ipnNotificationUrl = "http://IPNhost";

            return(requestPay);
        }
Esempio n. 7
0
 internal static void Prepare()
 {
     MessageReceivers?.Clear();
     UpdateReceivers?.Clear();
     RenderReceivers?.Clear();
     NavigateReceivers?.Clear();
     ModuleLoadReceivers?.Clear();
     GameInitializeReceivers?.Clear();
     GameDestructReceivers?.Clear();
     MessageReceivers = new ReceiverList<IMessager, Message>(MessageMapper);
     UpdateReceivers = new ReceiverList<IUpdater, int>(UpdateMapper);
     RenderReceivers = new ReceiverList<IRenderer, int>(RenderMapper);
     NavigateReceivers = new ReceiverList<INavigator, NavigationParameter>(NavigateMapper);
     ModuleLoadReceivers = new ReceiverList<IModuleLoader, Type[]>(ModuleLoadMapper);
     GameInitializeReceivers = new ReceiverList<IGameInitializer, int>(GameInitializeMapper);
     GameDestructReceivers = new ReceiverList<IGameDestructor, CancelEventArgs>(GameDestructMapper);
 }
Esempio n. 8
0
    // # Payment
    public PayRequest Payment()
    {
        // # PayRequest
        // The code for the language in which errors are returned
        RequestEnvelope envelopeRequest = new RequestEnvelope();

        envelopeRequest.errorLanguage = "en_US";

        List <Receiver> listReceiver = new List <Receiver>();

        // Amount to be credited to the receiver's account
        Receiver receive = new Receiver(Convert.ToDecimal("4.00"));

        // A receiver's email address
        receive.email = "*****@*****.**";
        listReceiver.Add(receive);
        ReceiverList listOfReceivers = new ReceiverList(listReceiver);

        // PayRequest which takes mandatory params:
        //
        // * `Request Envelope` - Information common to each API operation, such
        // as the language in which an error message is returned.
        // * `Action Type` - The action for this request. Possible values are:
        // * PAY - Use this option if you are not using the Pay request in
        // combination with ExecutePayment.
        // * CREATE - Use this option to set up the payment instructions with
        // SetPaymentOptions and then execute the payment at a later time with
        // the ExecutePayment.
        // * PAY_PRIMARY - For chained payments only, specify this value to delay
        // payments to the secondary receivers; only the payment to the primary
        // receiver is processed.
        // * `Cancel URL` - URL to redirect the sender's browser to after
        // canceling the approval for a payment; it is always required but only
        // used for payments that require approval (explicit payments)
        // * `Currency Code` - The code for the currency in which the payment is
        // made; you can specify only one currency, regardless of the number of
        // receivers
        // * `Recevier List` - List of receivers
        // * `Return URL` - URL to redirect the sender's browser to after the
        // sender has logged into PayPal and approved a payment; it is always
        // required but only used if a payment requires explicit approval
        PayRequest requestPay = new PayRequest(envelopeRequest, "PAY", "http://localhost/cancel", "USD", listOfReceivers, "http://localhost/return");

        return(requestPay);
    }
Esempio n. 9
0
        public WocketsController(string name, string filename, string description)
        {
            this._Name        = name;
            this._Filename    = filename;
            this._Description = description;



            this.savingEvent     = new AutoResetEvent(false);
            this.waitToSaveEvent = new AutoResetEvent(false);

            this.pollingEvent     = new AutoResetEvent(false);
            this.waitToPollEvent  = new AutoResetEvent(false);
            this.classifyingEvent = new AutoResetEvent(false);
            this.trainingEvent    = new AutoResetEvent(false);

            this._Decoders  = new DecoderList();
            this._Receivers = new ReceiverList();
            this._Sensors   = new SensorList();
        }
Esempio n. 10
0
        public PayRequest SubscriptionPayment(int rate, string userId, string paypalId)
        {
            // Payment operation
            // PayRequest requestPay = Payment();
            RequestEnvelope envelopeRequest = new RequestEnvelope();

            envelopeRequest.errorLanguage = "en_US";

            List <Receiver> receiverLst = new List <Receiver>();

            // Amount to be credited to the receiver's account
            Receiver receiverB = new Receiver(Convert.ToDecimal(rate));

            // A receiver's email address
            receiverB.email = "*****@*****.**";
            receiverLst.Add(receiverB);

            ReceiverList receiverList = new ReceiverList(receiverLst);

            PayRequest requestPay = new PayRequest(envelopeRequest, "PAY", System.Configuration.ConfigurationManager.AppSettings["CANCEL_URL"] + "/DoctorInformation/PayPalSubscription/?pstatus=cancel&userid=" + userId, "USD", receiverList, System.Configuration.ConfigurationManager.AppSettings["RETURN_URL"] + "/DoctorInformation/PayPalSubscription/?pstatus=success&userId=" + userId + "&pay=" + rate);

            requestPay.senderEmail  = paypalId;
            requestPay.receiverList = receiverList;
            //SenderIdentifier sender = new SenderIdentifier();
            //sender.accountId = userId;
            //sender.email = paypalId;
            //requestPay.sender = sender;

            // IPN URL
            //
            // * PayPal Instant Payment Notification is a call back system that is initiated when a transaction is completed
            // * The transaction related IPN variables will be received on the call back URL specified in the request
            // * The IPN variables have to be sent back to the PayPal system for validation, upon validation PayPal will send a response string "VERIFIED" or "INVALID"
            // * PayPal would continuously resend IPN if a wrong IPN is sent
            requestPay.ipnNotificationUrl = System.Configuration.ConfigurationManager.AppSettings["IPN_URL"] + "/DoctorInformation/PayPalIPIN/";

            return(requestPay);
        }
Esempio n. 11
0
    // # Chained Payment
    // `Note:
    // For chained Payment all the above mentioned request parameters in
    // SimplePay() are required, but in receiverList alone we have to make
    // receiver as Primary Receiver or Not Primary Receiver`
    public PayRequest ChainPayment()
    {
        // Payment operation
        PayRequest requestPay = Payment();

        List <Receiver> listReceiver = new List <Receiver>();

        // Amount to be credited to the receiver's account
        Receiver receiverA = new Receiver(Convert.ToDecimal("4.00"));

        // A receiver's email address
        receiverA.email = "*****@*****.**";

        // Set to true to indicate a chained payment; only one receiver can be a
        // primary receiver. Omit this field, or set it to false for simple and
        // parallel payments.
        receiverA.primary = true;
        listReceiver.Add(receiverA);

        // Amount to be credited to the receiver's account
        Receiver receiverB = new Receiver(Convert.ToDecimal("2.00"));

        // A receiver's email address
        receiverB.email = "*****@*****.**";

        // Set to true to indicate a chained payment; only one receiver can be a
        // primary receiver. Omit this field, or set it to false for simple and
        // parallel payments.
        receiverB.primary = false;
        listReceiver.Add(receiverB);

        ReceiverList receiverList = new ReceiverList(listReceiver);

        requestPay.receiverList = receiverList;
        return(requestPay);
    }
Esempio n. 12
0
        public string GetPaymentUrl()
        {
            var paymentReceiver = new Receiver
            {
                email  = PaymentReceiverEmail,
                amount = transaction.GetTotal()
            };

            var receivers = new ReceiverList(new List <Receiver>()
            {
                paymentReceiver
            });

            var payRequest = new PayRequest
            {
                actionType      = "PAY",
                receiverList    = receivers,
                currencyCode    = currency.code,
                requestEnvelope = new RequestEnvelope
                {
                    errorLanguage
                        =
                            "en_US"
                },
                returnUrl  = returnUrl,
                trackingId = uniqueid
            };

            payRequest.cancelUrl = payRequest.returnUrl;

            var configurationMap = Configuration.GetAcctAndConfig();

            var service = new AdaptivePaymentsService(configurationMap);

            var resp = service.Pay(payRequest);

            if (resp.responseEnvelope.ack == AckCode.FAILURE ||
                resp.responseEnvelope.ack == AckCode.FAILUREWITHWARNING)
            {
                // TODO: serialize this properly
                throw new Exception(resp.error.First().message);
            }

            if (resp.paymentExecStatus != "CREATED" && resp.paymentExecStatus != "COMPLETED")
            {
                // create the payment
                string errorString = "";
                foreach (var error in resp.payErrorList.payError)
                {
                    errorString += error.error.message;
                }
                throw new Exception(errorString);
            }

            string paymentStatus = PaymentStatus.Charging.ToString();

            if (resp.paymentExecStatus == "COMPLETED")
            {
                paymentStatus = PaymentStatus.Accepted.ToString();
            }

            var pay = new DBML.payment
            {
                created     = DateTime.UtcNow,
                paidAmount  = transaction.GetTotal(),
                method      = PaymentMethodType.Paypal.ToString(),
                orderid     = transaction.GetID(),
                status      = paymentStatus,
                reference   = uniqueid,
                redirectUrl = PaymentConstants.PaypalRedirectUrl + resp.payKey
            };

            transaction.AddPayment(pay, true);

            // update invoice status
            repository.Save();

            return(pay.redirectUrl);
        }
Esempio n. 13
0
        // # Payment
        public static PayRequest Payment(int quantity, int byocQuantity, Double extraLife)
        {
            // # PayRequest
            // The code for the language in which errors are returned
            RequestEnvelope envelopeRequest = new RequestEnvelope();

            envelopeRequest.errorLanguage = "en_US";

            List <Receiver> listReceiver = new List <Receiver>();

            // Amount to be credited to the receiver's account
            decimal amount;

            if (checkInDay.Equals("true"))
            {
                amount = Convert.ToDecimal(quantity * 25.00) + Convert.ToDecimal(byocQuantity * 25.00);
            }
            else
            {
                amount = Convert.ToDecimal(quantity * 15.00) + Convert.ToDecimal(byocQuantity * 20.00);
            }
            if (extraLife > 0)
            {
                amount += Convert.ToDecimal(extraLife);
            }
            Receiver receive = new Receiver(amount);

            // A receiver's email address
            receive.email = "*****@*****.**";
            listReceiver.Add(receive);
            ReceiverList listOfReceivers = new ReceiverList(listReceiver);

            // PayRequest which takes mandatory params:
            //
            // * `Request Envelope` - Information common to each API operation, such
            // as the language in which an error message is returned.
            // * `Action Type` - The action for this request. Possible values are:
            // * PAY - Use this option if you are not using the Pay request in
            // combination with ExecutePayment.
            // * CREATE - Use this option to set up the payment instructions with
            // SetPaymentOptions and then execute the payment at a later time with
            // the ExecutePayment.
            // * PAY_PRIMARY - For chained payments only, specify this value to delay
            // payments to the secondary receivers; only the payment to the primary
            // receiver is processed.
            // * `Cancel URL` - URL to redirect the sender's browser to after
            // canceling the approval for a payment; it is always required but only
            // used for payments that require approval (explicit payments)
            // * `Currency Code` - The code for the currency in which the payment is
            // made; you can specify only one currency, regardless of the number of
            // receivers
            // * `Recevier List` - List of receivers
            // * `Return URL` - URL to redirect the sender's browser to after the
            // sender has logged into PayPal and approved a payment; it is always
            // required but only used if a payment requires explicit approval
            PayRequest requestPay;

            if (checkInDay.Equals("true"))
            {
                requestPay = new PayRequest(envelopeRequest, "PAY", "https://kcgameon.com/Checkin.aspx", "USD", listOfReceivers, "https://kcgameon.com/Checkin.aspx");
            }
            else
            {
                requestPay = new PayRequest(envelopeRequest, "PAY", "https://kcgameon.com/Default.aspx", "USD", listOfReceivers, "https://kcgameon.com/Map.aspx");
            }
            //PayRequest requestPay = new PayRequest(envelopeRequest, "PAY", "https://nickthenerd.com/Default.aspx", "USD", listOfReceivers, "https://nickthenerd.com/Map.aspx");
            return(requestPay);
        }
Esempio n. 14
0
        /// <summary>
        /// Handle Pay API calls
        /// </summary>
        /// <param name="context"></param>
        private void Pay(HttpContext context)
        {
            NameValueCollection parameters = context.Request.Params;
            ReceiverList receiverList = new ReceiverList();
            receiverList.receiver = new List<Receiver>();
            string[] amt = context.Request.Form.GetValues("receiverAmount");
            string[] receiverEmail = context.Request.Form.GetValues("receiverEmail");
            string[] phoneCountry = context.Request.Form.GetValues("phoneCountry");
            string[] phoneNumber = context.Request.Form.GetValues("phoneNumber");
            string[] phoneExtn = context.Request.Form.GetValues("phoneExtn");
            string[] primaryReceiver = context.Request.Form.GetValues("primaryReceiver");
            string[] invoiceId = context.Request.Form.GetValues("invoiceId");
            string[] paymentType = context.Request.Form.GetValues("paymentType");
            string[] paymentSubType = context.Request.Form.GetValues("paymentSubType");
            for (int i = 0; i < amt.Length; i++)
            {
                Receiver rec = new Receiver(Decimal.Parse(amt[i]));
                if(receiverEmail[i] != "")
                    rec.email = receiverEmail[i];
                if (phoneCountry[i] != "" && phoneNumber[i] != "")
                {
                    rec.phone = new PhoneNumberType(phoneCountry[i], phoneNumber[i]);
                    if (phoneExtn[i] != "")
                    {
                        rec.phone.extension = phoneExtn[i];
                    }
                }
                if (primaryReceiver[i] != "")
                    rec.primary = Boolean.Parse(primaryReceiver[i]);
                if (invoiceId[i] != "")
                    rec.invoiceId = invoiceId[i];
                if (paymentType[i] != "")
                    rec.paymentType = paymentType[i];
                if (paymentSubType[i] != "")
                    rec.paymentSubType = paymentSubType[i];
                receiverList.receiver.Add(rec);
            }            
            PayRequest req = new PayRequest(new RequestEnvelope("en_US"), parameters["actionType"], 
                                parameters["cancelUrl"], parameters["currencyCode"], 
                                receiverList, parameters["returnUrl"]);
            // set optional parameters
            if (parameters["reverseAllParallelPaymentsOnError"] != "")
                req.reverseAllParallelPaymentsOnError = 
                    Boolean.Parse(parameters["reverseAllParallelPaymentsOnError"]);
            if (parameters["senderEmail"] != "")
                req.senderEmail = parameters["senderEmail"];
            if (parameters["trackingId"] != "")
                req.trackingId = parameters["trackingId"];
            if (parameters["fundingConstraint"] != "")
            {
                req.fundingConstraint = new FundingConstraint();
                req.fundingConstraint.allowedFundingType = new FundingTypeList();
                req.fundingConstraint.allowedFundingType.fundingTypeInfo.Add(
                    new FundingTypeInfo(parameters["fundingConstraint"]));
            }
            if (parameters["emailIdentifier"] != ""
                || (parameters["senderPhoneCountry"] != "" && parameters["senderPhoneNumber"] != "")
                || parameters["useCredentials"] != "")
            {
                req.sender = new SenderIdentifier();
                if (parameters["emailIdentifier"] != "")
                    req.sender.email = parameters["emailIdentifier"];
                if (parameters["senderPhoneCountry"] != "" && parameters["senderPhoneNumber"] != "")
                {
                    req.sender.phone = new PhoneNumberType(parameters["senderPhoneCountry"], parameters["senderPhoneNumber"]);
                    if (parameters["senderPhoneExtn"] != "")
                        req.sender.phone.extension = parameters["senderPhoneExtn"];
                }
                if (parameters["useCredentials"] != "")
                    req.sender.useCredentials = Boolean.Parse(parameters["useCredentials"]);
            }

            // All set. Fire the request            
            AdaptivePaymentsService service = new AdaptivePaymentsService();
            PayResponse resp = null;
            try
            {
                resp = service.Pay(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) )
            {
                redirectUrl = ConfigurationManager.AppSettings["PAYPAL_REDIRECT_URL"]
                                     + "_ap-payment&paykey=" + resp.payKey;
                keyResponseParams.Add("Pay key", resp.payKey);
                keyResponseParams.Add("Payment execution status", resp.paymentExecStatus);
                if (resp.defaultFundingPlan != null && resp.defaultFundingPlan.senderFees != null)
                {
                    keyResponseParams.Add("Sender fees", resp.defaultFundingPlan.senderFees.amount +
                                                resp.defaultFundingPlan.senderFees.code);
                }
            }
            displayResponse(context, "Pay", keyResponseParams, service.getLastRequest(), service.getLastResponse(), 
                resp.error, redirectUrl);            
        }
Esempio n. 15
0
        public void Dispose()
        {
            #if (PocketPC)
            if (dataCollectionThread != null)
                dataCollectionThread.Abort();

            if (interfaceActivityThread != null)
                interfaceActivityThread.Abort();
            #endif
            if (aPollingThread != null)
                aPollingThread.Abort();

            if (aSavingThread != null)
                aSavingThread.Abort();

            if (trainingTW != null)
            {
                trainingTW.Flush();
                trainingTW.Close();
                trainingTW = null;
            }
            if (structureTW != null)
            {
                structureTW.Flush();
                structureTW.Close();
                structureTW = null;
            }
            for (int i = 0; (i < this._Receivers.Count); i++)
            {
                //this._Receivers[i]._Status = ReceiverStatus.Disconnected;
                //Thread.Sleep(100);
                if (this._Sensors[i]._Loaded)
                {
                    this._Receivers[i].Dispose();
                    Thread.Sleep(1000);
                    this._Receivers[i] = null;
                }
            }

            this._Receivers = null;

            for (int i = 0; (i < this._Sensors.Count); i++)
                if (this._Sensors[i]._Loaded)
                {
                    this._Sensors[i].Dispose();
                    this._Decoders[i].Dispose();
                    this._Sensors[i] = null;
                    this._Decoders[i] = null;
                }

            this._Sensors = null;
            this._Decoders = null;

            //NetworkStacks._BluetoothStack.Dispose();
        }
Esempio n. 16
0
        public void Dispose()
        {
#if (PocketPC)
            if (dataCollectionThread != null)
            {
                dataCollectionThread.Abort();
            }

            if (interfaceActivityThread != null)
            {
                interfaceActivityThread.Abort();
            }
#endif
            if (aPollingThread != null)
            {
                aPollingThread.Abort();
            }

            if (aSavingThread != null)
            {
                aSavingThread.Abort();
            }


            if (trainingTW != null)
            {
                trainingTW.Flush();
                trainingTW.Close();
                trainingTW = null;
            }
            if (structureTW != null)
            {
                structureTW.Flush();
                structureTW.Close();
                structureTW = null;
            }
            for (int i = 0; (i < this._Receivers.Count); i++)
            {
                //this._Receivers[i]._Status = ReceiverStatus.Disconnected;
                //Thread.Sleep(100);
                if (this._Sensors[i]._Loaded)
                {
                    this._Receivers[i].Dispose();
                    Thread.Sleep(1000);
                    this._Receivers[i] = null;
                }
            }

            this._Receivers = null;

            for (int i = 0; (i < this._Sensors.Count); i++)
            {
                if (this._Sensors[i]._Loaded)
                {
                    this._Sensors[i].Dispose();
                    this._Decoders[i].Dispose();
                    this._Sensors[i]  = null;
                    this._Decoders[i] = null;
                }
            }

            this._Sensors  = null;
            this._Decoders = null;

            //NetworkStacks._BluetoothStack.Dispose();
        }
Esempio n. 17
0
 private static bool UpdateMapper(ReceiverList<IUpdater, int> list, IUpdater receiver, int parameter)
 {
     return receiver.Update(parameter);
 }
        public ActionResult Payment(int?id)
        {
            string identity = System.Web.HttpContext.Current.User.Identity.GetUserId();

            if (identity == null)
            {
                return(RedirectToAction("Unauthorized_Access", "Home"));
            }
            var    completedList  = db.CompletedBids.ToList();
            string HomeOwnerEmail = "";
            string payeeEmail     = "";
            var    person         = db.Homeowners.Where(x => x.UserId == identity).SingleOrDefault();


            foreach (var user in db.Users)
            {
                if (user.Id == identity)
                {
                    payeeEmail = user.Email;
                }
            }

            foreach (var i in completedList)
            {
                if (id == i.ID)
                {
                    HomeOwnerEmail = i.HomeEmail;
                }
            }


            if (this.User.IsInRole("Admin") || HomeOwnerEmail == payeeEmail)
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                CompletedBids completedBids = db.CompletedBids.Find(id);
                if (completedBids == null)
                {
                    return(HttpNotFound());
                }
                ReceiverList receiverList = new ReceiverList();
                receiverList.receiver = new List <Receiver>();
                Receiver receiver = new Receiver(completedBids.Bid);
                //var query = from v in db.Ventures where v.Id == bid.ventureID select v.investorID;
                //string receiverID = query.ToList().ElementAt(0);
                //ApplicationUser recvUser = HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>().FindById(receiverID.ToString());
                receiver.email   = "*****@*****.**";
                receiver.primary = true;
                receiverList.receiver.Add(receiver);
                Receiver receiver2 = new Receiver(completedBids.ContractorDue);
                //var query = from v in db.Ventures where v.Id == bid.ventureID select v.investorID;
                //string receiverID = query.ToList().ElementAt(0);
                //ApplicationUser recvUser = HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>().FindById(receiverID.ToString());
                receiver2.email   = completedBids.ConEmail;
                receiver2.primary = false;
                receiverList.receiver.Add(receiver2);
                RequestEnvelope requestEnvelope = new RequestEnvelope("en_US");
                string          actionType      = "PAY";
                string          successUrl      = "http://" + System.Web.HttpContext.Current.Request.Url.Authority + "/CompletedBids/SuccessView/{0}";
                string          failureUrl      = "http://" + System.Web.HttpContext.Current.Request.Url.Authority + "/CompletedBids/FailureView/{0}";
                successUrl = String.Format(successUrl, id);
                failureUrl = String.Format(failureUrl, id);
                string     returnUrl    = successUrl;
                string     cancelUrl    = failureUrl;
                string     currencyCode = "USD";
                PayRequest payRequest   = new PayRequest(requestEnvelope, actionType, cancelUrl, currencyCode, receiverList, returnUrl);
                payRequest.ipnNotificationUrl = "http://cf719b5f.ngrok.io";
                string memo = completedBids.Description + " Invoice = " + completedBids.Invoice;
                payRequest.memo = memo;
                Dictionary <string, string> sdkConfig = new Dictionary <string, string>();
                sdkConfig.Add("mode", "sandbox");
                sdkConfig.Add("account1.apiUsername", "mattjheller-facilitator_api1.yahoo.com");                    //PayPal.Account.APIUserName
                sdkConfig.Add("account1.apiPassword", "DG6GB55TRBWLESWG");                                          //PayPal.Account.APIPassword
                sdkConfig.Add("account1.apiSignature", "AFcWxV21C7fd0v3bYYYRCpSSRl31AafAKKwBsAp2EBV9PExGkablGWhj"); //.APISignature
                sdkConfig.Add("account1.applicationId", "APP-80W284485P519543T");                                   //.ApplicatonId

                AdaptivePaymentsService adaptivePaymentsService = new AdaptivePaymentsService(sdkConfig);
                PayResponse             payResponse             = adaptivePaymentsService.Pay(payRequest);
                ViewData["paykey"] = payResponse.payKey;

                //string payKey = payResponse.payKey; ////////
                //string paymentExecStatus = payResponse.paymentExecStatus;
                //string payURL = String.Format("https://www.sandbox.paypal.com/webscr?cmd=_ap-payment&paykey={0}", payKey);
                return(View(completedBids));
            }
            else
            {
                return(RedirectToAction("Unauthorized_Access", "Home"));
            }
        }
Esempio n. 19
0
        public WocketsController(string name, string filename, string description)
        {
            this._Name = name;
            this._Filename = filename;
            this._Description = description;

            this.savingEvent = new AutoResetEvent(false);
            this.waitToSaveEvent = new AutoResetEvent(false);

            this.pollingEvent = new AutoResetEvent(false);
            this.waitToPollEvent = new AutoResetEvent(false);
            this.classifyingEvent = new AutoResetEvent(false);
            this.trainingEvent = new AutoResetEvent(false);

            this._Decoders = new DecoderList();
            this._Receivers = new ReceiverList();
            this._Sensors = new SensorList();
        }
Esempio n. 20
0
        public void Pay()
        {
            Random r = new Random();
            int    PayPalPurchaseTransactionId = r.Next();      // -10;
            string PayPalRedirectUrl           = "www.cnn.com"; // ConfigurationManager.AppSettings["PAYPAL_REDIRECT_URL"];
            // Instantiate PayPalResponse class
            GIBSPayPal objPayPalResponse = new GIBSPayPal();

            objPayPalResponse.PayPalPaykey            = " ";
            objPayPalResponse.PayPalPaymentExecStatus = " ";
            objPayPalResponse.PayPalRedirectUrl       = PayPalRedirectUrl;
            objPayPalResponse.PayPalErrorMessage      = " ";
            objPayPalResponse.PayPalError             = false;
            string currentPath =
                System.Web.HttpContext.Current.Request.Url.OriginalString
                .Replace(@"/PayPal_Call_back.ashx", "");

            string strActionType = "PAY";
            string currencyCode  = "USD";
            string cancelUrl     = string.Format(@"{0}&mode=cancel", currentPath);
            string returnUrl     = String.Format(@"{0}&payment=complete", currentPath);
            string IpnURL        = String.Format(@"{0}/PayPal/IPNListener.aspx", currentPath);

            ReceiverList receiverList = new ReceiverList();

            receiverList.receiver = new List <Receiver>();

            Receiver Receiver1 = new Receiver(Decimal.Parse("5.59"));

            Receiver1.email     = "*****@*****.**";
            Receiver1.primary   = false;
            Receiver1.invoiceId = "";

            Receiver1.paymentType = "SERVICE";

            receiverList.receiver.Add(Receiver1);

            PayRequest req = new PayRequest(new RequestEnvelope("en_US"),
                                            strActionType,
                                            cancelUrl,
                                            currencyCode,
                                            receiverList,
                                            returnUrl);

            //// IPN Url (only enable with a published internet accessable application)
            //req.ipnNotificationUrl = IpnURL;
            //req.reverseAllParallelPaymentsOnError = true;
            //req.trackingId = PayPalPurchaseTransactionId.ToString();


            // Call PayPal to get PayKey
            Dictionary <string, string> configMap = new Dictionary <string, string>();

            //configMap = GetConfig();
            configMap.Add("mode", "sandbox");
            // Signature Credential
            configMap.Add("account1.apiUsername", "joe-facilitator_api1.gibs.com");
            configMap.Add("account1.apiPassword", "5UX8EJBTREJQ33MH");
            configMap.Add("account1.apiSignature", "An5ns1Kso7MWUdW4ErQKJJJ4qi4-AM3p4jdO1vcSS2ClRObAqbmoxWeN");
            configMap.Add("account1.applicationId", "APP-80W284485P519543T");

            //configMap.Add("account1.apiUsername", "joe_api1.gibs.com");
            //configMap.Add("account1.apiPassword", "Y5M699WXLTEF976T");
            //configMap.Add("account1.apiSignature", "AUHOQLvCB6h8yLQ2ZC0YcUb3EuZjAY-OG4J5Hkaj35SjMEkMxhoMslvt");
            //configMap.Add("account1.applicationId", "APP-80W284485P519543T");
            // Sandbox Email Address
            //configMap.Add("sandboxEmailAddress", "*****@*****.**");

            AdaptivePaymentsService service = new AdaptivePaymentsService(configMap);
            PayResponse             resp    = null;

            try
            {
                resp = service.Pay(req);
            }

            catch (System.Exception e)
            {
                objPayPalResponse.PayPalError        = true;
                objPayPalResponse.PayPalErrorMessage = e.Message;
                PayPalPaykey = " Catch " + e.Message; // resp.payKey;
            }
            // Check for errors
            if ((resp.responseEnvelope.ack == AckCode.FAILURE) ||
                (resp.responseEnvelope.ack == AckCode.FAILUREWITHWARNING))
            {
                string strError = "";
                objPayPalResponse.PayPalError = true;
                foreach (var error in resp.error)
                {
                    strError = strError + " " + error.message;
                }
                objPayPalResponse.PayPalErrorMessage = strError;
                PayPalPaykey = " " + strError;// resp.payKey;
            }
            else
            {
                objPayPalResponse.PayPalPaykey = resp.payKey;
                PayPalPaykey = resp.payKey;
                objPayPalResponse.PayPalPaymentExecStatus = resp.paymentExecStatus;
            }
        }
Esempio n. 21
0
 private static bool GameDestructMapper(ReceiverList<IGameDestructor, CancelEventArgs> list, IGameDestructor receiver, CancelEventArgs parameter)
 {
     return receiver.Destruct(parameter);
 }
Esempio n. 22
0
 private static bool MessageMapper(ReceiverList<IMessager, Message> list, IMessager receiver, Message parameter)
 {
     return (parameter.Mask & receiver.Mask) == 0 || receiver.Receive(parameter);
 }
Esempio n. 23
0
 private static bool GameInitializeMapper(ReceiverList<IGameInitializer, int> list, IGameInitializer receiver, int parameter)
 {
     return receiver.Initialize();
 }
Esempio n. 24
0
 private static bool NavigateMapper(ReceiverList<INavigator, NavigationParameter> list, INavigator receiver, NavigationParameter parameter)
 {
     return receiver.Navigate(parameter);
 }
Esempio n. 25
0
 private static bool RenderMapper(ReceiverList<IRenderer, int> list, IRenderer receiver, int parameter)
 {
     return receiver.Render(parameter);
 }
Esempio n. 26
0
 private static bool ModuleLoadMapper(ReceiverList<IModuleLoader, Type[]> list, IModuleLoader receiver, Type[] parameter)
 {
     return receiver.Initialize(parameter);
 }
Esempio n. 27
0
        /// <summary>
        /// Creating a request to get PayKey from PayPal
        /// </summary>
        /// <param name="receiver1amount">amount that receiver1 receives</param>
        /// <param name="receiver2amount">amount that receiver2 receives</param>
        /// <param name="receiver1email">email of receiver1 (max length 127 characters)</param>
        /// <param name="receiver2email">email of receiver2 (max length 127 characters)</param>
        /// <param name="senderEmail">Sender's email address. Maximum length: 127 characters</param>
        /// <returns></returns>
        private PayRequest CreateVisitPaymentRequest(VisitParallelPaymentParameters p)
        {
            Check.Require(string.IsNullOrEmpty(p.receiver1email) == false);
            Check.Require(string.IsNullOrEmpty(p.receiver2email) == false);
            //Check.Require(string.IsNullOrEmpty(p.senderEmail) == false);
            Check.Require(p.receiver1email.Length <= 127);
            Check.Require(p.receiver2email.Length <= 127);
            if (string.IsNullOrEmpty(p.senderEmail) == false)
            {
                Check.Require(p.senderEmail.Length <= 127);
            }


            //// (Optional) Sender's email address. Maximum length: 127 characters
            ////TODO: See why it is optional. It should deduct from the sender only

            // URL to redirect the sender's browser to after canceling the approval
            // for a payment; it is always required but only used for payments that
            // require approval (explicit payments)
            string cancelUrl = FWUtils.ConfigUtils.GetAppSettings().Paypal.GetCancelUrlPaymentID(p.paymentId);

            // The code for the currency in which the payment is made; you can
            // specify only one currency, regardless of the number of receivers
            string currencyCode = p.currencyCode;
            // URL to redirect the sender's browser to after the sender has logged
            // into PayPal and approved a payment; it is always required but only
            // used if a payment requires explicit approval
            string returnURL = FWUtils.ConfigUtils.GetAppSettings().Paypal.GetReturnUrlByPaymentID(p.paymentId);

            // (Optional) The URL to which you want all IPN messages for this
            // payment to be sent. Maximum length: 1024 characters
            string ipnNotificationURL = FWUtils.ConfigUtils.GetAppSettings().Paypal.GetIpnNotificationUrl(p.paymentId); // MAX 1024


            string errorLanguage = p.errorLanguage;


            // The action for this request. Possible values are: PAY ï؟½ Use this
            // option if you are not using the Pay request in combination with
            // ExecutePayment. CREATE ï؟½ Use this option to set up the payment
            // instructions with SetPaymentOptions and then execute the payment at a
            // later time with the ExecutePayment. PAY_PRIMARY ï؟½ For chained
            // payments only, specify this value to delay payments to the secondary
            // receivers; only the payment to the primary receiver is processed.
            AdaptivePaymentActionSEnum action = AdaptivePaymentActionSEnum.PAY;


            System.Collections.Specialized.NameValueCollection parameters = new System.Collections.Specialized.NameValueCollection();

            ReceiverList receiverList = new ReceiverList();

            receiverList.receiver = new List <Receiver>();

            PayRequest      request         = new PayRequest();
            RequestEnvelope requestEnvelope = new RequestEnvelope(errorLanguage);

            request.requestEnvelope = requestEnvelope;

            AddReceiver(p.receiver1amount, p.receiver1email, receiverList);
            AddReceiver(p.receiver2amount, p.receiver2email, receiverList);

            ReceiverList receiverlst = new ReceiverList(receiverList.receiver);

            request.receiverList = receiverlst;

            request.senderEmail        = p.senderEmail;
            request.actionType         = action.getFnName();
            request.cancelUrl          = cancelUrl;
            request.currencyCode       = currencyCode;
            request.returnUrl          = returnURL;
            request.requestEnvelope    = requestEnvelope;
            request.ipnNotificationUrl = ipnNotificationURL;

            return(request);
        }