Repository navigation
Expand file tree
/
Copy pathcustomsDeclare.py
More file actions
84 lines (73 loc) · 3.38 KB
/
Copy pathcustomsDeclare.py
File metadata and controls
84 lines (73 loc) · 3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
from com.alipay.ams.api.default_alipay_client import DefaultAlipayClient
from com.alipay.ams.api.model.amount import Amount
from com.alipay.ams.api.model.certificate import Certificate
from com.alipay.ams.api.model.customs_info import CustomsInfo
from com.alipay.ams.api.model.merchant_customs_info import MerchantCustomsInfo
from com.alipay.ams.api.model.result_status_type import ResultStatusType
from com.alipay.ams.api.model.user_name import UserName
from com.alipay.ams.api.request.declare.alipay_customs_declare_request import (
AlipayCustomsDeclareRequest,
)
from com.alipay.ams.api.request.declare.alipay_customs_query_request import (
AlipayCustomsQueryRequest,
)
from com.alipay.ams.api.response.declare.alipay_customs_declare_response import (
AlipayCustomsDeclareResponse,
)
from com.alipay.ams.api.response.declare.alipay_customs_query_response import (
AlipayCustomsQueryResponse,
)
MERCHANT_PRIVATE_KEY = ""
ALIPAY_PUBLIC_KEY = ""
CLIENT_ID = ""
GATEWAY_HOST = ""
def declare(paymentId):
default_alipay_client = DefaultAlipayClient(
GATEWAY_HOST, CLIENT_ID, MERCHANT_PRIVATE_KEY, ALIPAY_PUBLIC_KEY
)
alipayCustomsDeclareRequest = AlipayCustomsDeclareRequest()
alipayCustomsDeclareRequest.declaration_request_id = "declaration_test_00001"
alipayCustomsDeclareRequest.payment_id = paymentId
alipayCustomsDeclareRequest.declaration_amount = Amount("CNY", 100)
merchantCustomsInfo = MerchantCustomsInfo()
merchantCustomsInfo.merchant_customs_code = "amsdemoskr"
merchantCustomsInfo.merchant_customs_name = "amsdemo"
alipayCustomsDeclareRequest.merchant_customs_info = merchantCustomsInfo
alipayCustomsDeclareRequest.split_order = "false"
customs = CustomsInfo()
customs.region = "CN"
customs.customs_code = "ZONGSHU"
alipayCustomsDeclareRequest.customs = customs
buyerCertificate = Certificate()
holderName = UserName()
holderName.first_name = "f"
holderName.last_name = "l"
holderName.full_name = "guodong.wzj"
holderName.middle_name = "m"
buyerCertificate.holder_name = holderName
buyerCertificate.certificate_no = "123456789"
buyerCertificate.certificate_type = "ID_CARD"
alipayCustomsDeclareRequest.buyer_certificate = buyerCertificate
rsp_body = default_alipay_client.execute(alipayCustomsDeclareRequest)
alipayCustomsDeclareResponse = AlipayCustomsDeclareResponse(rsp_body)
if (
alipayCustomsDeclareResponse.result.result_status.name
== ResultStatusType.S.name
):
print(alipayCustomsDeclareResponse.customs_payment_id)
else:
print(alipayCustomsDeclareResponse.result.result_message)
def inquiryDeclaration(declarationRequestIds):
default_alipay_client = DefaultAlipayClient(
GATEWAY_HOST, CLIENT_ID, MERCHANT_PRIVATE_KEY, ALIPAY_PUBLIC_KEY
)
alipayCustomsQueryRequest = AlipayCustomsQueryRequest()
alipayCustomsQueryRequest.declaration_request_ids = declarationRequestIds
rsp_body = default_alipay_client.execute(alipayCustomsQueryRequest)
alipayCustomsQueryResponse = AlipayCustomsQueryResponse(rsp_body)
if alipayCustomsQueryResponse.result.result_status.name == ResultStatusType.S.name:
print(alipayCustomsQueryResponse.result.result_status)
else:
print(alipayCustomsQueryResponse.result.result_message)
declare("202407311940108001001887A0209760494")
# inquiryDeclaration(["declaration_test_00001"])