c# - 使用 Paypal API/SDK,我将如何检查某个订阅 ID? C#

标签 c# winforms paypal

好的,所以我下载了 Paypal 的 SDK/API,我需要一些帮助。

我正在尝试检查某个订阅 ID,但我似乎无法弄清楚如何。

当用户启动应用程序时,我想检查订阅 ID,如果它不是事件的或未付费的,那么它将显示一条错误消息,说明错误。如果它处于事件状态,那么它将正常启动。

有人可以为此发布一个 C# 示例吗?我搜索了所有的谷歌,却找不到任何东西:)

最佳答案

您可以检查 Paypal Official Docs

它没有专门用 C# 编码,因此可以用多种语言编码(而不是仅限于一种)

您还可以查看 Github 上的 C# 示例

我创建了一些示例代码,使用 InvoiceSend.aspx.cs/InvoiceCreate.aspx.cs :

                    var config = ConfigManager.Instance.GetProperties();
                    config.Add("mode", "live");
                    config.Add("clientId", "get_your_id_from_sandbox");
                    config.Add("clientSecret", "get_your_secret_from_sandbox");

                    var accessToken = new OAuthTokenCredential(config).GetAccessToken();

                    var apiContext = new APIContext(accessToken);

                    apiContext.Config = config;

                    // ### Create an invoice
                    // For demonstration purposes, we will create a new invoice for this sample.
                    var invoice = new Invoice()
                    {
                        // #### Merchant Information
                        // Information about the merchant who is sending the invoice.
                        merchant_info = new MerchantInfo()
                        {
                            email = "example@example.com",
                            first_name = "Carl",
                            last_name = "Smithy",
                            business_name = "Buddy Business Inc.",
                            phone = new Phone()
                            {
                                country_code = "001",
                                national_number = "1234567890"
                            },
                            address = new InvoiceAddress()
                            {
                                line1 = "1234 Main St.",
                                city = "Chicago",
                                state = "IL",
                                postal_code = "54321",
                                country_code = "001"
                            }
                        },
                        // #### Billing Information
                        // Email address of invoice recipient and optional billing information.
                        // > Note: PayPal currently only allows one recipient.
                        billing_info = new List<BillingInfo>()
                {
                    new BillingInfo()
                    {
                        // **(Required)** Email address of the invoice recipient.
                        email = "example@example.com",
                    }
                },
                        // #### Invoice Items
                        // List of items to be included in the invoice.
                        // > Note: 100 max per invoice.
                        items = new List<InvoiceItem>()
                {
                    new InvoiceItem()
                    {
                        name = "Item Name",
                        quantity = 1,
                        unit_price = new Currency()
                        {
                            currency = "USD",
                            value = "6.99" // The Price
                        }
                    }
                },
                        // #### Invoice Note
                        // Note to the payer. Maximum length is 4000 characters.
                        note = "Payment for <Your Item Here>",
                        // #### Payment Term
                        // **(Optional)** Specifies the payment deadline for the invoice.
                        // > Note: Either `term_type` or `due_date` can be sent, **but not both.**
                        payment_term = new PaymentTerm()
                        {
                            term_type = "NET_30"
                        },
                        // #### Shipping Information
                        // Shipping information for entities to whom items are being shipped.
                        shipping_info = new ShippingInfo()
                        {
                            first_name = "john",
                            last_name = "smith",
                            business_name = "Not applicable",
                            address = new InvoiceAddress()
                            {
                                line1 = "1234 Main St.",
                                city = "New York City",
                                state = "New York",
                                postal_code = "12345",
                                country_code = "001",
                            }
                        }
                    };

                    var createInvoice = invoice.Create(apiContext);

                    createInvoice.Send(apiContext);
                }

以编程方式通过 Paypal 发送发票!

您需要包含 namespace Paypal.ApiPaypal
您可以从 Nuget 下载 Paypal SDK

很高兴为您服务:)

关于c# - 使用 Paypal API/SDK,我将如何检查某个订阅 ID? C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59258263/

相关文章:

paypal - 是否可以使用 PayPal 接受 EMI/分期付款?

paypal - SetExpressCheckout 和 DoExpressCheckout 支付一步到位 : best practices?

c# - DependencyProperty ValidateValueCallback 问题

c# - 以编程方式访问 GridView 列并进行操作

c# - 调整窗口或容器大小时如何修复滚动条?

c# - 检查非打字间隔

winforms - 具有新的 Office High DPI 支持的 Outlook VSTO

php - Laravel 5 和 Paypal 结帐

c# - ASP.NET 4.6 异步 Controller 方法在等待后丢失 HttpContext.Current

c# - 如何使用我的项目部署数据库?