コード例 #1
0
        public ViewResult Success(string request_token, string verification_code)
        {
            Log.InfoFormat("PayPal Add callback, token:{0} verification code:{1}", request_token, verification_code);

            if (string.IsNullOrEmpty(verification_code) && string.IsNullOrEmpty(request_token))
            {
                Log.InfoFormat("PayPal adding was canceled by customer");
                return(View("PayPalCanceled"));
            }

            var paypal = ObjectFactory.GetInstance <PayPalDatabaseMarketPlace>();

            var customer = this.context.Customer;

            PayPalPermissionsGranted permissionsGranted;
            PayPalPersonalData       personalData;

            try
            {
                permissionsGranted = PayPalServiceHelper.GetAccessToken(request_token, verification_code);
                personalData       = PayPalServiceHelper.GetAccountInfo(permissionsGranted);
                this.mpChecker.Check(paypal.InternalId, customer, personalData.Email);
            }
            catch (PayPalException e)
            {
                Log.Warn(e);
                return(View("Error", (object)string.Join("<br />", e.ErrorDetails.Select(x => x.message).ToList())));
            }
            catch (MarketPlaceAddedByThisCustomerException)
            {
                return(View("Error", (object)DbStrings.PayPalAddedByYou));
            }
            catch (MarketPlaceIsAlreadyAddedException)
            {
                return(View("Error", (object)DbStrings.AccountAlreadyExixtsInDb));
            }

            int mpId = 0;

            Transactional.Execute(() => {
                mpId = SavePayPal(customer, permissionsGranted, personalData, paypal);
            });

            if (mpId > 0)
            {
                this.serviceClient.Instance.UpdateMarketplace(customer.Id, mpId, true, this.context.UserId);
            }

            return(View(permissionsGranted));
        }
コード例 #2
0
 public PayPalPermissionsGranted GetAccessToken(string requestToken, string verificationCode)
 {
     return(PayPalServiceHelper.GetAccessToken(requestToken, verificationCode));
 }