PAYPAL CART & SHIPPING ADDRESS NOT CAPTURED USING CC DIRECT

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
15 anni tempo fa
thanks, Do you know when the next version will be out?

Mike Wazee
15 anni tempo fa
March-April 2010
15 anni tempo fa
>Stevdude

NO not in the Dec 2009 release:
15 anni tempo fa
I posted this is another area but thought I would reply to your post directly.  I had the same problem with shipping address not getting to PayPal direct.  The following changes will solve the problem.


Changes made to PayPalStandardPaymentProcessor.cs in PostProcessPayment method.

Add this line to allow buyer address to show up when redirected to PayPal:
builder.AppendFormat("&address_override=1");

This line needed changing for the email address to show up (change from "&Email={0}"to lowercase "&email={0}"):
builder.AppendFormat("&email={0}", HttpUtility.UrlEncode(order.BillingEmail));

These lines were added because these properties were missing:
builder.AppendFormat("&zip={0}", HttpUtility.UrlEncode(order.BillingZipPostalCode));
if (!String.IsNullOrEmpty(order.BillingPhoneNumber))
{
   //strip out all non-digit characters from phone number; only use if 7 or more digits (could include extension at end)
   string billingPhoneNumber = System.Text.RegularExpressions.Regex.Replace(order.BillingPhoneNumber, @"\D", string.Empty);
   if (billingPhoneNumber.Length >= 7)
   {
      builder.AppendFormat("&night_phone_a={0}", HttpUtility.UrlEncode(billingPhoneNumber.Substring(0, 3)));
      builder.AppendFormat("&night_phone_b={0}", HttpUtility.UrlEncode(billingPhoneNumber.Substring(3, 3)));
      builder.AppendFormat("&night_phone_c={0}", HttpUtility.UrlEncode(billingPhoneNumber.Substring(6, 4)));
   }
}


That's it,
Phil
15 anni tempo fa
>.Phil
Thanks I will give it a whirl and post my results..
Cheers.
15 anni tempo fa
phil

No luck
I made the code change, compiled and moved the dlls, still same result, no shipping address or cart contents.


Can I ask , why change PayPal standard PayPalStandardPaymentProcessor.cs

if the issue is with PayPal Direct,PayPalDirectPaymentProcessor.cs

This area I would have thought?

