可以通过 API 取消 PayPal 自动付款吗? (通过托管按钮创建的订阅)

发布于 2024-09-24 20:32:51 字数 75 浏览 5 评论 0原文

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

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

Can you cancel a PayPal automatic payment via API? It's a "Subscription" created via Hosted button.

I have the "Automatic payment number" and the "Transaction ID".

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

王权女流氓 2024-10-01 20:32:51

是的。

您可以通过以下方式暂停或取消个人资料
使用
管理定期付款配置文件状态
API。您还可以重新激活
悬浮轮廓。如果最大
付款失败次数已
已达到,但是,您将需要
增加失败的数量
重新激活之前付款
简介。


请查找参考:

根据 PAYPAL,您可以利用 ManagerecurringPayments API 执行三种操作中的任意一种。

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

Yes.

You can suspend or cancel a profile by
using the
ManageRecurringPaymentsProfileStatus
API
. You can also reactivate a
suspended profile. If the maximum
number of failed payments has already
been reached, however, you will need
to increase the number of failed
payments before reactivating the
profile.

Please find this Reference:

Accodring to PAYPAL you can take any of three actions utilizing the ManagerecurringPayments API.

  • Cancel - Only profiles in Active or
    Suspended state can be canceled.
  • Suspend - Only profiles in Active
    state can be suspended.-
  • Reactivate - Only profiles in a
    suspended state can be reactivated.--
云柯 2024-10-01 20:32:51

我在找到解决方案之前找到了这个线程,并认为我会回来给出答案。 (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();
}

I found this thread before finding a solution, and thought I'd come back to give the answer. (C#.Net Solution)

You will require the following nuget packages:

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

And the following references:

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

Here's the code:

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();
}
木緿 2024-10-01 20:32:51

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

遇到了同样的问题,刚刚阅读了 Robert 的文章,它有效,您可以取消标准网站使用 API 订阅。

"A subscription is created via a Website Payments Standard 'Subscribe' button. Before 2009, the subscription profile ID started with S-XXXXXXXX. You are not able to manage these subscriptions via any API calls. After 2009, the subscription profile ID starts with I-XXXXXX. You are able to cancel these subscriptions via the ManageRecurringPaymentsProfileStatus API call."

Was having the same problem and just read it by Robert and it works, you can cancel standard website subscription using API.

方觉久 2024-10-01 20:32:51
扬花落满肩 2024-10-01 20:32:51

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

I don't think you can use the API to cancel a payment with Paypal standard payment event pro while only express checkout will work. I tried and got the error message: "Subscription Profiles not supported by Recurring Payment APIs.". You can find out more here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文