Showing posts with label PayPal. Show all posts
Showing posts with label PayPal. Show all posts

Sunday, April 20, 2014

PayPal Express Checkout with an Optional PayPal account

If you are integrating with PayPal Express Checkout, you may want to allow your customers to be able to checkout WITHOUT having a PayPal account.

By default, PayPal Express Checkout will require a PayPal account for you to checkout.

However, if you pass the right parameters to the PayPal Payment Gateway, it will allow you to optionally checkout without having a PayPal account. 

In order to do this, you have to have the following parameters in your ASP.NET PayPal Express Checkout method:

encoder["SOLUTIONTYPE"] = "Sole";
encoder["LANDINGPAGE"] = "Billing";


If you are using the PayPal Integration Wizard, this code can be included in your paypalfunctions.cs file.


Once you have this in place, your customers will be able to optionally pay by credit card WITHOUT having a PayPal account!

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.  

Thursday, April 3, 2014

Working with the PayPal API using ASP.NET

If you need to work with the PayPal API, you have 2 choices to choose from:


  • Classic API
  • REST API
As you can probably guess, the REST API is newer and therefore the preferred method of integration.

However, if you need work with the Classic API and you need to use Express Checkout, PayPal makes it quite easy for you to integrate your code with the language of your choice using the PayPal Integration Wizard: https://devtools-paypal.com/integrationwizard/

Unfortunately, the PayPal Integration Wizard does not support code samples for integrating with ASP.NET MVC, therefore, you are stuck with ASP.NET Web Forms if you are planning on using the Wizard.

The PayPal Integration Wizard simply asks you a series of questions and then provides you with necessary integration code to include in your ASP.NET Web Forms files.  The main point to note is that you will need to create a Session variable called "payment_amt" in order to store the PayPal payment amount to submit to the PayPal site.

If you are planning on using the PayPal REST API, you can download code samples from here: https://github.com/paypal/rest-api-sdk-dotnet



From the right hand lower corner, simply click on the link to "Download ZIP".  Once you extract the .zip file, you should be able to see the "Samples" folder containing the code samples for various versions of Visual Studio up to Visual Studio 2012.

Unfortunately, as with the PayPal Integration Wizard, the code samples are provided only for ASP.NET Web Forms.

When you open the Visual Studio 2012 Solution initially in Visual Studio 2013, you will notice that the RestAPISDK reference is missing.


Fortunately, since this package is managed through NuGet, this can be easily rectified!

You can simply go to "Manage NuGet Packages" and search for "PayPal REST API SDK".  This should return the appropriate search result and allow you to install the package for  your solution.





Once the NuGet package has been updated, you should be ready to work with the PayPal REST API code samples!

Monday, February 24, 2014

You do not have permission to make this API call using PayPal

I was working with nopCommerce and attempting to checkout with PayPal, when I received the following error message:

You do not have permission to make this API call.

After reviewing the list of API Errors on the PayPal site (https://developer.paypal.com/docs/classic/api/errorcodes/), I could not find a solution for how to resolve this error message.

Fortunately, I came across this article which describes in detail how to configure your PayPal account: http://help.tictail.com/customer/portal/articles/1063813-paypal-error-%22you-do-not-have-permissions-to-make-this-api-call%22