[SPAPI] 如何对接一个新的API, 以财务退款API为例

351 阅读1分钟

这是包的地址 `github.com/amzn/sellin…`

这是Amazon官方的财务API文档 developer-docs.amazon.com/sp-api/docs…

1.首先打开vendor里面包的RM文档

vendor/jlevers/selling-partner-api/docs/Api/FinancesApi.md

2.查看对接文档和示例代码

image.png

3.在快速测试脚本中编写代码
<?php

use SellingPartnerApi\Api\FinancesV0Api; //注意,虽然文档中没有V0,但是实际引入中需要

    // 获取财务相关
    public function getOrderFinancialEvents($config)
    {
        $apiInstance = new FinancesV0Api($config);
        $order_id = '000-0000000-0000000'; // string | An Amazon-defined order identifier, in 3-7-7 format.
        $max_results_per_page = 100; // int | The maximum number of results to return per page.
        $next_token = 'next_token_example'; // string | A string token returned in the response of your previous request.
        
        try {
            $result = $apiInstance->listFinancialEventsByOrderId($order_id, $max_results_per_page, null);
            $result = json_decode($result, true);
            dd(json_encode($result));
            
        } catch (Exception $e) {
            echo 'Exception when calling FinancesApi->listFinancialEventsByOrderId: ', $e->getMessage(), PHP_EOL;
        }
    }

SPAPI对接群: 790166589 983825517 950232659

亚马逊SP-API开发者大学: www.youtube.com/watch?v=7cZ…