/// Authorizes the payment
        /// </summary>
        /// <param name="paymentInfo">Payment info required for an order processing</param>
        /// <param name="customer">Customer</param>
        /// <param name="OrderGuid">Unique order identifier</param>
        /// <param name="processPaymentResult">Process payment result</param>
        /// <param name="authorizeOnly">A value indicating whether to authorize only; true - authorize; false - sale</param>
        protected void AuthorizeOrSale(PaymentInfo paymentInfo, Customer customer, Guid OrderGuid, ProcessPaymentResult processPaymentResult, bool authorizeOnly)
        {
            InitSettings();

            DoDirectPaymentReq req = new DoDirectPaymentReq();
            req.DoDirectPaymentRequest = new DoDirectPaymentRequestType();
            req.DoDirectPaymentRequest.Version = this.APIVersion;
            DoDirectPaymentRequestDetailsType details = new DoDirectPaymentRequestDetailsType();
            req.DoDirectPaymentRequest.DoDirectPaymentRequestDetails = details;
            details.IPAddress = HttpContext.Current.Request.UserHostAddress;
            if (authorizeOnly)
                details.PaymentAction = PaymentActionCodeType.Authorization;
            else
                details.PaymentAction = PaymentActionCodeType.Sale;
            details.CreditCard = new CreditCardDetailsType();
            details.CreditCard.CreditCardNumber = paymentInfo.CreditCardNumber;
            details.CreditCard.CreditCardType = GetPaypalCreditCardType(paymentInfo.CreditCardType);
            details.CreditCard.ExpMonthSpecified = true;
            details.CreditCard.ExpMonth = paymentInfo.CreditCardExpireMonth;
            details.CreditCard.ExpYearSpecified = true;
            details.CreditCard.ExpYear = paymentInfo.CreditCardExpireYear;
            details.CreditCard.CVV2 = paymentInfo.CreditCardCVV2;

            details.CreditCard.CardOwner = new PayerInfoType();
            details.CreditCard.CardOwner.PayerCountry = GetPaypalCountryCodeType(paymentInfo.BillingAddress.Country);

            details.CreditCard.CardOwner.Address = new AddressType();
            details.CreditCard.CardOwner.Address.CountrySpecified = true;
            details.CreditCard.CardOwner.Address.Street1 = paymentInfo.BillingAddress.Address1;
            details.CreditCard.CardOwner.Address.Street2 = paymentInfo.BillingAddress.Address2;
            details.CreditCard.CardOwner.Address.CityName = paymentInfo.BillingAddress.City;
            if (paymentInfo.BillingAddress.StateProvince != null)
                details.CreditCard.CardOwner.Address.StateOrProvince = paymentInfo.BillingAddress.StateProvince.Abbreviation;
            details.CreditCard.CardOwner.Address.Country = GetPaypalCountryCodeType(paymentInfo.BillingAddress.Country);
            details.CreditCard.CardOwner.Address.PostalCode = paymentInfo.BillingAddress.ZipPostalCode;
            details.CreditCard.CardOwner.PayerName = new PersonNameType();
            details.CreditCard.CardOwner.PayerName.FirstName = paymentInfo.BillingAddress.FirstName;
            details.CreditCard.CardOwner.PayerName.LastName = paymentInfo.BillingAddress.LastName;
            details.PaymentDetails = new PaymentDetailsType();
            details.PaymentDetails.OrderTotal = new BasicAmountType();
            details.PaymentDetails.OrderTotal.Value = paymentInfo.OrderTotal.ToString("N", new CultureInfo("en-us"));
            details.PaymentDetails.OrderTotal.currencyID = PaypalHelper.GetPaypalCurrency(CurrencyManager.PrimaryStoreCurrency);
            details.PaymentDetails.Custom = OrderGuid.ToString();
            details.PaymentDetails.ButtonSource = "nopCommerceCart";

            DoDirectPaymentResponseType response = service2.DoDirectPayment(req);

            string error = string.Empty;
            bool Success = PaypalHelper.CheckSuccess(response, out error);
            if (Success)
            {
                processPaymentResult.AuthorizationTransactionID = response.TransactionID;
                processPaymentResult.AuthorizationTransactionResult = response.Ack.ToString();





Thanks for the post and time!
G
15 anni tempo fa
Sorry, my fix was for PayPal Standard not for PayPal Direct.  Sorry for the confusion but the same changes in the appropriate method for PayPal Direct should work.

Phil
15 anni tempo fa
Thanks for everyone's contribution. I have an additional complain from my staff. They say that orders on PayPal also do not have the customer's email address. There is another helpful post but its about PayPal Standard but that's not my case. I have also confirmed that this bug has not been fixed in the latest release (1.4)

So I am wrote some code and its working fine as I tested it with a Real Credit Card and Real PayPal account. Here are the steps:

1. Locate the file 'PayPalDirectPaymentProcessor.cs' in 'Nop.Payment.PayPal' project.
2. Go to function 'AuthorizeOrSale'
3. Go to line 255 or find this line:

details.CreditCard.CardOwner.Address.PostalCode = paymentInfo.BillingAddress.ZipPostalCode;


and insert the following line for customer Email address

details.CreditCard.CardOwner.Payer = customer.Email;


4. Locate the following line

details.PaymentDetails.ButtonSource = "nopCommerceCart";


and below it insert the following code:

AddressType shipToAddress = new AddressType();
Address shippingAddress = paymentInfo.ShippingAddress;

shipToAddress.Name = string.Format("{0} {1}", shippingAddress.FirstName, shippingAddress.LastName);
shipToAddress.Street1 = shippingAddress.Address1;
shipToAddress.Street2 = shippingAddress.Address2;
shipToAddress.CityName = shippingAddress.City;
if (shippingAddress.StateProvince != null)
  shipToAddress.StateOrProvince = shippingAddress.StateProvince.Abbreviation;
shipToAddress.PostalCode = shippingAddress.ZipPostalCode;
shipToAddress.Country = GetPaypalCountryCodeType(shippingAddress.Country);
shipToAddress.CountryName = shippingAddress.Country.Name;
shipToAddress.CountrySpecified = true;
shipToAddress.Phone = shippingAddress.PhoneNumber;

details.PaymentDetails.ShipToAddress = shipToAddress;


and the next line would be:

DoDirectPaymentResponseType response = service2.DoDirectPayment(req);


Hope this helps.
Naveed Saqib
15 anni tempo fa
I also needed to add Shopping Cart Items into PayPal so here is the latest version.


protected void AuthorizeOrSale(PaymentInfo paymentInfo, Customer customer, Guid OrderGuid, ProcessPaymentResult processPaymentResult, bool authorizeOnly)
{
    InitSettings();

    DoDirectPaymentReq req = new DoDirectPaymentReq();
    req.DoDirectPaymentRequest = new DoDirectPaymentRequestType();
    req.DoDirectPaymentRequest.Version = this.APIVersion;

    DoDirectPaymentRequestDetailsType details = new DoDirectPaymentRequestDetailsType();
    req.DoDirectPaymentRequest.DoDirectPaymentRequestDetails = details;

  details.IPAddress = HttpContext.Current.Request.UserHostAddress;
  details.PaymentAction = (authorizeOnly ? PaymentActionCodeType.Authorization : PaymentActionCodeType.Sale);

  details.CreditCard = new CreditCardDetailsType()
  {
    CreditCardNumber = paymentInfo.CreditCardNumber,
    CreditCardType = GetPaypalCreditCardType(paymentInfo.CreditCardType),
    ExpMonthSpecified = true,
    ExpMonth = paymentInfo.CreditCardExpireMonth,
    ExpYearSpecified = true,
    ExpYear = paymentInfo.CreditCardExpireYear,
    CVV2 = paymentInfo.CreditCardCVV2,
    CardOwner = new PayerInfoType()
    {
      PayerCountry = GetPaypalCountryCodeType(paymentInfo.BillingAddress.Country),
      Address = new AddressType()
      {
        CountrySpecified = true,
        Street1 = paymentInfo.BillingAddress.Address1,
        Street2 = paymentInfo.BillingAddress.Address2,
        CityName = paymentInfo.BillingAddress.City,
        StateOrProvince = paymentInfo.BillingAddress.StateProvince.Abbreviation,
        Country = GetPaypalCountryCodeType(paymentInfo.BillingAddress.Country),
        PostalCode = paymentInfo.BillingAddress.ZipPostalCode,
      },
      Payer = customer.Email,
      PayerName = new PersonNameType()
      {
        FirstName = paymentInfo.BillingAddress.FirstName,
        LastName = paymentInfo.BillingAddress.LastName
      }
    }
  };

  Address ship = paymentInfo.ShippingAddress;
  details.PaymentDetails = new PaymentDetailsType()
  {
    OrderTotal = new BasicAmountType()
    {
      Value = paymentInfo.OrderTotal.ToString("N", new CultureInfo("en-us")),
      currencyID = PaypalHelper.GetPaypalCurrency(CurrencyManager.PrimaryStoreCurrency)
    },
    Custom = OrderGuid.ToString(),
    ButtonSource = "nopCommerceCart",
    ShipToAddress = new AddressType()
    {
      Name = string.Format("{0} {1}", ship.FirstName, ship.LastName),
      Street1 = paymentInfo.ShippingAddress.Address1,
      Street2 = paymentInfo.ShippingAddress.Address2,
      CityName = ship.City,
      StateOrProvince = ship.StateProvince.Abbreviation,
      PostalCode = ship.ZipPostalCode,
      Country = GetPaypalCountryCodeType(ship.Country),
      CountryName = ship.Country.Name,
      CountrySpecified = true,
      Phone = ship.PhoneNumber,
    }
  };

  // Add Shopping Cart Items
  ShoppingCart cart = ShoppingCartManager.GetShoppingCartByCustomerSessionGUID(
    ShoppingCartTypeEnum.ShoppingCart, NopContext.Current.Session.CustomerSessionGUID);
  PaymentDetailsItemType[] cartItems = new PaymentDetailsItemType[cart.Count];

  for(int i = 0; i < cart.Count; i++)
  {
    ShoppingCartItem item = cart[i];
    cartItems[i] = new PaymentDetailsItemType()
    {
      Name = item.ProductVariant.Product.Name,
      Number = item.ProductVariant.eBayProductID,
      Quantity = item.Quantity.ToString(),
      Amount = new BasicAmountType()
      {
        currencyID = PaypalHelper.GetPaypalCurrency(CurrencyManager.PrimaryStoreCurrency),
        Value = (item.Quantity * item.ProductVariant.Price).ToString("N", new CultureInfo("en-us"))
      }
    };
  };
  details.PaymentDetails.PaymentDetailsItem = cartItems;

    DoDirectPaymentResponseType response = service2.DoDirectPayment(req);

    string error = string.Empty;
    bool Success = PaypalHelper.CheckSuccess(response, out error);
    if (Success)
    {
        processPaymentResult.AuthorizationTransactionID = response.TransactionID;
        processPaymentResult.AuthorizationTransactionResult = response.Ack.ToString();


        processPaymentResult.AVSResult = response.AVSCode;
        processPaymentResult.AuthorizationTransactionCode = response.CVV2Code;
        if (authorizeOnly)
            processPaymentResult.PaymentStatus = PaymentStatusEnum.Authorized;
        else
            processPaymentResult.PaymentStatus = PaymentStatusEnum.Paid;

    }
    else
    {
        processPaymentResult.Error = error;
        processPaymentResult.FullError = error;
    }
}


Hope this helps.
Naveed Saqib
14 anni tempo fa
Phil you are a legend! I spent hours trying to sort this out until I cam across your post.

I am using 1.6 and paypal standard.

Thanks,

James.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.