Skip to content

Commit 8450227

Browse files
committed
内部转换沙箱链接
1 parent 1fd8568 commit 8450227

File tree

6 files changed

+38
-14
lines changed

6 files changed

+38
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# Changelog## 2.1.1 - 2025-07-09- update 0709## 2.1.0 - 2025-04-10* [#14](https://github.com/alipay/global-open-sdk-dotnet/pull/13) feature-250410 - Antom 印度渠道接入AMS拒付相关接口的标准变更 - Antom印度渠道接入(UPI/CARD/NETBAKING)相关接口标准变更 - CKP二期支持商户传入支付方式地区和支付方式要素## 2.0.9 - 2025-02-05* [#13](https://github.com/alipay/global-open-sdk-dotnet/pull/13) feature-250205 - 支付、查询、支付结果通知新增卡相关信息字段## 2.0.8 - 2025-01-22* [#12](https://github.com/alipay/global-open-sdk-dotnet/pull/12) feature-250122 - update promotionResults## 2.0.7 - 2025-01-06* [#11](https://github.com/alipay/global-open-sdk-dotnet/pull/11) feature-250106 - 订阅支付新增“更新接口”## 2.0.6 - 2024-12-24* [#11](https://github.com/alipay/global-open-sdk-dotnet/pull/10) feature-241224 - CKP二期支持商户传入可选支付方式列表 - AMS独立绑卡支持MIT交易## 2.0.5 - 2024-12-16* [#10](https://github.com/alipay/global-open-sdk-dotnet/pull/10) feature-241216 - RDR拒付通知优化通用能力变更 - Antom新增ApplePay支付方式## 2.0.4 - 2024-12-02* [#9](https://github.com/alipay/global-open-sdk-dotnet/pull/9) feature-241202 - update AlipayDisputeNotify - update AlipayPayQueryResponse## 2.0.3 - 2024-11-25* [#8](https://github.com/alipay/global-open-sdk-dotnet/pull/8) feature-241125 - update AlipayPayResultNotify - update AlipayPayQueryRequest## 2.0.3 - 2024-11-25* [#7](https://github.com/alipay/global-open-sdk-dotnet/pull/7) feature-241125 - update Leg## 2.0.2 - 2024-11-04* [#6](https://github.com/alipay/global-open-sdk-dotnet/pull/6) feature-notify - add notify## 2.0.1 - 2024-10-23 * [#5](https://github.com/alipay/global-open-sdk-dotnet/pull/5) feature-p2 - add MARKETPLACE - add vaulting - add Dispute - add risk - add Notify - add MARKETPLACE_demo - add subscription_demo - add vaulting_demo - add Dispute_demo## 2.0.0 - 2024-09-04* [#4](https://github.com/alipay/global-open-sdk-dotnet/pull/4) Init object library * Add pay - request response * Add auth - request response * Add customs - request response * Add subscription - request response * Add example - auth customs pay * Add Changelog## 1.0.0 - 2021-08-02* Init object library
1+
# Changelog## 2.1.2 - 2025-09-2- 内部转换沙箱链接## 2.1.1 - 2025-07-09- update 0709## 2.1.0 - 2025-04-10* [#14](https://github.com/alipay/global-open-sdk-dotnet/pull/13) feature-250410 - Antom 印度渠道接入AMS拒付相关接口的标准变更 - Antom印度渠道接入(UPI/CARD/NETBAKING)相关接口标准变更 - CKP二期支持商户传入支付方式地区和支付方式要素## 2.0.9 - 2025-02-05* [#13](https://github.com/alipay/global-open-sdk-dotnet/pull/13) feature-250205 - 支付、查询、支付结果通知新增卡相关信息字段## 2.0.8 - 2025-01-22* [#12](https://github.com/alipay/global-open-sdk-dotnet/pull/12) feature-250122 - update promotionResults## 2.0.7 - 2025-01-06* [#11](https://github.com/alipay/global-open-sdk-dotnet/pull/11) feature-250106 - 订阅支付新增“更新接口”## 2.0.6 - 2024-12-24* [#11](https://github.com/alipay/global-open-sdk-dotnet/pull/10) feature-241224 - CKP二期支持商户传入可选支付方式列表 - AMS独立绑卡支持MIT交易## 2.0.5 - 2024-12-16* [#10](https://github.com/alipay/global-open-sdk-dotnet/pull/10) feature-241216 - RDR拒付通知优化通用能力变更 - Antom新增ApplePay支付方式## 2.0.4 - 2024-12-02* [#9](https://github.com/alipay/global-open-sdk-dotnet/pull/9) feature-241202 - update AlipayDisputeNotify - update AlipayPayQueryResponse## 2.0.3 - 2024-11-25* [#8](https://github.com/alipay/global-open-sdk-dotnet/pull/8) feature-241125 - update AlipayPayResultNotify - update AlipayPayQueryRequest## 2.0.3 - 2024-11-25* [#7](https://github.com/alipay/global-open-sdk-dotnet/pull/7) feature-241125 - update Leg## 2.0.2 - 2024-11-04* [#6](https://github.com/alipay/global-open-sdk-dotnet/pull/6) feature-notify - add notify## 2.0.1 - 2024-10-23 * [#5](https://github.com/alipay/global-open-sdk-dotnet/pull/5) feature-p2 - add MARKETPLACE - add vaulting - add Dispute - add risk - add Notify - add MARKETPLACE_demo - add subscription_demo - add vaulting_demo - add Dispute_demo## 2.0.0 - 2024-09-04* [#4](https://github.com/alipay/global-open-sdk-dotnet/pull/4) Init object library * Add pay - request response * Add auth - request response * Add customs - request response * Add subscription - request response * Add example - auth customs pay * Add Changelog## 1.0.0 - 2021-08-02* Init object library

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Alipay AMS(Alipay Merchant Services) C# Bindings
22
```
33
Language:C#
4-
Releass ^2.1.1
4+
Releass ^2.1.2
55
Copyright:Ant financial services group
66
```
77

