Encontré este hilo antes de encontrar una solución, y pensé que volvería para dar la respuesta. (DO#.Solución neto)
se necesitan los siguientes paquetes NuGet:
Install-Package RestApiSDK
Install-Package PayPalCoreSDK
Install-Package PayPalMerchantSDK
Y las siguientes referencias:
using PayPal.Api;
using PayPal.PayPalAPIInterfaceService;
using PayPal.PayPalAPIInterfaceService.Model;
Aquí está el código:
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();
}
no se trata simplemente de "pagos PayPal Pro/Express"? El OP está hablando sobre el sistema de suscripción regular de PayPal. – erikcw
Funcionó para mí utilizando la identificación de suscripción como ID de perfil. – pat
No puede cancelar la suscripción anterior mediante API como se menciona en la respuesta a continuación. –