Search in sources :

Example 1 with TransactionCloneRequest

use of com.braintreegateway.TransactionCloneRequest in project camel by apache.

the class TransactionGatewayIntegrationTest method testCloneTransaction.

@Test
public void testCloneTransaction() throws Exception {
    assertNotNull("BraintreeGateway can't be null", this.gateway);
    final Result<Transaction> createResult = requestBody("direct://SALE", new TransactionRequest().amount(new BigDecimal("100.00")).paymentMethodNonce("fake-valid-nonce").options().submitForSettlement(false).done(), Result.class);
    assertNotNull("sale result", createResult);
    assertTrue(createResult.isSuccess());
    LOG.info("Transaction done - id={}", createResult.getTarget().getId());
    this.transactionIds.add(createResult.getTarget().getId());
    final Result<Transaction> cloneResult = requestBodyAndHeaders("direct://CLONETRANSACTION", null, new BraintreeHeaderBuilder().add("id", createResult.getTarget().getId()).add("cloneRequest", new TransactionCloneRequest().amount(new BigDecimal("99.00")).options().submitForSettlement(true).done()).build(), Result.class);
    assertNotNull("clone result", cloneResult);
    assertTrue(cloneResult.isSuccess());
    LOG.info("Clone Transaction done - clonedId={}, id={}", createResult.getTarget().getId(), cloneResult.getTarget().getId());
    this.transactionIds.add(cloneResult.getTarget().getId());
}
Also used : Transaction(com.braintreegateway.Transaction) TransactionCloneRequest(com.braintreegateway.TransactionCloneRequest) TransactionRequest(com.braintreegateway.TransactionRequest) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Aggregations

Transaction (com.braintreegateway.Transaction)1 TransactionCloneRequest (com.braintreegateway.TransactionCloneRequest)1 TransactionRequest (com.braintreegateway.TransactionRequest)1 BigDecimal (java.math.BigDecimal)1 Test (org.junit.Test)1