Example #1
0
    void ProcessExpressReturn(string sToken)
    {
        //get the wrapper
        APIWrapper wrapper = GetPPWrapper();

        //they have come back from the PayPal site and have a token, so use this token to go get their info
        //and populate the shipping etc.
        Commerce.Common.Address payer = wrapper.GetExpressCheckout(sToken);

        //set it as well in the billing/shippig controls
        //TODO: CMC - Profile.LastBillingAddress == null was not valid - figure this out.
        if (string.IsNullOrEmpty(Profile.LastBillingAddress.Address1))
        {
            addBilling.SelectedAddress = payer;
        }
        else
        {
            addBilling.SelectedAddress = Profile.LastBillingAddress;
        }
        if (!payer.Equals(Profile.LastShippingAddress))
        {
            Profile.LastShippingAddress = payer;
        }
        if (string.IsNullOrEmpty(Profile.LastShippingAddress.Address1))
        {
            addShipping.SelectedAddress = payer;
        }
        else
        {
            addShipping.SelectedAddress = Profile.LastShippingAddress;
        }

        //save this address for this user
        OrderController.SaveAddress(payer);

        //set the token in the ViewState
        ViewState.Add("ppToken", payer.PayPalToken);
        ViewState.Add("ppID", payer.PayPalPayerID);

        //need to run the tax calc now that we have an address
        Profile.CurrentOrderTax = OrderController.CalculateTax(payer.Zip, currentOrder.CalculateSubTotal());


        //save down the order to the ViewState so that it can be picked up when Running the Charge
        SetOrderInfo();
    }
Example #2
0
        public Commerce.Common.Address GetExpressCheckout(string token)
        {
            //PayerInfo payer = new PayerInfo();
            Commerce.Common.Address payer = new Commerce.Common.Address();

            PayPalSvc.GetExpressCheckoutDetailsReq         req         = new GetExpressCheckoutDetailsReq();
            PayPalSvc.GetExpressCheckoutDetailsRequestType requestType = new GetExpressCheckoutDetailsRequestType();


            requestType.Token   = token;
            requestType.Version = PayPalServiceUtility.PayPalAPIVersionNumber;

            req.GetExpressCheckoutDetailsRequest = requestType;

            PayPalSvc.GetExpressCheckoutDetailsResponseType response = service2.GetExpressCheckoutDetails(req);

            string sOut = "";

            string errors = this.CheckErrors(response);

            if (errors == string.Empty)
            {
                string ack = response.Ack.ToString();
                payer.Email         = response.GetExpressCheckoutDetailsResponseDetails.PayerInfo.Payer;
                payer.PayPalPayerID = response.GetExpressCheckoutDetailsResponseDetails.PayerInfo.PayerID;
                payer.FirstName     = response.GetExpressCheckoutDetailsResponseDetails.PayerInfo.PayerName.FirstName;
                payer.LastName      = response.GetExpressCheckoutDetailsResponseDetails.PayerInfo.PayerName.LastName;
                payer.Address1      = response.GetExpressCheckoutDetailsResponseDetails.PayerInfo.Address.Street1;
                payer.Address2      = response.GetExpressCheckoutDetailsResponseDetails.PayerInfo.Address.Street2;
                payer.City          = response.GetExpressCheckoutDetailsResponseDetails.PayerInfo.Address.CityName;
                payer.StateOrRegion = response.GetExpressCheckoutDetailsResponseDetails.PayerInfo.Address.StateOrProvince;
                payer.Zip           = response.GetExpressCheckoutDetailsResponseDetails.PayerInfo.Address.PostalCode;
                payer.PayPalToken   = response.GetExpressCheckoutDetailsResponseDetails.Token;
                payer.Country       = response.GetExpressCheckoutDetailsResponseDetails.PayerInfo.Address.CountryName;
            }
            else
            {
                payer.PayPalPayerID = errors;
            }
            return(payer);
        }