Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.

Chapter 54. Braintree Component


Available as of Camel version 2.17

The Braintree component provides access to Braintree Payments trough through theirs Java SDK.

All client applications need API credential in order to process payments. In order to use camel-braintree with your account, you’ll need to create a new Sandbox or Production account.

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>${camel-version}</version>
</dependency>

54.1. Braintree Options

The Braintree component supports 2 options, which are listed below.

NameDescriptionDefaultType

configuration (common)

To use the shared configuration

 

BraintreeConfiguration

resolveProperty Placeholders (advanced)

Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders.

true

boolean

The Braintree endpoint is configured using URI syntax:

braintree:apiName/methodName

with the following path and query parameters:

54.1.1. Path Parameters (2 parameters):

NameDescriptionDefaultType

apiName

Required What kind of operation to perform

 

BraintreeApiName

methodName

What sub operation to use for the selected operation

 

String

54.1.2. Query Parameters (14 parameters):

NameDescriptionDefaultType

environment (common)

The environment Either SANDBOX or PRODUCTION

 

String

inBody (common)

Sets the name of a parameter to be passed in the exchange In Body

 

String

merchantId (common)

The merchant id provided by Braintree.

 

String

privateKey (common)

The private key provided by Braintree.

 

String

publicKey (common)

The public key provided by Braintree.

 

String

bridgeErrorHandler (consumer)

Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored.

false

boolean

exceptionHandler (consumer)

To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored.

 

ExceptionHandler

exchangePattern (consumer)

Sets the exchange pattern when the consumer creates an exchange.

 

ExchangePattern

accessToken (advanced)

The access token granted by a merchant to another in order to process transactions on their behalf. Used in place of environment, merchant id, public key and private key fields.

 

String

httpReadTimeout (advanced)

Set read timeout for http calls.

 

Integer

synchronous (advanced)

Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported).

false

boolean

httpLogLevel (logging)

Set logging level for http calls, see java.util.logging.Level

 

String

proxyHost (proxy)

The proxy host

 

String

proxyPort (proxy)

The proxy port

 

Integer

54.2. Spring Boot Auto-Configuration

The component supports 14 options, which are listed below.

NameDescriptionDefaultType

camel.component.braintree.configuration.access-token

The access token granted by a merchant to another in order to process transactions on their behalf. Used in place of environment, merchant id, public key and private key fields.

 

String

camel.component.braintree.configuration.api-name

What kind of operation to perform

 

BraintreeApiName

camel.component.braintree.configuration.environment

The environment Either SANDBOX or PRODUCTION

 

String

camel.component.braintree.configuration.http-log-level

Set logging level for http calls, see java.util.logging.Level

 

Level

camel.component.braintree.configuration.http-log-name

Set log category to use to log http calls, default "Braintree"

 

String

camel.component.braintree.configuration.http-read-timeout

Set read timeout for http calls.

 

Integer

camel.component.braintree.configuration.merchant-id

The merchant id provided by Braintree.

 

String

camel.component.braintree.configuration.method-name

What sub operation to use for the selected operation

 

String

camel.component.braintree.configuration.private-key

The private key provided by Braintree.

 

String

camel.component.braintree.configuration.proxy-host

The proxy host

 

String

camel.component.braintree.configuration.proxy-port

The proxy port

 

Integer

camel.component.braintree.configuration.public-key

The public key provided by Braintree.

 

String

camel.component.braintree.enabled

Enable braintree component

true

Boolean

camel.component.braintree.resolve-property-placeholders

Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders.

true

Boolean

54.3. URI format

braintree://endpoint-prefix/endpoint?[options]

Endpoint prefix can be one of:

  • addOn
  • address
  • clientToken
  • creditCardverification
  • customer
  • discount
  • dispute
  • documentUpload
  • merchantAccount
  • paymentmethod
  • paymentmethodNonce
  • plan
  • report
  • settlementBatchSummary
  • subscription
  • transaction
  • webhookNotification

54.4. BraintreeComponent

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.

OptionTypeDescription

environment

String

Value that specifies where requests should be directed – sandbox or production

merchantId

String

A unique identifier for your gateway account, which is different than your merchant account ID

