从paypal回调中检索IPP访问令牌和访问机密

时间:2014-08-24 01:05:41

标签: paypal oauth intuit-partner-platform

我有一个使用标准paypal购物车的网络应用程序。我们想要做的是当paypal通知我们的网站付款已经完成时,使用Intuit QB API在线自动记录QB中的付款。

我看到的用于获取访问令牌和秘密的示例是用户启动的。如何在paypal回调的上下文中获取这些内容?我需要它们自动发生,并且没有来自用户的Request上下文。我在这里有一些基本的测试代码,它们在paypal回调中运行。

//start a transaction
//start try block            
//set our transaction record as paid
Token = ConfigurationManager.AppSettings["appToken"];
        string consumerKey = ConfigurationManager.AppSettings["consumerKey"];
        string consumerSecret = ConfigurationManager.AppSettings["consumerSecret"];
        string companyID = ConfigurationManager.AppSettings["companyID"];
        string accessToken = "??????";
        string accessSecret = "?????";

        OAuthRequestValidator oauthValidator = new OAuthRequestValidator(accessToken, accessSecret, consumerKey, consumerSecret);
        ServiceContext context = new ServiceContext(appToken, companyID, IntuitServicesType.QBO, oauthValidator);
        DataService service = new DataService(context);
        Customer customer = new Customer();
        //just a test example. without missing tokens, i don't get here.
        customer.GivenName = "Mary";
        customer.Title = "Ms.";
        customer.MiddleName = "Jayne";
        customer.FamilyName = "Cooper";
        Customer resultCustomer = service.Add(customer) as Customer;
//complete transaction
//catch {rollback transaction}

1 个答案:

答案 0 :(得分:1)

没有自动方式从您的应用程序获取访问令牌和秘密。 您需要首次使用用户交互(C2QB-连接到Quickbooks)生成它们,然后保存它们以备将来使用。这些令牌有效期为6个月,之后您必须调用Reconnect api来续订令牌或再次进行C2QB交互以获得新令牌。 https://developer.intuit.com/docs/0025_quickbooksapi/0010_getting_started/0030_integrate_your_app/disconnecting_from_quickbooks/0050_how_to_reconnect