0

我目前正在尝试在 Adyen Disputes API 中自动上传证据文件 (PDF) 以消除争议。

Adyen 争议 API 文档: https ://docs.adyen.com/risk-management/disputes-api#supply-dispute-defense-documents

该文档要求以 PDF 文件的 Base64 字符串发送文档的二进制内容。执行代码时,API 返回一条 200 消息,说明它已成功,但我无法在网站本身中看到 PDF 文件。编码有问题吗?

作为记录,我同时使用了base64.b64encode(pdf_file.read()).decode()[base64.b64encode(pdf_file.read()).decode('utd-8')][1]

    with open("/Path/Path/Path/Path/dispute_evidence_test_sample_1.pdf", "rb") as pdf_file:
         encoded_string = base64.b64encode(pdf_file.read()).decode()
    
    headers = {
        'x-api-key': 'API-KEY',
        'content-type': 'application/json'
    }
    
    data = {
        "defenseDocuments": [
            {
                "content": encoded_string,
                "contentType": "application/pdf",
                "defenseDocumentTypeCode": "MerchandiseDescription"
            }
        ],
        "disputePspReference": "8936291617862600",
        "merchantAccountCode": "my_mechant_account"
    }
    
    json_data = json.dumps(data)
    response = requests.post('https://ca-test.adyen.com/ca/services/DisputeService/v30/supplyDefenseDocument', headers=headers, data=json_data)
    
    print('')
    print(response)
    print(response.content)
    print('')

<Response [200]>
b'{"disputeServiceResult":{"success":true}}'
4

0 回答 0