publicKey

String

User-specific public identifier

privateKey

String

User-specific secure identifier that should not be shared – even with us!

accessToken

String

Token granted to a merchant using Braintree Auth allowing them to process transactions on another’s behalf. Used in place of the environment, merchantId, publicKey and privateKey options.

All the options above are provided by Braintree Payments

54.5. Producer Endpoints:

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.

For more information on the endpoints and options see Braintree references at https://developers.braintreepayments.com/reference/overview

54.5.1. Endpoint prefix addOn

The following endpoints can be invoked with the prefix addOn as follows:

braintree://addOn/endpoint
EndpointShorthand AliasOptionsResult Body Type

all

  

List<com.braintreegateway.Addon>

54.5.2. Endpoint prefix address

The following endpoints can be invoked with the prefix address as follows:

braintree://address/endpoint?[options]
EndpointShorthand AliasOptionsResult Body Type

create

 

customerId, request

com.braintreegateway.Result<com.braintreegateway.Address>

delete

 

customerId, id

com.braintreegateway.Result<com.braintreegateway.Address>

find

 

customerId, id

com.braintreegateway.Address

update

 

customerId, id, request

com.braintreegateway.Result<com.braintreegateway.Address>

URI Options for address

NameType

customerId

String

request

com.braintreegateway.AddressRequest

id

String

54.5.3. Endpoint prefix clientToken

The following endpoints can be invoked with the prefix clientToken as follows:

braintree://clientToken/endpoint?[options]
EndpointShorthand AliasOptionsResult Body Type

generate

 

request

String

URI Options for clientToken

NameType

request

com.braintreegateway.ClientTokenrequest

54.5.4. Endpoint prefix creditCardVerification

The following endpoints can be invoked with the prefix creditCardverification as follows:

braintree://creditCardVerification/endpoint?[options]
EndpointShorthand AliasOptionsResult Body Type

find

 

id

com.braintreegateway.CreditCardVerification

search

 

query

com.braintreegateway.ResourceCollection<com.braintreegateway.CreditCardVerification>

URI Options for creditCardVerification

NameType

id

String

query

com.braintreegateway.CreditCardVerificationSearchRequest

54.5.5. Endpoint prefix customer

The following endpoints can be invoked with the prefix customer as follows:

braintree://customer/endpoint?[options]
EndpointShorthand AliasOptionsResult Body Type

all

   

create

 

request

com.braintreegateway.Result<com.braintreegateway.Customer>

delete

 

id

com.braintreegateway.Result<com.braintreegateway.Customer>

find

 

id

com.braintreegateway.Customer

search

 

query

com.braintreegateway.ResourceCollection<com.braintreegateway.Customer>

update

 

id, request

com.braintreegateway.Result<com.braintreegateway.Customer>

URI Options for customer

NameType

id

String

request

com.braintreegateway.CustomerRequest

query

com.braintreegateway.CustomerSearchRequest

54.5.6. Endpoint prefix discount

The following endpoints can be invoked with the prefix discount as follows:

braintree://discount/endpoint
EndpointShorthand AliasOptionsResult Body Type

all

 

 

List<com.braintreegateway.Discount>

+
+

54.5.7. Endpoint prefix dispute

The following endpoints can be invoked with the prefix dispute as follows:

braintree://dispute/endpoint?[options]
EndpointShorthand AliasOptionsResult Body Type

accept

 

id

com.braintreegateway.Result

addFileEvidence

 

disputeId, documentId

com.braintreegateway.Result<DisputeEvidence>

addFileEvidence

 

disputeId, fileEvidenceRequest

com.braintreegateway.Result<DisputeEvidence>

addTextEvidence

 

disputeId, content

com.braintreegateway.Result<DisputeEvidence>

addTextEvidence

 

disputeId, textEvidenceRequest

com.braintreegateway.Result<DisputeEvidence>

finalize

 

id

com.braintreegateway.Result

find

 

id

com.braintreegateway.Dispute

removeEvidence

 

id

com.braintreegateway.Result

search

 

disputeSearchRequest

com.braintreegateway.PaginatedCollection<com.braintreegateway.Dispute>

