Available as of Camel 2.17
The Braintree component provides access to
Braintree Payments services which support the following payment methods:
Maven users will need to add the following dependency to their pom.xml
for this component:
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-braintree</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency>
braintree://endpoint-prefix/endpoint?[options]
Endpoint prefix can be one of:
addOn
address
clientToken
creditCardverification
customer
discount
merchantAccount
paymentmethod
paymentmethodNonce
plan
settlementBatchSummary
subscription
transaction
webhookNotification
The Braintree Component can be configured with the options below. These options can be provided using the component's bean property configuration of type org.apache.camel.component.braintree.BraintreeConfiguration.
All the options above are provided by Braintree Payments
Producer endpoints can use endpoint prefixes followed by endpoint names and associated options described next. A shorthand alias can be used for some endpoints. The endpoint URI MUST contain a prefix.
Endpoint options that are not mandatory are denoted by []. When there are no mandatory options for an endpoint, one of the set of [] options MUST be provided. Producer endpoints can also use a special option inBody that in turn should contain the name of the endpoint option whose value will be contained in the Camel Exchange In message.
Any of the endpoint options can be provided in either the endpoint URI, or dynamically in a message header. The message header name must be of the format CamelBraintree.<option>. Note that the inBody option overrides message header, i.e. the endpoint option inBody=option would override a CamelBraintree.option header.
The following endpoints can be invoked with the prefix addOn as follows:
braintree://addOn/endpoint
The following endpoints can be invoked with the prefix address as follows:
braintree://address/endpoint?[options]
Table 16.1. URI Options for address
Name | Type |
customerId
|
String
|
request
|
com.braintreegateway.AddressRequest
|
id
|
String
|
Endpoint prefix clientToken
The following endpoints can be invoked with the prefix clientToken as follows:
braintree://clientToken/endpoint?[options]
Table 16.2. URI Options for clientToken
Name | Type |
request
|
com.braintreegateway.ClientTokenrequest
|
Endpoint prefix creditCardVerification
The following endpoints can be invoked with the prefix creditCardverification as follows:
braintree://creditCardVerification/endpoint?[options]
Table 16.3. URI Options for creditCardVerification
Name | Type |
id
|
String
|
query
|
com.braintreegateway. CreditCardVerificationSearchRequest
|
The following endpoints can be invoked with the prefix customer as follows:
braintree://customer/endpoint?[options]
Table 16.4. URI Options for customer
Name | Type |
id
|
String
|
request
|
com.braintreegateway.CustomerRequest
|
query
|
com.braintreegateway.CustomerSearchRequest
|
The following endpoints can be invoked with the prefix discount as follows:
braintree://discount/endpoint
Endpoint prefix merchantAccount
The following endpoints can be invoked with the prefix merchantAccount as follows:
braintree://merchantAccount/endpoint?[options]
Table 16.5. URI Options for merchantAccount
Name | Type |
id
|
String
|
request
|
com.braintreegateway.MerchantAccountRequest
|
Endpoint prefix paymentMethod
The following endpoints can be invoked with the prefix paymentMethod as follows:
braintree://paymentMethod/endpoint?[options]
Table 16.6. URI Options for paymentMethod
Name | Type |
token
|
String
|
request
|
com.braintreegateway.PaymentMethodRequest
|
Endpoint prefix paymentMethodNonce
The following endpoints can be invoked with the prefix paymentMethodNonce as follows:
braintree://paymentMethodNonce/endpoint?[options]
Table 16.7. URI Options for paymentMethodNonce
Name | Type |
paymentMethodToken
|
String
|
paymentMethodNonce
|
String
|
The following endpoints can be invoked with the prefix plan as follows:
braintree://plan/endpoint
Endpoint prefix settlementBatchSummary
The following endpoints can be invoked with the prefix settlementBatchSummary as follows:
braintree://settlementBatchSummary/endpoint?[options]
Table 16.8. URI Options for settlementBatchSummary
Name | Type |
settlementDate
|
Calendar
|
groupByCustomField
|
String
|
Endpoint prefix subscription
The following endpoints can be invoked with the prefix subscription as follows:
braintree://subscription/endpoint?[options]
Table 16.9. URI Options for subscription
Name | Type |
id
|
String
|
request
|
com.braintreegateway.SubscriptionRequest
|
customerId
|
String
|
subscriptionId
|
String
|
amount
|
BigDecimal
|
searchRequest
|
com.braintreegateway.SubscriptionSearchRequest.
|
Endpoint prefix transaction
The following endpoints can be invoked with the prefix transaction as follows:
braintree://transaction/endpoint?[options]
Table 16.10. URI Options for transaction
Name | Type |
id
|
String
|
request
|
com.braintreegateway.TransactionCloneRequest
|
cloneRequest
|
com.braintreegateway.TransactionCloneRequest
|
amount
|
BigDecimal
|
query
|
com.braintreegateway.TransactionSearchRequest
|
Endpoint prefix webhookNotification
The following endpoints can be invoked with the prefix webhookNotification as follows:
braintree://webhookNotification/endpoint?[options]
Table 16.11. URI Options for webhookNotification
Name | Type |
signature
|
String
|
payload
|
String
|
challenge
|
String
|
Any of the producer endpoints can be used as a consumer endpoint. Consumer endpoints can use
Scheduled Poll Consumer Options with a
consumer. prefix to schedule endpoint invocation. By default Consumer endpoints that return an array or collection will generate one exchange per element, and their routes will be executed once for each exchange. To change this behavior use the property
consumer.splitResults=true to return a single exchange for the entire list or array.
Any URI option can be provided in a message header for producer endpoints with a CamelBraintree. prefix.
All result message bodies utilize objects provided by the Braintree Java SDK. Producer endpoints can specify the option name for incoming message body in the inBody endpoint parameter.
<?xml version="1.0"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
xsi:schemaLocation="
http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.0.0.xsd
http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<cm:property-placeholder id="placeholder" persistent-id="camel.braintree">
</cm:property-placeholder>
<bean id="braintree" class="org.apache.camel.component.braintree.BraintreeComponent">
<property name="configuration">
<bean class="org.apache.camel.component.braintree.BraintreeConfiguration">
<property name="environment" value="${environment}"/>
<property name="merchantId" value="${merchantId}"/>
<property name="publicKey" value="${publicKey}"/>
<property name="privateKey" value="${privateKey}"/>
</bean>
</property>
</bean>
<camelContext trace="true" xmlns="http://camel.apache.org/schema/blueprint" id="braintree-example-context">
<route id="braintree-example-route">
<from uri="direct:generateClientToken"/>
<to uri="braintree://clientToken/generate"/>
<to uri="stream:out"/>
</route>
</camelContext>
</blueprint>