Skip to content

Commit 331c0c5

Browse files
authored
Merge pull request #14 from alipay/feature-add-fields-p2
Feature add fields p2
2 parents bd1b1e9 + dcfedc2 commit 331c0c5

File tree

116 files changed

+3856
-96
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+3856
-96
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
# Changelog
22

33

4+
## 1.3.3 - 2024-10-17
5+
* [#14](https://github.com/alipay/global-open-sdk-python/pull/14) update-p2
6+
* add MARKETPLACE_demo
7+
* add MARKETPLACE
8+
* add vaulting
9+
* add Dispute
10+
* add risk
11+
* and add example
12+
* add Notify
13+
414
## 1.3.2 - 2024-09-04
515
* [#13](https://github.com/alipay/global-open-sdk-python/pull/13) add:ScopeType add TAOBAO_REBIND
616
* Add TAOBAO_REBIND

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ Copyright:Ant financial services group
99
default_alipay_client = DefaultAlipayClient("https://open-na.alipay.com", client_id, MERCHANT_PRIVATE_KEY, ALIPAY_PUBLIC_KEY)
1010
1111
alipay_pay_request = AlipayPayRequest()
12-
alipay_pay_request.path = "/ams/sandbox/api/v1/payments/pay"
1312
1413
alipay_pay_request.product_code = ProductCodeType.AGREEMENT_PAYMENT
15-
alipay_pay_request.payment_notify_url = "https://www.merchant.com/notify"
16-
alipay_pay_request.payment_redirect_url = "https://www.merchant.com?param1=sl"
14+
alipay_pay_request.payment_notify_url = "https://www.yourNotifyUrl.com"
15+
alipay_pay_request.payment_redirect_url = "https://www.yourRedirectUrl.com"
1716
alipay_pay_request.payment_request_id = "pay_python_test"
1817
1918
payment_method = PaymentMethod()

com/alipay/ams/api/default_alipay_client.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def __init__(self, gateway_url, client_id, merchant_private_key, alipay_public_k
1313
self.__client_id = client_id
1414
self.__merchant_private_key = merchant_private_key
1515
self.__alipay_public_key = alipay_public_key
16+
self.__is_sandbox_mode = client_id.startswith("SANDBOX_")
1617

1718
"""
1819
内部方法,生成请求签名
@@ -65,6 +66,8 @@ def execute(self, request):
6566
raise AlipayApiException('invalid path')
6667

6768
client_id = self.__client_id
69+
self.__is_sandbox_mode = client_id.startswith("SANDBOX_")
70+
self.adjust_sandbox_url(request)
6871
http_method = request.http_method.value
6972
path = request.path
7073
req_time = get_cur_iso8601_time()
@@ -102,3 +105,10 @@ def execute(self, request):
102105
raise AlipayApiException("response signature verify failed.")
103106

104107
return rsp_body
108+
109+
def adjust_sandbox_url(self, request):
110+
if self.__is_sandbox_mode:
111+
origin_path = request.path
112+
new_path = origin_path.replace('/ams/api', '/ams/sandbox/api', 1)
113+
request.path = new_path
114+
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import json
2+
3+
from com.alipay.ams.api.model.amount import Amount
4+
5+
6+
class AccountBalance:
7+
def __init__(self):
8+
self.__account_balance = None
9+
self.__currency = None
10+
self.__available_balance = None #type: Amount
11+
self.__frozen_balance = None #type: Amount
12+
self.__total_balance = None #type: Amount
13+
14+
@property
15+
def account_balance(self):
16+
return self.__account_balance
17+
@property
18+
def currency(self):
19+
return self.__currency
20+
21+
@property
22+
def available_balance(self):
23+
return self.__available_balance
24+
25+
@property
26+
def frozen_balance(self):
27+
return self.__frozen_balance
28+
29+
@property
30+
def total_balance(self):
31+
return self.__total_balance
32+
33+
def parse_rsp_body(self, response_body):
34+
if type(response_body) == str:
35+
response_body = json.loads(response_body)
36+
37+
if 'accountBalance' in response_body:
38+
self.__account_balance = response_body['accountBalance']
39+
if 'currency' in response_body:
40+
self.__currency = response_body['currency']
41+
if 'availableBalance' in response_body:
42+
self.__available_balance = Amount()
43+
self.__available_balance.parse_rsp_body(response_body['availableBalance'])
44+
if 'frozenBalance' in response_body:
45+
self.__frozen_balance = Amount()
46+
self.__frozen_balance.parse_rsp_body(response_body['frozenBalance'])
47+
if 'totalBalance' in response_body:
48+
self.__total_balance = Amount()
49+
self.__total_balance.parse_rsp_body(response_body['totalBalance'])
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 AccountHolderType(Enum):
6+
INDIVIDUAL = "INDIVIDUAL"
7+
ENTERPRISE = "ENTERPRISE"
8+
9+
def to_ams_dict(self):
10+
return self.name
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
from enum import Enum, unique
3+
4+
5+
@unique
6+
class AccountType(Enum):
7+
CHECKING = "CHECKING"
8+
FIXED_DEPOSIT = "FIXED_DEPOSIT"
9+
10+
def to_ams_dict(self):
11+
return self.name

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ def parse_rsp_body(self, amount_body):
3636

3737
if 'value' in amount_body:
3838
self.__value = amount_body['value']
39+
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
from enum import Enum
2+
3+
class AntomPathConstants(Enum):
4+
"""
5+
Ant Group
6+
Copyright (c) 2004-2024 All Rights Reserved.
7+
"""
8+
AUTH_CONSULT_PATH = "/ams/api/v1/authorizations/consult"
9+
AUTH_APPLY_TOKEN_PATH = "/ams/api/v1/authorizations/applyToken"
10+
AUTH_REVOKE_PATH = "/ams/api/v1/authorizations/revoke"
11+
AUTH_QUERY_PATH = "/ams/api/v1/authorizations/query"
12+
13+
CREATE_VAULTING_SESSION_PATH = "/ams/api/v1/vaults/createVaultingSession"
14+
VAULT_PAYMENT_METHOD_PATH = "/ams/api/v1/vaults/vaultPaymentMethod"
15+
INQUIRE_VAULTING_PATH = "/ams/api/v1/vaults/inquireVaulting"
16+
17+
CONSULT_PAYMENT_PATH = "/ams/api/v1/payments/consult"
18+
PAYMENT_PATH = "/ams/api/v1/payments/pay"
19+
CREATE_SESSION_PATH = "/ams/api/v1/payments/createPaymentSession"
20+
CAPTURE_PATH = "/ams/api/v1/payments/capture"
21+
INQUIRY_PAYMENT_PATH = "/ams/api/v1/payments/inquiryPayment"
22+
CANCEL_PATH = "/ams/api/v1/payments/cancel"
23+
SYNC_ARREAR_PATH = "/ams/api/v1/payments/syncArrear"
24+
CREATE_DEVICE_CERTIFICATE_PATH = "/ams/api/v1/payments/createDeviceCertificate"
25+
26+
SUBSCRIPTION_CREATE_PATH = "/ams/api/v1/subscriptions/create"
27+
SUBSCRIPTION_CHANGE_PATH = "/ams/api/v1/subscriptions/change"
28+
SUBSCRIPTION_CANCEL_PATH = "/ams/api/v1/subscriptions/cancel"
29+
30+
ACCEPT_DISPUTE_PATH = "/ams/api/v1/payments/acceptDispute"
31+
SUPPLY_DEFENCE_DOC_PATH = "/ams/api/v1/payments/supplyDefenseDocument"
32+
DOWNLOAD_DISPUTE_EVIDENCE_PATH = "/ams/api/v1/payments/downloadDisputeEvidence"
33+
34+
REFUND_PATH = "/ams/api/v1/payments/refund"
35+
INQUIRY_REFUND_PATH = "/ams/api/v1/payments/inquiryRefund"
36+
37+
DECLARE_PATH = "/ams/api/v1/customs/declare"
38+
INQUIRY_DECLARE_PATH = "/ams/api/v1/customs/inquiryDeclarationRequests"
39+
40+
MARKETPLACE_SUBMITATTACHMENT_PATH = "/ams/api/open/openapiv2_file/v1/business/attachment/submitAttachment"
41+
MARKETPLACE_REGISTER_PATH = "/ams/api/v1/merchants/register"
42+
MARKETPLACE_SETTLEMENTINFO_UPDATE_PATH = "/ams/api/v1/merchants/settlementInfo/update"
43+
MARKETPLACE_INQUIREBALANCE_PATH = "/ams/api/v1/accounts/inquireBalance"
44+
MARKETPLACE_SETTLE_PATH = "/ams/api/v1/payments/settle"
45+
MARKETPLACE_CREATEPAYOUT_PATH = "/ams/api/v1/funds/createPayout"
46+
MARKETPLACE_CREATETRANSFER_PATH = "/ams/api/v1/funds/createTransfer"
47+
48+
RISK_DECIDE_PATH = "/ams/api/v1/risk/payments/decide"
49+
RISK_REPORT_PATH = "/ams/api/v1/risk/payments/reportRisk"
50+
RISK_SEND_PAYMENT_RESULT_PATH = "/ams/api/v1/risk/payments/sendPaymentResult"
51+
RISK_SEND_REFUND_RESULT_PATH = "/ams/api/v1/risk/payments/sendRefundResult"
52+
53+
MERCHANTS_INQUIRY_REGISTRATION_PATH ="/ams/api/v1/merchants/inquiryRegistrationInfo"
54+
MERCHANTS_REGISTRATION_PATH = "/ams/api/v1/merchants/registration"
55+
MERCHANTS_INQUIRY_REGISTRATION_STATUS_PATH = "/ams/api/v1/merchants/inquiryRegistrationStatus"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
from enum import Enum, unique
3+
4+
5+
@unique
6+
class AssociationType(Enum):
7+
LEGAL_REPRESENTATIVE = "LEGAL_REPRESENTATIVE"
8+
UBO = "UBO"
9+
CONTACT = "CONTACT"
10+
DIRECTOR = "DIRECTOR"
11+
AUTHORIZER = "AUTHORIZER"
12+
BOARD_MEMBER = "BOARD_MEMBER"
13+
14+
def to_ams_dict(self):
15+
return self.name

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ def __init__(self):
33
self.__attachment_type = None
44
self.__file = None
55
self.__attachment_name = None
6+
self.__file_key = None
67

78
@property
89
def attachment_type(self):
@@ -28,6 +29,14 @@ def attachment_name(self):
2829
def attachment_name(self, value):
2930
self.__attachment_name = value
3031

32+
@property
33+
def file_key(self):
34+
return self.__file_key
35+
36+
@file_key.setter
37+
def file_key(self, value):
38+
self.__file_key = value
39+
3140
def to_ams_dict(self):
3241
params = dict()
3342
if hasattr(self, "attachment_type") and self.attachment_type:
@@ -39,4 +48,7 @@ def to_ams_dict(self):
3948
if hasattr(self, "attachment_name") and self.attachment_name:
4049
params['attachmentName'] = self.attachment_name
4150

51+
if hasattr(self, "file_key") and self.file_key:
52+
params['fileKey'] = self.file_key
53+
4254
return params

0 commit comments

Comments
 (0)