Search in sources :

Example 1 with TransactionRequest

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

the class TransactionGatewayIntegrationTest method testSubmitForSettlementWithIdAndAmount.

@Test
public void testSubmitForSettlementWithIdAndAmount() 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> result = requestBodyAndHeaders("direct://SUBMITFORSETTLEMENT_WITH_ID_ADN_AMOUNT", null, new BraintreeHeaderBuilder().add("id", createResult.getTarget().getId()).add("amount", new BigDecimal("100.00")).build(), Result.class);
    assertNotNull("Submit For Settlement result", result);
    LOG.debug("Transaction submitted for settlement - id={}" + result.getTarget().getId());
}
Also used : Transaction(com.braintreegateway.Transaction) TransactionRequest(com.braintreegateway.TransactionRequest) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 2 with TransactionRequest

use of com.braintreegateway.TransactionRequest 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)

Example 3 with TransactionRequest

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

the class TransactionGatewayIntegrationTest method testFind.

@Test
public void testFind() 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());
    // using String message body for single parameter "id"
    final Transaction result = requestBody("direct://FIND", createResult.getTarget().getId());
    assertNotNull("find result", result);
    LOG.info("Transaction found - id={}", result.getId());
}
Also used : Transaction(com.braintreegateway.Transaction) TransactionRequest(com.braintreegateway.TransactionRequest) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Aggregations

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