3

I have created a webapi.xml in module vault:

<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Webapi:etc/webapi.xsd">

    <route url="/V1/vault/items" method="GET">
        <service class="Magento\Vault\Api\PaymentTokenManagementInterface" method="getListByCustomerId"/>
        <resources>
            <resource ref="self" />
        </resources>
        <data>
            <parameter name="customerId" force="true">%customer_id%</parameter>
        </data>
    </route>


</routes>

Give this type of error :-

this is a result:"message": "Internal Error. Details are available in Magento log file. Report ID: webapi-5b7c371e39aa0" }

in my log file i see this error: -

Error:
main.CRITICAL: Report ID: webapi-5b7c371e39aa0; Message: Class \Magento\Vault\Api\Data\PaymentTokenSearchResultsInterfa does not exist {"exception":"     
     [object] (Exception(code: -1): Report ID: webapi-5b7c371e39aa0; Message: Class      \\Magento\\Vault\\Api\\Data\\PaymentTokenSearchResultsInterfa does not exist at /<dir>/vendor/magento/framework/Webapi/ErrorProcessor.php:205, ReflectionException(code: -1): Class \\Magento\\Vault\\Api\\Data\\PaymentTokenSearchResultsInterfa does not exist at /<dir>/vendor/magento/framework/Reflection/MethodsMap.php:155)"} []

Can help me?

2

Looks like there is an issue in Magento 2 core.

/**
 * Lists payment tokens that match specified search criteria.
 *
 * @param int $customerId Customer ID.
 * @return \Magento\Vault\Api\Data\PaymentTokenSearchResultsInterface Payment token search result interface.
 * @since 100.1.0
 */
public function getListByCustomerId($customerId);

return value is \Magento\Vault\Api\Data\PaymentTokenSearchResultsInterface but actually it returns \Magento\Vault\Api\Data\PaymentTokenInterface[]. So set correct return type fix the issue.

Here you can check working sample https://github.com/troublediehard/mma-customapi

| improve this answer | |
0

We needed to import tokens into the vault using the rest Api, so we knocked this module together: https://packagist.org/packages/zero1/vault-web-api hopefully it helps.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.