Saturday, April 12, 2014

PayPal Classic API Error Message--Order Total Is Missing

I was recently using the PayPal Classic API with ASP.NET by generating the appropriate ASP.NET and C# files using the PayPal Integration Wizard: https://devtools-paypal.com/integrationwizard/

However, once I downloaded the code and began using it, I kept on encountering this error message from the API: "Order total is missing"

After going back and forth with PayPal Technical Support, they were not able to determine the root cause of the problem in the source code, however, they told me that the version number information was WRONG!

The version number was being sent as "2.3", when it should be a much later release such as "112.0"!!  The list of version numbers can be found here: https://developer.paypal.com/webapps/developer/docs/classic/release-notes/#MerchantAPI%29

After digging around in the source code a bit further, I discovered that this function was responsible for generating the incorrect version number!

/// <summary>

    /// Credentials added to the NVP string

    /// </summary>

    /// <param name="profile"></param>

    /// <returns></returns>

    private string buildCredentialsNVPString()

    {

        NVPCodec codec = new NVPCodec();

 

        if (!IsEmpty(APIUsername))

            codec["USER"] = APIUsername;

 

        if (!IsEmpty(APIPassword))

            codec[PWD] = APIPassword;

 

        if (!IsEmpty(APISignature))

            codec[SIGNATURE] = APISignature;

 

        if (!IsEmpty(Subject))

            codec["SUBJECT"] = Subject;

 

        codec["VERSION"] = "2.3";

 

        return codec.Encode();

    }
After I changed the source code to the following:

/// <summary>

    /// Credentials added to the NVP string

    /// </summary>

    /// <param name="profile"></param>

    /// <returns></returns>

    private string buildCredentialsNVPString()

    {

        NVPCodec codec = new NVPCodec();

 

        if (!IsEmpty(APIUsername))

            codec["USER"] = APIUsername;

 

        if (!IsEmpty(APIPassword))

            codec[PWD] = APIPassword;

 

        if (!IsEmpty(APISignature))

            codec[SIGNATURE] = APISignature;

 

        if (!IsEmpty(Subject))

            codec["SUBJECT"] = Subject;

 

        codec["VERSION"] = "112.0";

 

        return codec.Encode();

    }

I was successfully able to submit my PayPal Express Checkout payment!

Therefore, as a word to the wise, the PayPal Integration Wizard is outdated and defective.  However, by simply changing the version number in your resultant source code, you should be able to have a workable solution.  

No comments:

Post a Comment