URI Options for dispute

NameType

id

String

disputeId

String

documentId

String

fileEvidenceRequest

com.braintreegateway.FileEvidenceRequest

content

String

 

textEvidenceRequest

com.braintreegateway.TextEvidenceRequest

disputeSearchRequest

54.5.8. Endpoint prefix documentUpload

The following endpoints can be invoked with the prefix documentUpload as follows:

braintree://documentUpload/endpoint?[options]
EndpointShorthand AliasOptionsResult Body Type

create

 

request

com.braintreegateway.Result<com.braintreegateway.DocumentUpload>

URI Options for documentUpload

NameType

request

com.braintreegateway.DocumentUploadRequest

54.5.9. Endpoint prefix merchantAccount

The following endpoints can be invoked with the prefix merchantAccount as follows:

 

braintree://merchantAccount/endpoint?[options]
EndpointShorthand AliasOptionsResult Body Type

create

 

request

com.braintreegateway.Result<com.braintreegateway.MerchantAccount>

createForCurrency

 

currencyRequest

com.braintreegateway.Result<com.braintreegateway.MerchantAccount>

find

 

id

com.braintreegateway.MerchantAccount

update

 

id, request

com.braintreegateway.Result<com.braintreegateway.MerchantAccount>

URI Options for merchantAccount

NameType

id

String

request

com.braintreegateway.MerchantAccountRequest

currencyRequest

com.braintreegateway.MerchantAccountCreateForCurrencyRequest

54.5.10. Endpoint prefix paymentMethod

The following endpoints can be invoked with the prefix paymentMethod as follows:

 

braintree://paymentMethod/endpoint?[options]
EndpointShorthand AliasOptionsResult Body Type

create

 

request

com.braintreegateway.Result<com.braintreegateway.PaymentMethod>

delete

 

token, deleteRequest

com.braintreegateway.Result<com.braintreegateway.PaymentMethod>

find

 

token

com.braintreegateway.PaymentMethod

update

 

token, request

com.braintreegateway.Result<com.braintreegateway.PaymentMethod>

URI Options for paymentMethod

NameType

token

String

request

com.braintreegateway.PaymentMethodRequest

deleteRequest

com.braintreegateway.PaymentMethodDeleteRequest

54.5.11. Endpoint prefix paymentMethodNonce

The following endpoints can be invoked with the prefix paymentMethodNonce as follows:

 

braintree://paymentMethodNonce/endpoint?[options]
EndpointShorthand AliasOptionsResult Body Type

create

 

paymentMethodToken

com.braintreegateway.Result<com.braintreegateway.PaymentMethodNonce>

find

 

paymentMethodNonce

com.braintreegateway.PaymentMethodNonce

URI Options for paymentMethodNonce

NameType

paymentMethodToken

String

paymentMethodNonce

String

54.5.12. Endpoint prefix plan

The following endpoints can be invoked with the prefix plan as follows:

 

braintree://plan/endpoint
EndpointShorthand AliasOptionsResult Body Type

all

 

 

List<com.braintreegateway.Plan>

54.5.13. Endpoint prefix report

The following endpoints can be invoked with the prefix report as follows:

braintree://plan/report?[options]
EndpointShorthand AliasOptionsResult Body Type

transactionLevelFees

 

 request

com.braintreegateway.Result<com.braintreegateway.TransactionLevelFeeReport>

URI Options for report

NameType

request

com.braintreegateway.TransactionLevelFeeReportRequest

54.5.14. Endpoint prefix settlementBatchSummary

The following endpoints can be invoked with the prefix settlementBatchSummary as follows:

 

braintree://settlementBatchSummary/endpoint?[options]
EndpointShorthand AliasOptionsResult Body Type

generate

 

 request

com.braintreegateway.Result<com.braintreegateway.SettlementBatchSummary>

URI Options for settlementBatchSummary

NameType

settlementDate

Calendar

groupByCustomField

String

54.5.15. Endpoint prefix subscription

The following endpoints can be invoked with the prefix subscription as follows:

 

braintree://subscription/endpoint?[options]
EndpointShorthand AliasOptionsResult Body Type

