Search in sources :

Example 1 with BraintreeGateway

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

the class WebhookNotificationGatewayIntegrationTest method testParse.

@Test
public void testParse() throws Exception {
    final BraintreeGateway gateway = getGateway();
    Map<String, String> notification = gateway.webhookTesting().sampleNotification(WebhookNotification.Kind.SUBSCRIPTION_WENT_PAST_DUE, "my_id");
    final Map<String, Object> headers = new HashMap<>();
    headers.put(BraintreeConstants.PROPERTY_PREFIX + "signature", notification.get("bt_signature"));
    headers.put(BraintreeConstants.PROPERTY_PREFIX + "payload", notification.get("bt_payload"));
    final WebhookNotification result = requestBodyAndHeaders("direct://PARSE", null, headers);
    assertNotNull("parse result", result);
    assertEquals("my_id", result.getSubscription().getId());
}
Also used : HashMap(java.util.HashMap) WebhookNotification(com.braintreegateway.WebhookNotification) BraintreeGateway(com.braintreegateway.BraintreeGateway) Test(org.junit.Test)

Example 2 with BraintreeGateway

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

the class BraintreeConfiguration method newBraintreeGateway.

/**
     * Construct a BraintreeGateway from configuration
     */
synchronized BraintreeGateway newBraintreeGateway() {
    final BraintreeGateway gateway = new BraintreeGateway(getBraintreeEnvironment(), getMerchantId(), getPublicKey(), getPrivateKey());
    if (ObjectHelper.isNotEmpty(proxyHost) && ObjectHelper.isNotEmpty(proxyPort)) {
        gateway.setProxy(proxyHost, proxyPort);
    }
    if (httpReadTimeout != null) {
        gateway.getConfiguration().setTimeout(httpReadTimeout);
    }
    // If custom log name is defined, a new logger wil be requested otherwise
    // the one supplied by Braintree' SDK will be used
    final Logger logger = ObjectHelper.isNotEmpty(httpLogName) ? Logger.getLogger(httpLogName) : gateway.getConfiguration().getLogger();
    // Cleanup handlers as by default braintree install a ConsoleHandler
    for (Handler handler : logger.getHandlers()) {
        logger.removeHandler(handler);
    }
    logger.addHandler(new BraintreeLogHandler());
    if (httpLogLevel != null) {
        logger.setLevel(httpLogLevel);
    }
    gateway.getConfiguration().setLogger(logger);
    return gateway;
}
Also used : BraintreeLogHandler(org.apache.camel.component.braintree.internal.BraintreeLogHandler) BraintreeLogHandler(org.apache.camel.component.braintree.internal.BraintreeLogHandler) Handler(java.util.logging.Handler) BraintreeGateway(com.braintreegateway.BraintreeGateway) Logger(java.util.logging.Logger)

Aggregations

BraintreeGateway (com.braintreegateway.BraintreeGateway)2 WebhookNotification (com.braintreegateway.WebhookNotification)1 HashMap (java.util.HashMap)1 Handler (java.util.logging.Handler)1 Logger (java.util.logging.Logger)1 BraintreeLogHandler (org.apache.camel.component.braintree.internal.BraintreeLogHandler)1 Test (org.junit.Test)1