Skip to content

Commit c5311ec

Browse files
committed
新增isv agenttoken
1 parent 710a528 commit c5311ec

File tree

10 files changed

+292
-10
lines changed

10 files changed

+292
-10
lines changed

CHANGELOG.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,36 @@
11
# Changelog
22

3-
## 1.4.7 - 2024-07-28
3+
4+
## 1.4.7 - 2025-09-24
5+
- 新增isv模式 agent-token参数
6+
- 补充已知字段
7+
8+
## 1.4.7 - 2025-07-28
49
- 修改已知问题
510

6-
## 1.4.6 - 2024-07-10
11+
## 1.4.6 - 2025-07-10
712
- update 0710
813

9-
## 1.4.5 - 2024-04-10
14+
## 1.4.5 - 2025-04-10
1015
- pay/createPaymentSession支付接口支持订阅支付能力
1116

1217

13-
## 1.4.4 - 2024-04-10
18+
## 1.4.4 - 2025-04-10
1419
* [#28](https://github.com/alipay/global-open-sdk-python/pull/28) feature-250410
1520
- Antom 印度渠道接入AMS拒付相关接口的标准变更
1621
- Antom印度渠道接入(UPI/CARD/NETBAKING)相关接口标准变更
1722
- CKP二期支持商户传入支付方式地区和支付方式要素
1823

1924

20-
## 1.4.3 - 2024-02-05
25+
## 1.4.3 - 2025-02-05
2126
* [#27](https://github.com/alipay/global-open-sdk-python/pull/27) feature-250205
2227
- 支付、查询、支付结果通知新增卡相关信息字段
2328

24-
## 1.4.2 - 2024-01-22
29+
## 1.4.2 - 2025-01-22
2530
* [#26](https://github.com/alipay/global-open-sdk-python/pull/26) feature-250122
2631
- update promotionResults
2732

28-
## 1.4.1 - 2024-01-06
33+
## 1.4.1 - 2025-01-06
2934
* [#25](https://github.com/alipay/global-open-sdk-python/pull/25) feature-250105
3035
- 订阅支付新增“更新接口”
3136

com/alipay/ams/api/default_alipay_client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88

99
class DefaultAlipayClient(object):
1010

11-
def __init__(self, gateway_url, client_id, merchant_private_key, alipay_public_key):
11+
def __init__(self, gateway_url, client_id, merchant_private_key, alipay_public_key,agent_token = None):
1212
self.__gateway_url = gateway_url
1313
self.__client_id = client_id
1414
self.__merchant_private_key = merchant_private_key
1515
self.__alipay_public_key = alipay_public_key
1616
self.__is_sandbox_mode = client_id.startswith("SANDBOX_")
17+
self.__agent_token = agent_token
1718

1819
"""
1920
内部方法,生成请求签名
@@ -88,8 +89,11 @@ def execute(self, request):
8889
"User-Agent": "global-alipay-sdk-python",
8990
"Request-Time": req_time,
9091
"client-id": client_id,
91-
"Signature": signature
92+
"Signature": signature,
9293
}
94+
if self.__agent_token:
95+
headers["Agent-Token"] = self.__agent_token
96+
9397

9498
url = self.__gateway_url + path
9599
headers, response = do_post(url, headers, req_body)

com/alipay/ams/api/model/acquirer_info.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ def __init__(self):
1010
self.__acquirer_merchant_id = None
1111
self.__acquirer_result_code = None
1212
self.__acquirer_result_message = None
13+
self.__acquirer_merchant_name = None
1314

1415
@property
1516
def acquirer_name(self):
@@ -59,6 +60,15 @@ def acquirer_result_message(self):
5960
def acquirer_result_message(self, acquirer_result_message):
6061
self.__acquirer_result_message = acquirer_result_message
6162

63+
@property
64+
def acquirer_merchant_name(self):
65+
return self.__acquirer_merchant_name
66+
67+
68+
@acquirer_merchant_name.setter
69+
def acquirer_merchant_name(self, acquirer_merchant_name):
70+
self.__acquirer_merchant_name = acquirer_merchant_name
71+
6272
def parse_rsp_body(self, result_body):
6373
if type(result_body) == str:
6474
payment_result_info_body = json.loads(result_body)
@@ -81,6 +91,9 @@ def parse_rsp_body(self, result_body):
8191
if 'acquirerResultMessage' in result_body:
8292
self.__acquirer_result_message = result_body['acquirerResultMessage']
8393

94+
if 'acquirerMerchantName' in result_body:
95+
self.__acquirer_merchant_name = result_body['acquirerMerchantName']
96+
8497

8598

8699

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from enum import Enum, unique
2+
3+
4+
@unique
5+
class CredentialType(Enum):
6+
NETWORK_TOKEN = "NETWORK_TOKEN"
7+
PAN = "PAN"
8+
9+
def to_ams_dict(self):
10+
return self.name
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import json
2+
3+
4+
class MpiData(object):
5+
6+
def __init__(self):
7+
self.__three_ds_version = None
8+
self.eci = None
9+
self.cavv = None
10+
self.ds_transaction_id = None
11+
self.credential_type = None
12+
13+
@property
14+
def three_ds_version(self):
15+
return self.__three_ds_version
16+
17+
@three_ds_version.setter
18+
def three_ds_version(self, value):
19+
self.__three_ds_version = value
20+
21+
22+
@property
23+
def eci(self):
24+
return self.__eci
25+
26+
@eci.setter
27+
def eci(self, value):
28+
self.__eci = value
29+
30+
31+
@property
32+
def cavv(self):
33+
return self.__cavv
34+
35+
@cavv.setter
36+
def cavv(self, value):
37+
self.__cavv = value
38+
39+
40+
@property
41+
def ds_transaction_id(self):
42+
return self.__ds_transaction_id
43+
44+
@ds_transaction_id.setter
45+
def ds_transaction_id(self, value):
46+
self.__ds_transaction_id = value
47+
48+
@property
49+
def credential_type(self):
50+
return self.__credential_type
51+
52+
@credential_type.setter
53+
def credential_type(self, value):
54+
self.__credential_type = value
55+
56+
57+
def to_ams_dict(self):
58+
ams_dict = {}
59+
if self.three_ds_version:
60+
ams_dict['threeDSVersion'] = self.three_ds_version
61+
if self.eci:
62+
ams_dict['eci'] = self.eci
63+
if self.cavv:
64+
ams_dict['cavv'] = self.cavv
65+
if self.ds_transaction_id:
66+
ams_dict['dsTransactionId'] = self.ds_transaction_id
67+
if self.credential_type:
68+
ams_dict['credentialType'] = self.credential_type
69+
return ams_dict
70+
71+
72+
def parse_rsp_body(self, response_body):
73+
if type(response_body) == str:
74+
response_body = json.loads(response_body)
75+
if 'threeDSVersion' in response_body:
76+
self.three_ds_version = response_body['threeDSVersion']
77+
if 'eci' in response_body:
78+
self.eci = response_body['eci']
79+
if 'cavv' in response_body:
80+
self.cavv = response_body['cavv']
81+
if 'dsTransactionId' in response_body:
82+
self.ds_transaction_id = response_body['dsTransactionId']
83+
if 'credentialType' in response_body:
84+
self.credential_type = response_body['credentialType']
85+

com/alipay/ams/api/model/payment_method.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# -*- coding: utf-8 -*-
33
import json
44

5+
from com.alipay.ams.api.model.funding_type import FundingType
6+
57

68
class PaymentMethod(object):
79
def __init__(self):
@@ -10,6 +12,8 @@ def __init__(self):
1012
self.__payment_method_meta_data = None #type: map
1113
self.__customer_id = None
1214
self.__extend_info = None
15+
self.__require_issuer_authentication = None #type: bool
16+
self.funding = None #type: FundingType
1317

1418
@property
1519
def payment_method_type(self):
@@ -51,6 +55,21 @@ def extend_info(self):
5155
def extend_info(self, value):
5256
self.__extend_info = value
5357

58+
@property
59+
def require_issuer_authentication(self):
60+
return self.__require_issuer_authentication
61+
@require_issuer_authentication.setter
62+
def require_issuer_authentication(self, value):
63+
self.__require_issuer_authentication = value
64+
65+
@property
66+
def funding(self):
67+
return self.__funding
68+
69+
@funding.setter
70+
def funding(self, value):
71+
self.__funding = value
72+
5473
def to_ams_dict(self):
5574
params = dict()
5675
if hasattr(self, "payment_method_type") and self.payment_method_type:
@@ -68,6 +87,12 @@ def to_ams_dict(self):
6887
if hasattr(self, "extend_info") and self.extend_info:
6988
params['extendInfo'] = self.extend_info
7089

90+
if hasattr(self, "require_issuer_authentication") and self.require_issuer_authentication:
91+
params['requireIssuerAuthentication'] = self.require_issuer_authentication
92+
93+
if hasattr(self, "funding") and self.funding:
94+
params['funding'] = self.funding
95+
7196
return params
7297

7398
def parse_rsp_body(self, response_body):
@@ -83,4 +108,8 @@ def parse_rsp_body(self, response_body):
83108
if 'paymentMethodId' in response_body:
84109
self.payment_method_id = response_body['paymentMethodId']
85110
if 'extendInfo' in response_body:
86-
self.extend_info = response_body['extendInfo']
111+
self.extend_info = response_body['extendInfo']
112+
if 'requireIssuerAuthentication' in response_body:
113+
self.require_issuer_authentication = response_body['requireIssuerAuthentication']
114+
if 'funding' in response_body:
115+
self.funding = response_body['funding']

com/alipay/ams/api/model/payment_result_info.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import json
22

3+
from com.alipay.ams.api.model.acquirer_info import AcquirerInfo
4+
from com.alipay.ams.api.model.three_ds_result import ThreeDSResult
5+
36

47
class PaymentResultInfo(object):
58

@@ -20,6 +23,11 @@ def __init__(self):
2023
self.__last_four = None
2124
self.__expiry_month = None
2225
self.__expiry_year = None
26+
self.__account_no = None
27+
self.__refusal_code_raw = None
28+
self.__refusal_reason_raw = None
29+
self.__merchant_advice_code = None
30+
self.__acquirer_info = None #type: AcquirerInfo
2331

2432

2533
@property
@@ -150,6 +158,50 @@ def expiry_year(self):
150158
def expiry_year(self, value):
151159
self.__expiry_year = value
152160

161+
162+
@property
163+
def account_no(self):
164+
return self.__account_no
165+
166+
@account_no.setter
167+
def account_no(self, value):
168+
self.__account_no = value
169+
170+
@property
171+
def refusal_code_raw(self):
172+
return self.__refusal_code_raw
173+
174+
@refusal_code_raw.setter
175+
def refusal_code_raw(self, value):
176+
self.__refusal_code_raw = value
177+
178+
179+
@property
180+
def refusal_reason_raw(self):
181+
return self.__refusal_reason_raw
182+
183+
@refusal_reason_raw.setter
184+
def refusal_reason_raw(self, value):
185+
self.__refusal_reason_raw = value
186+
187+
@property
188+
def merchant_advice_code(self):
189+
return self.__merchant_advice_code
190+
191+
@merchant_advice_code.setter
192+
def merchant_advice_code(self, value):
193+
self.__merchant_advice_code = value
194+
195+
@property
196+
def acquirer_info(self):
197+
return self.__acquirer_info
198+
199+
@acquirer_info.setter
200+
def acquirer_info(self, value):
201+
self.__acquirer_info = value
202+
203+
204+
153205
def to_ams_dict(self):
154206
param = dict()
155207
if hasattr(self, 'avs_result_raw') and self.avs_result_raw:
@@ -184,6 +236,16 @@ def to_ams_dict(self):
184236
param['expiryMonth'] = self.expiry_month
185237
if hasattr(self, 'expiry_year') and self.expiry_year:
186238
param['expiryYear'] = self.expiry_year
239+
if hasattr(self, 'account_no') and self.account_no:
240+
param['accountNo'] = self.account_no
241+
if hasattr(self, 'refusal_code_raw') and self.refusal_code_raw:
242+
param['refusalCodeRaw'] = self.refusal_code_raw
243+
if hasattr(self, 'refusal_reason_raw') and self.refusal_reason_raw:
244+
param['refusalReasonRaw'] = self.refusal_reason_raw
245+
if hasattr(self, 'merchant_advice_code') and self.merchant_advice_code:
246+
param['merchantAdviceCode'] = self.merchant_advice_code
247+
if hasattr(self, 'acquirer_info') and self.acquirer_info:
248+
param['acquirerInfo'] = self.acquirer_info
187249

188250
return param
189251

@@ -223,3 +285,13 @@ def parse_rsp_body(self, payment_result_info_body):
223285
self.expiry_month = payment_result_info_body['expiryMonth']
224286
if 'expiryYear' in payment_result_info_body:
225287
self.expiry_year = payment_result_info_body['expiryYear']
288+
if 'accountNo' in payment_result_info_body:
289+
self.account_no = payment_result_info_body['accountNo']
290+
if 'refusalCodeRaw' in payment_result_info_body:
291+
self.refusal_code_raw = payment_result_info_body['refusalCodeRaw']
292+
if 'refusalReasonRaw' in payment_result_info_body:
293+
self.refusal_reason_raw = payment_result_info_body['refusalReasonRaw']
294+
if 'merchantAdviceCode' in payment_result_info_body:
295+
self.merchant_advice_code = payment_result_info_body['merchantAdviceCode']
296+
if 'acquirerInfo' in payment_result_info_body:
297+
self.acquirer_info = payment_result_info_body['acquirerInfo']

0 commit comments

Comments
 (0)