cancel

 

 id

 com.braintreegateway.Result<com.braintreegateway.Subscription>

create

 

request

com.braintreegateway.Result<com.braintreegateway.Subscription>

delete

 

customerId, id

com.braintreegateway.Result<com.braintreegateway.Subscription>

find

 

id

com.braintreegateway.Subscription

retryCharge

 

subscriptionId, amount

com.braintreegateway.Result<com.braintreegateway.Transaction>

search

 

searchRequest

com.braintreegateway.ResourceCollection<com.braintreegateway.Subscription>

update

 

id, request

com.braintreegateway.Result<com.braintreegateway.Subscription>

URI Options for subscription

NameType

id

String

request

com.braintreegateway.SubscriptionRequest

customerId

String

subscriptionId

String

amount

BigDecimal

searchRequest

com.braintreegateway.SubscriptionSearchRequest.

 

54.5.16. Endpoint prefix transaction

The following endpoints can be invoked with the prefix transaction as follows:

 

braintree://transaction/endpoint?[options]
EndpointShorthand AliasOptionsResult Body Type

cancelRelease

 

id

com.braintreegateway.Result<com.braintreegateway.Transaction>

cloneTransaction

 

id, cloneRequest

com.braintreegateway.Result<com.braintreegateway.Transaction>

credit

 

request

com.braintreegateway.Result<com.braintreegateway.Transaction>

find

 

id

com.braintreegateway.Transaction

holdInEscrow

 

id

com.braintreegateway.Result<com.braintreegateway.Transaction>

releaseFromEscrow

 

id

com.braintreegateway.Result<com.braintreegateway.Transaction>

refund

 

id, amount, refundRequest

com.braintreegateway.Result<com.braintreegateway.Transaction>

sale

 

request

com.braintreegateway.Result<com.braintreegateway.Transaction>

search

 

query

com.braintreegateway.ResourceCollection<com.braintreegateway.Transaction>

submitForPartialSettlement

 

id, amount

com.braintreegateway.Result<com.braintreegateway.Transaction>

submitForSettlement

 

id, amount, request

com.braintreegateway.Result<com.braintreegateway.Transaction>

voidTransaction

 

id

com.braintreegateway.Result<com.braintreegateway.Transaction>

URI Options for transaction

NameType

id

String

request

com.braintreegateway.TransactionCloneRequest

cloneRequest

com.braintreegateway.TransactionCloneRequest

refundRequest

com.braintreegateway.TransactionRefundRequest

amount

BigDecimal

query

com.braintreegateway.TransactionSearchRequest

54.5.17. Endpoint prefix webhookNotification

The following endpoints can be invoked with the prefix webhookNotification as follows:

 

braintree://webhookNotification/endpoint?[options]
EndpointShorthand AliasOptionsResult Body Type

parse

 

 signature, payload

com.braintreegateway.WebhookNotification

verify

 

challenge

String

URI Options for webhookNotification

NameType

signature

String

payload

String

challenge

String

 

54.6. Consumer Endpoints

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. 

54.7. Message Headers

Any URI option can be provided in a message header for producer endpoints with a CamelBraintree. prefix.

54.8. Message body

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.

 

 

54.9. Examples

Blueprint

<?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>

54.10. See Also

* Configuring Camel * Component * Endpoint * Getting Started

 

 

Red Hat logoGithubRedditYoutubeTwitter

Lernen

Testen, kaufen und verkaufen

Communitys

Über Red Hat Dokumentation

Wir helfen Red Hat Benutzern, mit unseren Produkten und Diensten innovativ zu sein und ihre Ziele zu erreichen – mit Inhalten, denen sie vertrauen können.

Mehr Inklusion in Open Source

Red Hat hat sich verpflichtet, problematische Sprache in unserem Code, unserer Dokumentation und unseren Web-Eigenschaften zu ersetzen. Weitere Einzelheiten finden Sie in Red Hat Blog.

Über Red Hat

Wir liefern gehärtete Lösungen, die es Unternehmen leichter machen, plattform- und umgebungsübergreifend zu arbeiten, vom zentralen Rechenzentrum bis zum Netzwerkrand.

© 2024 Red Hat, Inc.