Changes to allow Shipping Address to be passed to PayPal Standard

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Il y a 14 ans
Hi, just thought I'd share my solution to the problem where the shipping address does not get passed to PayPal Standard if the buyer does not have a PayPal account.

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
Il y a 14 ans
Hi Phil,

Thanks for the helpful post. I am also facing the same issue but I am using PayPal Direct. Your code will definitely be of more help to me.

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