Announcement

Collapse
No announcement yet.

My shipping module isn't showing methods to Paypal Commerce

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    My shipping module isn't showing methods to Paypal Commerce

    My shipping module has been working well on one of the sites I manage that uses Paypal Express Checkout. But the other day I installed it on a site that uses the newer Paypal Commerce Platform, and now on that site, Paypal doesn't show any shipping methods. Instead, the customer gets a message in the Paypal popup that says "http://www.example.com doesn't ship to this location. Please use a different address."

    There are a couple of weird things with that. First, I watched the basketInfo table on a fresh cart, and even though Paypal responds with that message, I see that my module inserted some rates into basketInfo, so it definitely did find rates for the provided address. The second weird thing is that I didn't initially disable the other shipping module that was active on the site (instead I just modified the OSEL template to ignore any methods from that module). So even if my module didn't respond, Paypal still should have gotten methods from the existing module..

    I thought it might be a timeout thing, that Paypal didn't like waiting for both my module and the existing module to get rates, so I disabled the existing one. Unfortunately Paypal still gives the same message though

    Can anyone think of something obvious I might have missed?

    EDIT:

    Some testing has shown that disabling my module allows the existing module to return rates. So something about having my module enabled blocks all other modules from working.

    I figured I'd try changing the `ShippingModule_Basket_Methods` to something extremely basic, but even so, Paypal still fails to see any methods..

    Code:
    <mvFunction
       name="ShippingModule_Basket_Methods"
       parameters="module var, packages var, package_count, methods var"
       standardOutputLevel="text, html, compresswhitespace"
    >
       <mvComment>
          * ****FOR TESTING****, ignore everything this function might do, and do some other thing instead
       </mvComment>
       <mvIf expr="{1}">
          <mvAssign name="l.methods" value="">
          <mvAssign name="l.method_count" value=0>
          <mvAssign name="l.method" value="">
          <mvAssign name="l.method:code" value="'fake'">
          <mvAssign name="l.method:price" value="111.11">
          <mvAssign name="l.method:name" value="'FakeShipping'">
          <mvAssign name="l.method_count" value="{ miva_array_insert_var( l.methods, l.method, -1 ) }">
          <mvFunctionReturn value="{ l.method_count }">
       </mvIf>
    
       ...
    
    ​​​​​​​</mvFunction>






    Last edited by Mike521w; 08-26-22, 08:57 AM.
    Looking for work as of March 2024! I've been a web developer for going on 20 years, with most of that time spent on Miva sites.

    #2
    sounds like something simple like a variable name change has occurred. Is your shipping module's API up to date?
    Bruce Golub
    Phosphor Media - "Your Success is our Business"

    Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
    phosphormedia.com

    Comment


      #3
      hi Bruce, by API do you mean the compiler I'm using? hmm let me update that, I can't remember the last time I did

      EDIT: I updated to v5.36, I was on 5.35. I also realized you probably meant this:

      Code:
      <mvAssign name="l.module:api_ver" value="10.04">
      I was previously at 5.72, I changed it to 10.04 and recompiled, but unfortunately no luck, Paypal still says the site doesn't ship there.. What makes it more frustrating is that Miva gets shipping methods just fine on OSEL and in admin..
      Last edited by Mike521w; 08-26-22, 10:53 AM.
      Looking for work as of March 2024! I've been a web developer for going on 20 years, with most of that time spent on Miva sites.

      Comment


        #4
        no, this:

        <MvASSIGN NAME = "l.module:api_ver" VALUE = "6.00">

        This will define what function calls the module recieves and what miva functions are supported within the module.

        But what I'm getting at is more like paypal is looking for the shipping method to be passed as shipmethod=xxxx when it used to be shippingmethod=xxxx. so the first thing to check is whether the other shipping modules have recently be updated. now that i've said that, seems a bit unlikely. but its still sort of the thing i'd look for.
        Bruce Golub
        Phosphor Media - "Your Success is our Business"

        Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
        phosphormedia.com

        Comment


          #5
          I'm not sure how to debug that.. It seemed to me when I was writing this module that the most important part was the `ShippingModule_Basket_Methods` function, which is where the calculation takes place. This function is responsible for populating the `l.methods` array with methods, each entry must have `price`, `code`, and `name`. Once I got that sorted out, I was able to see my methods in Miva on OSEL.

          But unfortunately the shipping modules in the LSK are all on an old API and don't even implement `ShippingModule_Basket_Methods`, so it's hard to use them as a guide for how to get Paypal Commerce working. Furthermore I don't see a way for how I can debug this - I can't compare the output from the original module vs mine to see what the difference is. I can't even see exactly what mine is sending to paypal. All I know for sure is that mine is definitely calculating methods because the last thing it does in `ShippingModule_Basket_Methods` is populate the basketInfo table, and I can see that this step happens and the data is as expected.
          Looking for work as of March 2024! I've been a web developer for going on 20 years, with most of that time spent on Miva sites.

          Comment


            #6
            See page 200 in the Module API Guide for the available functions for a shipping module:

            https://www.miva.com/apiguide

            I believe your module need to implement ShippingModule_Enabled_Methods function and ShippingModule_Basket_Methods

            Do your shipping methods for this module show up in the Miva admin under Shipping Settings?
            Brennan Heyde
            VP Product
            Miva, Inc.
            [email protected]
            https://www.miva.com

            Comment


              #7
              Hi Brennan, thanks for the info,

              I do have both of those functions implemented, and yep the methods show up in Miva admin > Shipping Settings..

              One other piece of info I've figured out - if my module and the previous shipping module are both enabled, Paypal Commerce gives that error message. But if I disable my module, Paypal Commerce will show the methods that the previous module generates. So basically, my module is somehow screwing up the works.

              But again, my module's methods show up in both Miva admin and on OSEL..

              Is there a way to log the output that gets sent to Paypal Commerce so I can compare my module vs prior? Or can you think of any other way to determine what the issue is?

              Another thing just dawned on me while reviewing my `ShippingModule_Enabled_Methods` function. It populates the `l.methods` variable with a list of methods that have a code and a name. The code does NOT match what the `ShippingModule_Basket_Methods` function generates. In `ShippingModule_Basket_Methods` I prefix the codes with numbers so that they show up in the order I want on OSEL's select menu (sorted by price).. Could Paypal be getting annoyed that the codes don't match?
              Looking for work as of March 2024! I've been a web developer for going on 20 years, with most of that time spent on Miva sites.

              Comment


                #8
                I found the problem, it has to do with the fact that I'm using basketInfo to save the shipping methods so I don't have to retrieve them from APIs again when `ShippingModule_Calculate_Basket` is called.

                Unbeknownst to me, when Paypal Commerce loads it's popup, it not only retrieves rates via `ShippingModule_Basket_Methods`, but it also calls `ShippingModule_Calculate_Basket`. When I was testing my module against Miva checkout, I could match up the saved shipping methods against `g.ShippingMethod` (from OSEL). But Paypal Commerce isn't populating `g.ShippingMethod`, instead it's populating `l.data`, so I had to compare against that. I shouldn't have been using `g.ShippingMethod` in the first place, the documentation states that `l.data` has the code of the selected method.

                Once I figured that out and updated it, Paypal Commerce started getting rates.
                Looking for work as of March 2024! I've been a web developer for going on 20 years, with most of that time spent on Miva sites.

                Comment

                Working...
                X