You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
123 lines
4.9 KiB
123 lines
4.9 KiB
using BBWY._1688SDK.entity.Order;
|
|
using BBWY.Common.Models;
|
|
using com.alibaba.openapi.client;
|
|
using com.alibaba.openapi.client.policy;
|
|
using Jd.Api;
|
|
using Jd.Api.Request;
|
|
using Jd.Api.Response;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
using System.Net.Http;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Security.Cryptography;
|
|
using System.Security.Policy;
|
|
using System.Text;
|
|
|
|
namespace BBWY.Test
|
|
{
|
|
internal class Program
|
|
{
|
|
private static IJdClient GetJdClient(string appKey, string appSecret)
|
|
{
|
|
return new DefaultJdClient("https://api.jd.com/routerjson", appKey, appSecret);
|
|
}
|
|
|
|
public static string Md5Encrypt(string originStr)
|
|
{
|
|
using (var md5 = MD5.Create())
|
|
{
|
|
return string.Join(string.Empty, md5.ComputeHash(Encoding.UTF8.GetBytes(originStr)).Select(x => x.ToString("x2")));
|
|
}
|
|
}
|
|
|
|
private static SyncAPIClient GetSyncAPIClient(string appKey, string appSecret)
|
|
{
|
|
var sercvice = new ServiceCollection();
|
|
sercvice.AddHttpClient();
|
|
var servicePriovder = sercvice.BuildServiceProvider();
|
|
return new SyncAPIClient(appKey, appSecret, new Common.Http.RestApiService(servicePriovder.GetRequiredService<IHttpClientFactory>()));
|
|
}
|
|
|
|
static void Main(string[] args)
|
|
{
|
|
|
|
//var appkey = "E1AA9247D5583A6D87449CE6AB290185";
|
|
//var appSecret = "e479558ddd9e40f8929cfc00c6cbbc9c";
|
|
|
|
var appkey = "120EA9EC65AB017567D78CC1139EEEA5";
|
|
var appSecret = "8a42bc2301e8439b896e99f5475e0a9b";
|
|
|
|
////0e61c4a8ec3e4df4b5836e10884db9220yth 齐盛
|
|
var token = "2ace3023200c4ea9aa682bbf8bffee18jztm"; //布莱特玩具
|
|
//var token = "01f5be2cb4d741dda66bce2356941597mdfm"; //布莱特玩具 token2
|
|
//var token = "01dc6f6e7fc34dcd99090d690312556cmdfk"; //齐盛
|
|
//var token = "9fffa982da23446fb035499ae5622f49odjk"; //腾奇
|
|
//var token = "c22ff4d37b6c4bbd82cd9e8d0dab42dbziyz"; //森王车品
|
|
//var token = "44c19a1c1fbd4641957e6e8985ed1358jmtl"; //森王玩具
|
|
//var token = "4a0ddc095e054c7aa90adcaccb14f83cwzgr"; //可比车品
|
|
//var token = "50a4c0f5c55848b5a8a715709e8d6fe0jntb"; //卿卿玩具专营店
|
|
|
|
|
|
{
|
|
var request = new { AppKey = "1074007", AppSecret = "0r9u4Fc9zK", AppToken = "8093fdc5-6adc-46c7-b640-87218c1dcccd" };
|
|
var client = GetSyncAPIClient(request.AppKey, request.AppSecret);
|
|
RequestPolicy reqPolicy = new RequestPolicy();
|
|
reqPolicy.HttpMethod = "POST";
|
|
reqPolicy.NeedAuthorization = false;
|
|
reqPolicy.RequestSendTimestamp = false;
|
|
reqPolicy.UseHttps = false;
|
|
reqPolicy.UseSignture = true;
|
|
reqPolicy.AccessPrivateApi = false;
|
|
|
|
Request _request = new Request();
|
|
APIId apiId = new APIId
|
|
{
|
|
Name = "alibaba.trade.pay.protocolPay.preparePay",
|
|
NamespaceValue = "com.alibaba.trade",
|
|
Version = 1
|
|
};
|
|
_request.ApiId = apiId;
|
|
|
|
//var param = new
|
|
//{
|
|
// orderId = 3494275885416167358
|
|
//};
|
|
|
|
//var param = new tradeWithholdPreparePayParam()
|
|
//{
|
|
// orderId = 3494275885416167358
|
|
//};
|
|
|
|
var param = new
|
|
{
|
|
tradeWithholdPreparePayParam = new
|
|
{
|
|
orderId = 3494275885416167358
|
|
}
|
|
};
|
|
_request.RequestEntity = param;
|
|
if (!string.IsNullOrEmpty(request.AppToken))
|
|
_request.AccessToken = request.AppToken;
|
|
var result = client.NewRequest(_request, reqPolicy);
|
|
if (result.Value<bool>("success") != true)
|
|
throw new BusinessException(result.Value<string>("message"));
|
|
|
|
Console.WriteLine(JsonConvert.SerializeObject(result));
|
|
}
|
|
|
|
Console.ReadKey();
|
|
}
|
|
|
|
static string tomMd5(string str)
|
|
{
|
|
using (var md5 = MD5.Create())
|
|
{
|
|
return string.Join(string.Empty, md5.ComputeHash(Encoding.UTF8.GetBytes(str)).Select(x => x.ToString("x2")));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|