Skip to main content

Remove Subscription

Description

Removes a subscription by id.

Endpoint

Method: DELETE
/api/v2/callbacks/subscriptions/{subscriptionId}

Sample Code

Remove Subscription Example
using Microsoft.Extensions.DependencyInjection;

internal static class RemoveSubscription
{
internal static async Task RemoveSubscriptionAsync(string subscriptionid)
{
var services = new ServiceCollection();
services.AddHttpClient("MyApiClient", client =>
{
client.BaseAddress = new Uri("http://paymentadminapistage.svea.com/api/");
});

var serviceProvider = services.BuildServiceProvider();
var httpClientFactory = serviceProvider.GetRequiredService<IHttpClientFactory>();
var httpClient = httpClientFactory.CreateClient("MyApiClient");

var apiUrl = string.Format("/api/v2/callbacks/subscriptions/{0}", subscriptionid);

// Add authorization header
Authentication.CreateAuthenticationToken(out string token, out string timestamp);
httpClient.DefaultRequestHeaders.Add("Authorization", token);
httpClient.DefaultRequestHeaders.Add("Timestamp", timestamp);

try
{
HttpResponseMessage response = await httpClient.DeleteAsync(apiUrl);

// Check if the request was successful
if (response.IsSuccessStatusCode)
{
string responseData = await response.Content.ReadAsStringAsync();
Console.WriteLine("Response: " + responseData);
}
else
{
Console.WriteLine("Failed to retrieve data. Status code: " + response.StatusCode);
}
}
catch (HttpRequestException ex)
{
Console.WriteLine("Error: " + ex.Message);
}
}
}

Payload parameters

ParameterDescriptionType

subscriptionId required

Subscription Id of the Merchant for Callback.GUID

Response Code

CodeHttpStatusCodeDescription
200OkWebhook URL valid and verified.
400BadRequestWebhook URL is invalid.
403ForbiddenMerchant is not authorized to retrieve information.
401UnauthorizedMerchant is not authorized to retrieve information.