示例#1
0
        private void VerifyPaypalCheckout(SubscriberPaymentProviderInfo subscriberPaymentProvider)
        {
            string token = Request["token"];

            if (subscriberPaymentProvider != null)
            {
                string[] userCredentials   = subscriberPaymentProvider.PaymentProviderProperties.Split(',');
                PaypalUserCredentials cred = new PaypalUserCredentials(userCredentials[0], userCredentials[1], userCredentials[2]);
                PaypalApi.UseSandbox = (userCredentials.Length == 3 || (userCredentials.Length > 3 && Convert.ToBoolean(userCredentials[3]) == true));
                string response = PaypalApi.GetExpressCheckoutDetails(cred, token);
                PaypalCommonResponse ppCommon = new PaypalCommonResponse(response);
                if (ppCommon.Ack == PaypalAckType.Success)
                {
                    // TODO: Paypal Payerinfo auswerten ?
                    PaypalPayerInfo             payer = new PaypalPayerInfo(response);
                    CustomerPaymentProviderInfo customerPaymentProvider = Controller.GetCustomerPaymentProvider(MainControl.Cart.CustomerPaymentProviderID);

                    // Save token and payerid in customerpaymentprovider for later confirmation of payment in paypal
                    customerPaymentProvider.PaymentProviderValues = ppCommon.Token + "," + payer.PayerId;
                    Controller.UpdateCustomerPaymentProvider(customerPaymentProvider);
                    Response.Redirect(Globals.NavigateURL(TabId, "", "action=" + MainControl.GetNextAction()));
                }
                else
                {
                    string message = "";
                    foreach (PaypalError error in ppCommon.Errors)
                    {
                        message += String.Format("ErrorNo:{0} Message {1}<br/>\r\n", error.ErrorNo, error.LongMessage);
                    }
                    MainControl.ErrorText += message;
                }
            }
        }
示例#2
0
        private void ProcessPayment(string method)
        {
            Boolean hasError  = false;
            string  errorText = "";

            int selectedIndex     = Convert.ToInt32(hidPPSelectedIndex.Value);
            int paymentProviderId = -1;

            PaymentProviderBase ppUI = null;

            // if we have any Paymentproviders defined
            if (selectedIndex < 0)
            {
                hasError  = true;
                errorText = Localization.GetString("ValidPaymentProvider.Error", this.LocalResourceFile);
            }
            else
            {
                paymentProviderId = (int)lstPaymentProvider.DataKeys[selectedIndex].Value;
                if (paymentProviderId < 0)
                {
                    hasError  = true;
                    errorText = Localization.GetString("ValidPaymentProvider.Error", this.LocalResourceFile);
                }
                else
                {
                    ppUI = FindControlRecursive(divMain, "pp" + paymentProviderId.ToString()) as PaymentProviderBase;
                    if (ppUI == null)
                    {
                        hasError  = true;
                        errorText = Localization.GetString("ValidPaymentProvider.Error", this.LocalResourceFile);
                    }
                    else if (ppUI.IsValid == false)
                    {
                        hasError  = true;
                        errorText = Localization.GetString("MandatoryFields.Error", this.LocalResourceFile);
                    }
                }
            }

            if (hasError)
            {
                MainControl.ErrorText = errorText;
            }
            else
            {
                MainControl.ErrorText = "";
                UpdatePayment(ppUI);
                switch (method)
                {
                case "standard":
                    Response.Redirect(Globals.NavigateURL(TabId, "", "action=" + MainControl.GetNextAction()));
                    break;

                case "paypal":
                    StartPaypalCheckout(ppUI.Properties, paymentProviderId);
                    break;
                }
            }
        }