【问题标题】:Can you cancel a PayPal automatic payment via API? (Subscription created via Hosted button)您可以通过 API 取消 PayPal 自动付款吗? (通过托管按钮创建的订阅)
【发布时间】:2011-04-18 02:21:42
【问题描述】:

您可以通过 API 取消 PayPal 自动付款吗?这是通过托管按钮创建的“订阅”。

我有“自动付款号码”和“交易 ID”。

【问题讨论】:

    标签: paypal paypal-subscriptions


    【解决方案1】:

    是的。

    您可以通过以下方式暂停或取消个人资料 使用 管理RecurringPaymentsProfileStatus API。您也可以重新激活一个 暂停的个人资料。如果最大 支付失败的次数已经 已达到,但是,您将需要 增加失败次数 在重新激活之前付款 个人资料。

    请找this参考:

    根据 PAYPAL,您可以使用 ManagerecurringPayments API 执行三个操作中的任何一个。

    • 取消 - 仅配置文件处于活动状态或 可以取消暂停状态。
    • 暂停 - 仅配置文件处于活动状态 状态可以暂停。-
    • 重新激活 - 仅配置文件在 暂停状态可以重新激活。--

    【讨论】:

    • 这不只是用于“Paypal Pro/Express 付款”吗? OP 正在谈论常规的贝宝订阅系统。
    • 您无法使用 API 取消旧订阅,如下面的答案所述。
    • 您可以取消“旧”订阅,您无法使用 API 查看“旧”订阅的详细信息。
    【解决方案2】:

    我在找到解决方案之前找到了这个帖子,并认为我会回来给出答案。 (C#.Net 解决方案)

    您将需要以下 nuget 包:

    Install-Package RestApiSDK
    Install-Package PayPalCoreSDK
    Install-Package PayPalMerchantSDK
    

    以及以下参考资料:

    using PayPal.Api;
    using PayPal.PayPalAPIInterfaceService;
    using PayPal.PayPalAPIInterfaceService.Model;
    

    代码如下:

    public static void CancelRecurringPayment(string ProfileID)
    {
        ManageRecurringPaymentsProfileStatusRequestType request =
            new ManageRecurringPaymentsProfileStatusRequestType();
        ManageRecurringPaymentsProfileStatusRequestDetailsType details =
            new ManageRecurringPaymentsProfileStatusRequestDetailsType();
        request.ManageRecurringPaymentsProfileStatusRequestDetails = details;
    
        details.ProfileID = ProfileID;
    
        details.Action = StatusChangeActionType.CANCEL;
    
        // Invoke the API
        ManageRecurringPaymentsProfileStatusReq wrapper = new ManageRecurringPaymentsProfileStatusReq();
        wrapper.ManageRecurringPaymentsProfileStatusRequest = request;
    
        Dictionary<string, string> configurationMap = new Dictionary<string, string>();
    
        configurationMap.Add("mode", "live");
        // Signature Credential
        configurationMap.Add("account1.apiUsername", "APIUSERNAME");
        configurationMap.Add("account1.apiPassword", "APIPASSWORD");
        configurationMap.Add("account1.apiSignature", "APISIGNATURE");
    
        // Create the PayPalAPIInterfaceServiceService service object to make the API call
        PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap);
    
        ManageRecurringPaymentsProfileStatusResponseType manageProfileStatusResponse =
                    service.ManageRecurringPaymentsProfileStatus(wrapper);
    
        // Check for API return status
    
        Dictionary<string, string> responseParams = new Dictionary<string, string>();
        responseParams.Add("API Status", manageProfileStatusResponse.Ack.ToString());
    
        if (manageProfileStatusResponse.Ack.Equals(AckCodeType.FAILURE) || (manageProfileStatusResponse.Errors != null && manageProfileStatusResponse.Errors.Count > 0))
        { 
            //FAILURE
            Console.WriteLine(manageProfileStatusResponse.Errors.ToString());
        }
        else
        {
            //SUCCESS
            Console.Write("Success!");
        }
        Console.WriteLine();
    }
    

    【讨论】:

    • 您的代码非常棒,而且切中要害。它帮助我解决了我的问题。谢谢。
    【解决方案3】:

    “订阅是通过网站支付标准“订阅”按钮创建的。在 2009 年之前,订阅配置文件 ID 以 S-XXXXXXXX 开头。您无法通过任何 API 调用管理这些订阅。2009 年之后,订阅配置文件ID 以 I-XXXXXX 开头。您可以通过 ManageRecurringPaymentsProfileStatus API 调用取消这些订阅。"

    遇到同样的问题,通过Robert 阅读即可,您可以使用 API 取消标准网站订阅。

    【讨论】:

    • 什么有效?我有同样的问题,我无法取消 S- 订阅。
    • 是的,您将无法使用 API 取消“S”前缀订阅。
    • 如何创建带有 I- 前缀的订阅?
    • 您现在使用 API 或 Paypal 页面创建的任何新页面都将使用 I。S 只是旧页面。
    • 不完全正确。我有两个贝宝账户。一方面,订阅都以 S 开头——它们是不可管理的。另一方面,它们以 I- 开头,并且可以通过 API 进行管理。贝宝是癌症:/
    【解决方案4】:

    【讨论】:

      【解决方案5】:

      我认为您不能使用 API 取消使用 Paypal 标准付款事件专业版的付款,而只能使用快速结帐。我尝试并收到错误消息:“定期付款 API 不支持订阅配置文件。”。您可以了解更多here

      【讨论】:

      • 您只会在尝试检索订阅详细信息时收到此错误。 ''Any'' 订阅可以修改其状态。
      猜你喜欢
      • 2013-04-16
      • 2013-09-15
      • 2012-04-21
      • 2012-09-10
      • 2015-08-19
      • 2012-01-07
      相关资源
      最近更新 更多