【问题标题】:Remove/Delete reusable token from world pay payment integration从世界支付支付集成中删除/删除可重复使用的令牌
【发布时间】:2020-09-13 02:58:54
【问题描述】:

我使用返回我的可重复使用令牌的 API 在世界支付中创建了订单。我正在使用这个可重复使用的令牌在未来为同一订单进行任何下一次付款。我现在想删除令牌,以便用户不能再使用它。我在下面编写了 C# 代码来创建订单并捕获可重用令牌。有人知道我如何删除可重复使用的令牌吗?

       WorldpayRestClient restClient = new WorldpayRestClient("https://api.worldpay.com/v1", "Key");

        var orderRequest = new OrderRequest()
        {
            token = token,
            amount = 200,
            //authorizedAmount=20,
            currencyCode = CurrencyCode.GBP.ToString(),
            name = "Laptop",
            orderDescription = "Laptop description",
            customerOrderCode = "ordercode_01",
        };

        var address = new Address()
        {
            address1 = "123 House Road",
            address2 = "A village",
            city = "London",
            countryCode = CountryCode.GB.ToString(),
            postalCode = "EC1 1AA"
        };

        orderRequest.billingAddress = address;

        try
        {
            OrderResponse orderResponse = restClient.GetOrderService().Create(orderRequest);

            string token = orderResponse.token;

            Console.WriteLine("Order code: " + orderResponse.orderCode);
        }
        catch (WorldpayException error)
        {
            Console.WriteLine("Error code:" + error.apiError.customCode);
            Console.WriteLine("Error description: " + error.apiError.description);
            Console.WriteLine("Error message: " + error.apiError.message);
        }

任何帮助将不胜感激。

【问题讨论】:

  • delete-tokens希望对你有帮助。
  • @Karan :我已经看到了,但我不确定如何用 C# 语言调用它。

标签: c# payment-gateway worldpay


【解决方案1】:

似乎delete token 方法不是由第三方扩展WorldpayRestClient 实现的。创建您自己的delete-token 请求,如下所示。我以xxxx 为例。请在此处设置您的实际token。同时验证url

您需要添加headers,如下所示。请在其中添加appropriate 值。 Check this for more detail about values

这是一个如何发出DELETE 网络请求的示例。

string token = "xxxxx";
string sURL = "https://api.worldpay.com/v1/tokens/" + token;

WebRequest request = WebRequest.Create(sURL);
request.Method = "DELETE";
request.Headers.Add("Authorization", "your_credentials");
request.Headers.Add("Accept", "application/vnd.worldpay.tokens-v1.hal+json");

HttpWebResponse response = (HttpWebResponse)request.GetResponse();

【讨论】:

  • 远程服务器返回错误:(401) Unauthorized
  • @Kartik 您是否将“your_credentials”替换为“base64 编码的基本身份验证用户名和密码”?
猜你喜欢
  • 2013-05-19
  • 1970-01-01
  • 2014-12-08
  • 1970-01-01
  • 1970-01-01
  • 2020-12-24
  • 1970-01-01
  • 2013-01-28
  • 1970-01-01
相关资源
最近更新 更多