bhanu
bhanu

Reputation: 218

How to integrate Paypal Api for express checkout in asp.net?

I have found this code online.

But the function paypalAAInt does not exist in the PayPal API according to the WSDL. Can anyone help me to how to integrate PayPal express checkout in Asp.Net

CustomSecurityHeaderType type = new CustomSecurityHeaderType();

type.Credentials = new UserIdPasswordType()
{
    Username = "thakur_1322207622_biz_api1.gmail.com",
    Password = "1322207646",
    Signature = "An5ns1Kso7MWUdW4ErQKJJJ4qi4-Asr3E2CXn-a5b6uZmCDTPNNvpGBl"
};

SetExpressCheckoutRequestDetailsType sdt = new SetExpressCheckoutRequestDetailsType();
sdt.NoShipping = "1";

PaymentDetailsType pdt = new PaymentDetailsType()
{
    OrderDescription = "Order for 1 year" + Request.Cookies["username"].Value,
    OrderTotal = new BasicAmountType()
    {
        currencyID = CurrencyCodeType.USD,
        Value = "95.40"
    }
};
sdt.PaymentDetails = new PaymentDetailsType[] { pdt };
sdt.CancelURL = "http://localhost:2326/MusicStore/Default.aspx";
sdt.ReturnURL = "http://localhost:2326/MusicStore/regsuccessfull.aspx";

SetExpressCheckoutReq req = new SetExpressCheckoutReq()
{
    SetExpressCheckoutRequest = new SetExpressCheckoutRequestType()
    {
        SetExpressCheckoutRequestDetails = sdt,
        Version = "60.0"
    }
};

var resp = paypalAAInt.SetExpressCheckout(ref type, req);

if (resp.Errors != null && resp.Errors.Length > 0)
{
    // errors occured
    throw new Exception("Exception(s) occured when calling PayPal. First exception: " +
            resp.Errors[0].LongMessage);
}

Response.Redirect(string.Format("{0}?cmd=_express-checkout&token={1}", 
    ConfigurationManager.AppSettings["PayPalSubmitUrl"], resp.Token));  

This is the code which I am using, but the function paypalAAInt does not exist in the PayPal API. Which function should be used instead of paypalAAInt?

Upvotes: 2

Views: 3042

Answers (1)

JP Hellemons
JP Hellemons

Reputation: 6057

The Method SetExpressCheckout is available if you have an object of PayPalAPIAAInterfaceClient and that should become available if you have added a web reference to the WSDL.

Here is your missing line:

PayPalAPIAAInterfaceClient paypalAAInt = new PayPalAPIAAInterfaceClient();

Upvotes: 1

Related Questions