8-
## Documentation
9-
8+
`## Documentation
9+
`
1010
Please see the [API docs](https://global.alipay.com/docs/) for the most up-to-date documentation.
1111

1212
## Usage

ams-dotnet/ams-dotnet.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<PropertyGroup>
55
<PackageId>global-open-sdk-dotnet</PackageId>
6-
<Version>2.1.1</Version>
6+
<Version>2.1.2</Version>
77
<Authors>wangzunjiao</Authors>
88
<Company>antom</Company>
99
<OutputType>Exe</OutputType>

ams-dotnet/src/com/alipay/ams/api/DefaultAlipayClient.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Net.Http;
33
using System.Text;
4+
using System.Text.RegularExpressions;
45
using com.alipay.ams.api.response;
56

67
namespace com.alipay.ams.api
@@ -32,8 +33,9 @@ public DefaultAlipayClient(
3233
public TAMSResponse Execute<TAMSResponse>(request.AMSRequest<TAMSResponse> request)
3334
where TAMSResponse : AMSResponse
3435
{
35-
36-
var requestMessage = new System.Net.Http.HttpRequestMessage(System.Net.Http.HttpMethod.Post, this.GatewayUrl+ request.GetRequestURI());
36+
var requestUrl = BuildRequestUrl(request.GetRequestURI());
37+
38+
var requestMessage = new System.Net.Http.HttpRequestMessage(System.Net.Http.HttpMethod.Post, requestUrl );
3739

3840
var body = request.BuildBody();
3941
var headers = request.BuildRequestHeader(this.ClientId,this.AgentToken,this.MerchantPrivateKey);
@@ -52,5 +54,18 @@ public TAMSResponse Execute<TAMSResponse>(request.AMSRequest<TAMSResponse> requ
5254

5355
return AMSResponse.ParseResponse<TAMSResponse>(ret, request.GetRequestURI(), this.ClientId,this.AlipayPublicKey);
5456
}
57+
58+
public string BuildRequestUrl(string originPath)
59+
{
60+
61+
if (ClientId != null && ClientId.StartsWith("SANDBOX_", StringComparison.Ordinal))
62+
{
63+
originPath = originPath.Replace("/ams/api", "/ams/sandbox/api");
64+
}
65+
66+
var baseUri = new Uri(this.GatewayUrl, UriKind.Absolute);
67+
var fullUri = new Uri(baseUri, originPath);
68+
return fullUri.ToString();
69+
}
5570
}
5671
}

ams-dotnet/src/com/alipay/ams/api/request/AMSRequest.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public Dictionary<string, string> BuildRequestHeader(string clientId, string age
2626

2727
var requestTime = DateTime.UtcNow.ToString("o");
2828
headers.Add("client-id", clientId);
29-
headers.Add("signature", "algorithm=RSA256,keyVersion=1,signature=" + SignatureUtil.sign(GetRequestURI(), clientId, requestTime, privateKey, BuildBody()));
29+
headers.Add("signature", "algorithm=RSA256,keyVersion=1,signature=" + SignatureUtil.sign(BuildRequestUrl(clientId,GetRequestURI()), clientId, requestTime, privateKey, BuildBody()));
3030

3131
if(agentToken != null)
3232
{
@@ -58,6 +58,17 @@ public override string ToString()
5858
{
5959
return JsonSerializer.Serialize(this, this.GetType(), JsonSerializerOptionsFactory.WriteIndented);
6060
}
61+
62+
public string BuildRequestUrl(string clientId,string originPath)
63+
{
64+
65+
if (clientId != null && clientId.StartsWith("SANDBOX_", StringComparison.Ordinal))
66+
{
67+
originPath = originPath.Replace("/ams/api", "/ams/sandbox/api");
68+
}
69+
70+
return originPath;
71+
}
6172
}
6273

6374

ams-dotnet/src/example/Program.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@ namespace ams_dotnet
88
class Program
99
{
1010

11-
private const string GatewayUrl = "https://open-na-global.alipay.com";
12-
private const string ClientId = "SANDBOX_5YES502ZS7KG03623";
11+
private const string GatewayUrl = "";
12+
private const string ClientId = "";
1313

1414
// Below are fake keys that are for demo purpose. Replace them with your own ones.
15-
private const string MerchantPrivateKey = "MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQC9tC4d3Wnf65KfcyjKXfbPUwO/OT6p4VhRaY8VxETG7WWAVWPYwECPNprsK/Waoce2ItVHzWzy/+3avs0jOkUudXH9CoDqDX/DqGAPbW3MdFU1+aVfkO96rC/Dyfqm6m0+WgqKXCIC1ohxKuYC+0n6nDBTwbfuoUTCXtWA9jxvmfkWJ2jJSQKegePdXX1t0GrGMEzAoAMur0/k/pu6ys9cCRMa90A5yr3rMQNdeE/5u97Qpn8oQYfWkYF73vK8lUx4cNlaQUBvNue5HNcdNV5Cx40+RNj7W3KfqmAIKV3PWYwrwvuJOXkVdP4h/vch4rHFTSovclnTJmlpnVdPe7qRAgMBAAECggEABeBE5WvsUaFMY1//zXTnpjheD1hIlp6CS9NHOVdhAgBsenMqqpYZ6dW5KsOZ0fZc50lg7d5xF33R8kqitAqkBfJhW4MtxxIv+PGIODIdio237foTo0gsAtK+kAP7nZv5UksbtHlyHEBk7Yx0n3cFLZwU6yM+/UdFh/fECUCXUqWWnq39Ub8onxK5KGN4tQDxV9lZQtlAd8ecbQ1yC8sYNtNCLQD+IcGuPooqEXb6bIq1yFdXKItrWr0zt/UAn2Q3CqbFZPnQgxm2k9lrKLhwEtkSF3MuKLZ2v/6AO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Y1C/PBU0/LruObAp7fOTDiIdkL44h4q71pw1sPOLb7bPLXtAhlzWRyGxV7IDDPkXpXC14BBAtPJUK0ICMDPyMJBNI6qUq5jK33N67XcnlnPQQETbb3pwBqgvK7u00RBZPGpyo2HW+n0hRHN/kd9E/M6UO3H0RoJsEa9o14QPVQOdILopL7eXr/6Y7BHoz78itpSozn7jFi+tc+iYxrJLUKIcrIdOVMx72kNcpBEMoaMl74gFlOwKFAUUM0cL7Lc4wIDAQAB";
18-
15+
private const string MerchantPrivateKey = "";
16+
private const string AlipayPublicKey = "";
1917

2018

2119
static void Main(string[] args)

0 commit comments

Comments
 (0)