com.braintreegateway.test.TestingGateway Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of org.apache.servicemix.bundles.braintree-java
Show all versions of org.apache.servicemix.bundles.braintree-java
This OSGi bundle wraps ${pkgArtifactId} ${pkgVersion} jar file.
package com.braintreegateway.test;
import com.braintreegateway.Configuration;
import com.braintreegateway.Environment;
import com.braintreegateway.Result;
import com.braintreegateway.Transaction;
import com.braintreegateway.exceptions.TestOperationPerformedInProductionException;
import com.braintreegateway.util.Http;
import com.braintreegateway.util.NodeWrapper;
public class TestingGateway {
private Http http;
private Configuration configuration;
public TestingGateway(Http http, Configuration configuration) {
this.configuration = configuration;
this.http = http;
}
public Result settle(String transactionId) {
checkEnvironment();
NodeWrapper node = http.put(configuration.getMerchantPath() + "/transactions/" + transactionId + "/settle");
return new Result(node, Transaction.class);
}
public Result settlementConfirm(String transactionId) {
checkEnvironment();
NodeWrapper node = http.put(configuration.getMerchantPath() + "/transactions/" + transactionId + "/settlement_confirm");
return new Result(node, Transaction.class);
}
public Result settlementDecline(String transactionId) {
checkEnvironment();
NodeWrapper node = http.put(configuration.getMerchantPath() + "/transactions/" + transactionId + "/settlement_decline");
return new Result(node, Transaction.class);
}
public Result settlementPending(String transactionId) {
checkEnvironment();
NodeWrapper node = http.put(configuration.getMerchantPath() + "/transactions/" + transactionId + "/settlement_pending");
return new Result(node, Transaction.class);
}
private void checkEnvironment() throws TestOperationPerformedInProductionException {
if (configuration.getEnvironment() == Environment.PRODUCTION) {
throw new TestOperationPerformedInProductionException();
}
}
}