Authorize.net Java SDK(2.0.1v) Environment not set issue

半世苍凉 提交于 2021-02-10 06:09:37

问题


I am using Authorize.net as a Payment vendor in my application. After getting form token from Mobile SDK, I am using their Java SDK in Backend to initiate Payment.

But I am getting the following issue while using CreateAnAcceptPaymentTransaction class from Authorize.net Java SDK(v2.0.1).

Environment not set. Set environment using setter or use overloaded method to pass appropriate environment

The controller object in the below line has the error.

CreateTransactionController controller = new CreateTransactionController(apiRequest);

I have already set the environment via the below piece of code

ApiOperationBase.setEnvironment(Environment.SANDBOX);

Tried to downgrade the version to v2.0.0 but it doesn't worked for me.

Any help would be really appreciated.


回答1:


The error was not actually with setting Environment.

You might have got an exception which is mentioned below.

javax.xml.bind.JAXBException Implementation of JAXB-API has not been found on module path or classpath 

It was with a missing dependency in gradle file or Maven file.

Add these dependencies into your pom/gradle:

Gradle:

compile('javax.xml.bind:jaxb-api:2.3.0')
compile('javax.activation:activation:1.1')
compile('org.glassfish.jaxb:jaxb-runtime:2.3.0')

Pom:

<!-- https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api -->
<dependency>
    <groupId>javax.xml.bind</groupId>
    <artifactId>jaxb-api</artifactId>
    <version>2.3.0-b170201.1204</version>
</dependency>

<!-- https://mvnrepository.com/artifact/javax.activation/activation -->
<dependency>
    <groupId>javax.activation</groupId>
    <artifactId>activation</artifactId>
    <version>1.1</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.glassfish.jaxb/jaxb-runtime -->
<dependency>
    <groupId>org.glassfish.jaxb</groupId>
    <artifactId>jaxb-runtime</artifactId>
    <version>2.3.0-b170127.1453</version>
</dependency>

Original Post can be found here javax.xml.bind.JAXBException Implementation of JAXB-API has not been found on module path or classpath



来源:https://stackoverflow.com/questions/60650812/authorize-net-java-sdk2-0-1v-environment-not-set-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!