可以通过 API 取消 PayPal 自动付款吗?(通过托管按钮创建的订阅)
-
25-09-2019 - |
题
可以通过 API 取消 PayPal 自动付款吗?这是通过托管按钮创建的“订阅”。
我有“自动付款号码”和“交易ID”。
解决方案
是的。
您可以使用 管理PAYPAYPROFILESTATUS API. 。您还可以重新激活悬挂轮廓。如果最大 支付失败的次数已经 但是,您需要 以增加失败的 在重新启动 概况
请找到 这 参考:
根据 PAYPAL,您可以利用 ManagerecurringPayments API 执行三种操作中的任意一种。
- 取消 - 只能取消活动状态或悬浮状态的配置文件。
- 暂停 - 只能暂停处于主动状态的概况。-
- 重新激活 - 只能重新激活悬浮状态下的轮廓。
其他提示
我发现这个线索找到解决办法之前,我想我会回来给出答案。 (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();
}
“订阅通过网站付款标准‘订阅’按钮创建的。在2009年之前,开始与S-XXXXXXXX订购简档ID。你无法通过任何API调用来管理这些订阅。2009年,用户签约信息后ID开始与I-XXXXXX,你可以取消通过ManageRecurringPaymentsProfileStatus API调用这些预订。“
有同样的问题,只是通过罗伯特读它和它的作品,你可以取消标准网站订阅使用的API。
- 取消新的 我-* 使用 PayPal ManageRecurringPaymentsProfileStatus API 进行订阅。
- 取消旧的 S-* 使用 PhantomJS + 此脚本进行订阅: http://blog. Degree.no/2015/10/cancelling-old-s-paypal-subscriptions-from-code/
我认为您无法使用 API 取消 Paypal 标准支付事件专业版的付款,而只有快速结账才可以。我尝试并收到错误消息:“定期付款 API 不支持订阅配置文件。”。您可以了解更多 这里.
不隶属于 StackOverflow