简体   繁体   中英

Billing fields not prepopulated by PayPal SDK

I am using the PayPal Merchant .NET SDK http://paypal.github.io/sdk/ to implement Express Checkout.

The code snippet bellow is for my SetExpressCheckout call. The only field that gets pre-populated is the email address. Does anyone know the right way to do this? BTW - the PayPal billing screen has First and Last name fields but the API only has a name field???

SetExpressCheckoutRequestType request = new SetExpressCheckoutRequestType();
SetExpressCheckoutRequestDetailsType ecDetails = new SetExpressCheckoutRequestDetailsType();
...
ecDetails.ReqConfirmShipping = "0";
ecDetails.NoShipping = "1";
ecDetails.AddressOverride = "1";
ecDetails.SolutionType = SolutionTypeType.SOLE;
PaymentDetailsType paymentDetails = new PaymentDetailsType();
CurrencyCodeType currency = CurrencyCodeType.USD;
paymentDetails.OrderDescription = "Test";
paymentDetails.OrderTotal = new BasicAmountType(currency, "1.00");
ecDetails.PaymentDetails.Add(paymentDetails);
ecDetails.PaymentAction = PaymentActionCodeType.SALE;
ecDetails.LandingPage = LandingPageType.BILLING;
ecDetails.BuyerEmail = "bob@smith.com";
AddressType address = new AddressType();
address.Name = "Bob";
address.Street1 = "123 somewhere st";
address.Street2 = "#32";
address.CityName = "Houston";
address.StateOrProvince = "TX";
address.PostalCode = "12345";
address.CountryName = "US";
address.Phone = "123-456-7890";
ecDetails.BillingAddress = address;
request.SetExpressCheckoutRequestDetails = ecDetails;

I've played around with the first 3 settings shown and have it doesn't seem to help. The email is populated and the order description is fine. Country is set based on my test account and not the address

From https://developer.paypal.com/webapps/developer/docs/classic/api/merchant/SetExpressCheckout_API_Operation_NVP/

ADDROVERRIDE
(Optional) Determines whether or not the PayPal pages should display the shipping address set by you in this SetExpressCheckout request, not the shipping address on file with PayPal for this buyer. Displaying the PayPal street address on file does not allow the buyer to edit that address. It is one of the following values:

0 – The PayPal pages should not display the shipping address.

1 – The PayPal pages should display the shipping address.

Character length and limitations: 1 single-byte numeric character.

Use ecDetails.AddressOverride = 1; as the .NET SDK version of this.

Also you need to set paymentDetails.ShipToAddress instead of ecDetails.BillingAddress filling out the billing address requires PAYMENTREQUEST_0_SHIPTONAME etc fields to be set. Which means your first ecDetails.PaymentDetails must have the address associated with it.

For setting the users name it is a string that would be address.Name = "Bob Smith";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM