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; } } }
private void UpdatePayment(PaymentProviderBase pp) { // First we'll save the CustomerPaymentprovider int customerPaymentProviderId = 0; CustomerPaymentProviderInfo cpp = Controller.GetCustomerPaymentProvider(MainControl.CustomerId, pp.PaymentProviderId); if (cpp == null) { cpp = new CustomerPaymentProviderInfo(); cpp.PaymentProviderId = pp.PaymentProviderId; cpp.PaymentProviderValues = pp.Values; cpp.CustomerId = MainControl.CustomerId; customerPaymentProviderId = Controller.NewCustomerPaymentProvider(cpp); } else { customerPaymentProviderId = cpp.CustomerPaymentProviderId; cpp.PaymentProviderId = pp.PaymentProviderId; cpp.PaymentProviderValues = pp.Values; cpp.CustomerId = MainControl.CustomerId; Controller.UpdateCustomerPaymentProvider(cpp); } // Next we need to update our PaymentProviderId in the cart Controller.UpdateCartCustomerPaymentProviderId(MainControl.CartId, customerPaymentProviderId); // and set the ID on our Cart Variable MainControl.Cart.CustomerPaymentProviderID = customerPaymentProviderId; }
protected void lstPaymentProvider_ItemDataBound(object sender, ListViewItemEventArgs e) { ListView lv = sender as ListView; ListViewDataItem item = e.Item as ListViewDataItem; SubscriberPaymentProviderInfo spp = item.DataItem as SubscriberPaymentProviderInfo; if (spp != null) { PlaceHolder ph = e.Item.FindControl("phPaymentProvider") as PlaceHolder; PaymentProviderInfo pp = PaymentProvider.Find(p => p.PaymentProviderId == spp.PaymentProviderId); if (pp != null) { Literal ltrTitle = e.Item.FindControl("ltrTitle") as Literal; ltrTitle.Text = "<h3 class=\"bbstore-cart-payment-header\">" + pp.ProviderName + "</h3>"; PaymentProviderBase ctrl = this.LoadControl(@"~\DesktopModules\BBStore\Providers\Payment\" + pp.ProviderControl.Trim() + ".ascx") as PaymentProviderBase; ctrl.DisplayMode = ViewMode.View; ctrl.Title = pp.ProviderName; ctrl.EnableViewState = true; ctrl.Properties = spp.PaymentProviderProperties; ctrl.Cost = spp.Cost; ctrl.CostPercent = spp.CostPercent; ctrl.TaxPercent = spp.TaxPercent; ctrl.PaymentProviderId = spp.PaymentProviderId; ctrl.ShowNetprice = MainControl.ShowNetPrice; ctrl.ID = "pp" + spp.SubscriberPaymentProviderId.ToString(); CustomerPaymentProviderInfo cusPP = Controller.GetCustomerPaymentProvider(MainControl.CustomerId, spp.PaymentProviderId); if (cusPP != null) { ctrl.Values = cusPP.PaymentProviderValues; if (cusPP.CustomerPaymentProviderId == MainControl.Cart.CustomerPaymentProviderID) { int index = item.DataItemIndex; string script = "<script type=\"text/javascript\">var paneIndex = " + index.ToString() + ";" + "</script>"; Page.ClientScript.RegisterStartupScript(typeof(Page), "SetActivePane", script); } } ph.Controls.Add(ctrl); ctrl = null; } } }
public abstract void UpdateCustomerPaymentProvider(CustomerPaymentProviderInfo CustomerPaymentProvider);
public abstract int NewCustomerPaymentProvider(CustomerPaymentProviderInfo CustomerPaymentProvider);