Пример #1
0
        public ActionResult paypalPreapprovalSubmit(PaypalPreapprovalAdminForm form)
        {
            if (ModelState.IsValid)
            {
                //var timezone = TimeZoneInfo.FindSystemTimeZoneById("Antarctica/Troll");
                var timezone = TimeZoneInfo.FindSystemTimeZoneById("Israel Standard Time");//it's the same with Antarctica/Troll
                if (form.starting_date != null)
                {
                    form.starting_date = TimeZoneInfo.ConvertTimeFromUtc(form.starting_date, timezone);
                }

                if (form.ending_date != null)
                {
                    form.ending_date = TimeZoneInfo.ConvertTimeFromUtc(form.ending_date, timezone);
                }

                Mapper.CreateMap<PaypalPreapprovalAdminForm, paypal_preapproval>();

                var paypalPreapproval = Mapper.Map<paypal_preapproval>(form);
                paypalPreapproval.flag = Guid.NewGuid().ToString();

                var result = PaypalPreapprovalRequest(paypalPreapproval);
                if (result.responseEnvelope.ack.HasValue && result.responseEnvelope.ack.Value.ToString().ToLower() == "failure")
                {
                    form.error = String.Format("Fail from field: {0}, message: {1}", result.error[0].parameter[0].name, result.error[0].message);
                    return View("submit", form);
                }
                else
                {
                    var api = GoPlayApi.Instance;

                    var key = result.preapprovalKey;
                    paypalPreapproval.preapproval_key = key;

                    this.Flash("Submitting...", FlashLevel.Success);

                    paypalPreapproval.created_at = DateTime.UtcNow;
                    api.CreatePaypalPreapproval(paypalPreapproval);

                    return Redirect(ConfigurationManager.AppSettings["PAYPAL_CONFIRM_KEY_URL"] + key);

                }

            }
            return View("submit", form);
        }
Пример #2
0
 public ActionResult GetPaypalPreapprovalSubmit()
 {
     var model = new PaypalPreapprovalAdminForm();
     return View("submit", model);
 }