paypal direct - shipping address

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Il y a 14 ans
If you send the shipping address to paypal with the direct api, you can print shipping labels from paypal. works pretty well.

I enabled this in the store with just a few lines of code:

In PaypaldirectPaymentProcesssor:AuthorizeOrSale, add this:

if (sendShippingAddress && paymentInfo.ShippingAddress != null)
            {
                details.PaymentDetails.ShipToAddress = new AddressType();
                details.PaymentDetails.ShipToAddress.CountrySpecified = true;
                details.PaymentDetails.ShipToAddress.Street1 = paymentInfo.ShippingAddress.Address1;
                details.PaymentDetails.ShipToAddress.Street2 = paymentInfo.ShippingAddress.Address2;
                details.PaymentDetails.ShipToAddress.CityName = paymentInfo.ShippingAddress.City;
                if (paymentInfo.ShippingAddress.StateProvince != null)
                    details.PaymentDetails.ShipToAddress.StateOrProvince = paymentInfo.ShippingAddress.StateProvince.Abbreviation;
                details.PaymentDetails.ShipToAddress.Country = GetPaypalCountryCodeType(paymentInfo.ShippingAddress.Country);
                details.PaymentDetails.ShipToAddress.PostalCode = paymentInfo.ShippingAddress.ZipPostalCode;
                details.PaymentDetails.ShipToAddress.Name = paymentInfo.ShippingAddress.FirstName + " " + paymentInfo.ShippingAddress.LastName;
              
            }

I added the "sendShippingAddress" as a boolean value pulled from the settings db, so you can turn this feature on or off.
Il y a 14 ans
hey boomhauer-

Thanks, that's awesome! I am going to try to implement it right now.

I hate entering this information and I assumed it was a problem with the IPN integration that was going to be fixed in the soon to be release 1.5!

Update:

I tried to copy and paste the code into the method you described:
AuthorizeOrSale
but it seemed that one of the variables you provided was out of scope for me, maybe you could clarify.

sendShippingAddress 
throws: "This variable doesn't appear in this context..."


Il y a 14 ans
I added that variable as a switch that is turned off or on via the app settings.. you can elimnate it if you want the shipping info to always be sent. should be no problem.
Il y a 14 ans
I see, ok for now Ill try without it, but I want the switch I would just create it in the "admin-->all settings" to enter it into the database as a new parameter?

No way it's that easy?

Good work this was one of the big things I was looking forward too in 1.5, at least if it doesn't get fixed I can fall back on this!
Il y a 14 ans
Nope, youll need to add a section to the InitSettings (i believe it is called...) method to load the setting.
Il y a 14 ans
Ok! Thanks, most importantly, I'm curious if there is another line I can add to include emails collected by my store so that customers will receive the tracking number after it is generated by Paypal.

I know I need to learn the IPN API or wait for a fixed version of nopCommerce to include the IPN fix.
Il y a 14 ans
entered the following, tried a test order, no shipping info in Paypal?:

protected void AuthorizeOrSale(PaymentInfo paymentInfo, Customer customer, Guid OrderGuid, ProcessPaymentResult processPaymentResult, bool authorizeOnly)
{
                   ....this is a long method so left a lot out.

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

            
//new code at the end of the method

if (paymentInfo.ShippingAddress != null)
{
details.PaymentDetails.ShipToAddress = new AddressType();
details.PaymentDetails.ShipToAddress.CountrySpecified = true;
details.PaymentDetails.ShipToAddress.Street1 = paymentInfo.ShippingAddress.Address1;
details.PaymentDetails.ShipToAddress.Street2 = paymentInfo.ShippingAddress.Address2;
details.PaymentDetails.ShipToAddress.CityName = paymentInfo.ShippingAddress.City;
if (paymentInfo.ShippingAddress.StateProvince != null)
  details.PaymentDetails.ShipToAddress.StateOrProvince = paymentInfo.ShippingAddress.StateProvince.Abbreviation;
  details.PaymentDetails.ShipToAddress.Country = GetPaypalCountryCodeType(paymentInfo.ShippingAddress.Country);
  details.PaymentDetails.ShipToAddress.PostalCode = paymentInfo.ShippingAddress.ZipPostalCode;
  details.PaymentDetails.ShipToAddress.Name = paymentInfo.ShippingAddress.FirstName + " " + paymentInfo.ShippingAddress.LastName;

            }


}

Il y a 14 ans
jbc, look at the code, that's too far down - the transaction has already been sent!

put the new block just after:

  details.PaymentDetails.OrderTotal.currencyID = PaypalHelper.GetPaypalCurrency(CurrencyManager.PrimaryStoreCurrency);
            details.PaymentDetails.Custom = OrderGuid.ToString();
            details.PaymentDetails.ButtonSource = "nopCommerceCart";


(or, anywhere in the section of the code where the request is being populated)

Brady
Il y a 14 ans
I'm starting to get a lot of issues with "No Shipping Required" occurring when the customer checks out!

This is a real pain. Since I have to contact customers whom have different shipping addresses than billing. I don't know for sure, but I don't remember this happening before I implemented this code.

So I'm going to go ahead and disable it and see what happens.
Il y a 14 ans
wow that's itneresting.. i havent had any reports of this with out site...
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.