PayPal Merchant SDK GetExpressCheckoutDetailsResponseDetails not returning buyer's email or phone number

时间:2015-10-29 15:57:36

标签: paypal

I'm using the PayPal Merchant SDK for .NET (v 2.15.117) and am trying to retrieve the shipping address info, customer's email address, and phone number from the GetExpressCheckoutDetailsRequestType.GetExpressCheckoutDetailsResponseDetails call. The shipping address is populated as expected but for the life of me, I can't figure out how to get the buyer's email or phone number. At a minimum we have to have the email to communicate about the order (ie tracking emails).

I see a BuyerMarketingEmail property but it is null and I am under the impression that is an optional email the buyer can choose to provide. For phone, I see a PayerInfo.ContactPhone property but that is also null (and I'm less concerned about having that but it would be nice for customer service issues or to give to ground shippers like FedEx).

I am using the PayPal sandbox if that matters.

What am I missing?

var getExpressCheckoutDetails = new GetExpressCheckoutDetailsReq();

var getExpressCheckoutDetailsRequest = new GetExpressCheckoutDetailsRequestType(token);

getExpressCheckoutDetails.GetExpressCheckoutDetailsRequest = getExpressCheckoutDetailsRequest;

var service = new PayPalAPIInterfaceServiceService();

paypalResponse = service.GetExpressCheckoutDetails(getExpressCheckoutDetails);

if (paypalResponse != null)
{
    //Success values check for a matching PayerID to validate the token response
    if (paypalResponse.Ack.ToString().Trim().ToUpper().Equals("SUCCESS") &&
        PayerID == paypalResponse.GetExpressCheckoutDetailsResponseDetails.PayerInfo.PayerID)
    {
        checkout.ShippingInfo.ShippingName = paypalResponse.GetExpressCheckoutDetailsResponseDetails.PayerInfo.Address.Name;
        checkout.ShippingInfo.ShippingAddress1 = paypalResponse.GetExpressCheckoutDetailsResponseDetails.PayerInfo.Address.Street1;
        checkout.ShippingInfo.ShippingAddress2 = paypalResponse.GetExpressCheckoutDetailsResponseDetails.PayerInfo.Address.Street2;
        checkout.ShippingInfo.ShippingCity = paypalResponse.GetExpressCheckoutDetailsResponseDetails.PayerInfo.Address.CityName;
        checkout.ShippingInfo.ShippingState = paypalResponse.GetExpressCheckoutDetailsResponseDetails.PayerInfo.Address.StateOrProvince;
        checkout.ShippingInfo.ShippingZip = paypalResponse.GetExpressCheckoutDetailsResponseDetails.PayerInfo.Address.PostalCode;
        checkout.ShippingInfo.ShippingCountry = paypalResponse.GetExpressCheckoutDetailsResponseDetails.PayerInfo.Address.Country.ToString();

        //these next two are always null
        checkout.BillingInfo.Email = paypalResponse.GetExpressCheckoutDetailsResponseDetails.BuyerMarketingEmail;
        checkout.ShippingInfo.PhoneNumber = paypalResponse.GetExpressCheckoutDetailsResponseDetails.PayerInfo.ContactPhone;
    }   
}

1 个答案:

答案 0 :(得分:0)

以为我会发布一个答案来解决这个问题 -

如上所述,我对原始问题的评论中,买方的电子邮件地址为PayerInfo.Payer

此外,突然/神奇地,PayerInfo.ContactPhone开始返回电话号码而不是空。我只能在Sandbox环境或我的沙盒用户帐户中使用它。