我的目标是代表第三方商家将发票发送到另一个Paypal帐户。我正在使用权限服务来成功获取权限,从而产生访问令牌和关联的机密。
但是,我不理解在创建/发送发票时如何使用访问令牌和关联的机密来构建标题。
我正在使用C# .NET Invoicing SDK与Invoicing Service API进行通信。
这是我用来创建和发送发票的代码。
RequestEnvelope envelopeRequest = new RequestEnvelope();
envelopeRequest.errorLanguage = "en_GB";
List<InvoiceItemType> invoiceItemList = new List<InvoiceItemType>();
InvoiceItemType invoiceItem = new InvoiceItemType("Item", Convert.ToDecimal("2"), Convert.ToDecimal("4.00"));
invoiceItemList.Add(invoiceItem);
InvoiceItemListType itemList = new InvoiceItemListType(invoiceItemList);
InvoiceType invoice = new InvoiceType("[email protected]", "[email protected]", itemList, "USD");
CreateAndSendInvoiceRequest requestCreateAndSendInvoice = new CreateAndSendInvoiceRequest(envelopeRequest, invoice);
InvoiceService service = new InvoiceService();
responseCreateAndSendInvoice = service.CreateAndSendInvoice(requestCreateAndSendInvoice);
最佳答案
在黑暗中摸索了一段时间之后,我发现.NET Invoicing SDK负责创建标头。 InvoiceService有两种将令牌和秘密分配给标头的方法。有关详情,请参见下文。
RequestEnvelope envelopeRequest = new RequestEnvelope();
envelopeRequest.errorLanguage = "en_GB";
List<InvoiceItemType> invoiceItemList = new List<InvoiceItemType>();
InvoiceItemType invoiceItem = new InvoiceItemType("Item", Convert.ToDecimal("2"), Convert.ToDecimal("4.00"));
invoiceItemList.Add(invoiceItem);
InvoiceItemListType itemList = new InvoiceItemListType(invoiceItemList);
InvoiceType invoice = new InvoiceType("[email protected]", "[email protected]", itemList, "USD");
CreateAndSendInvoiceRequest requestCreateAndSendInvoice = new CreateAndSendInvoiceRequest(envelopeRequest, invoice);
Dictionary<string, string> list = new Dictionary<string, string>();
list.Add("mode", "sandbox");
list.Add("account1.apiUsername", "contact-facilitator_api1.testdomain.com");
list.Add("account1.apiPassword", "xxxx");
list.Add("account1.apiSignature", "xxxx--xxx");
InvoiceService service = new InvoiceService(list);
service.SetAccessToken(accessToken);
service.SetAccessTokenSecret(secret);
responseCreateAndSendInvoice = service.CreateAndSendInvoice(requestCreateAndSendInvoice);