如何在asp.net中集成Paypal Api进行快速结账?

时间:2012-04-25 07:34:03

标签: asp.net paypal-sandbox

我在网上找到this code

但根据WSDL,PayPal API中不存在函数paypalAAInt。任何人都可以帮助我如何在Asp.Net中集成PayPal快速结账

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));  

这是我正在使用的代码,但PayPal API中不存在函数paypalAAInt。应该使用哪个函数而不是paypalAAInt

1 个答案:

答案 0 :(得分:1)

如果您有SetExpressCheckout的对象,并且如果您已向WSDL添加了Web引用,则该方法PayPalAPIAAInterfaceClient可用。

这是你遗漏的一行:

PayPalAPIAAInterfaceClient paypalAAInt = new PayPalAPIAAInterfaceClient();