aligent/braintree-orocommerce
Install the Package
composer require aligent/braintree-orocommerce
Clear Cache & Run Migrations
php bin/console cache:clear --env=prod
php bin/console oro:migration:load --force --env=prod
Install & Build Assets
php bin/console assets:install --env=prod
php bin/console oro:assets:build --env=prod
Configure Braintree Integration
Merchant IDPublic KeyPrivate KeyEnvironment (sandbox/live)Create a Payment Rule
Test in Checkout
Checkout Flow Integration
BraintreeActionInterface.assets:build).Transaction Lifecycle
// Example event listener for custom data
public function onBraintreePurchase(BraintreePaymentActionEvent $event) {
$event->getPayload()->setCustomField('order_id', $event->getOrder()->getId());
}
Purchase is supported).Multi-Instance Support
Fraud Protection
Custom Fields
Extend the payload via the BraintreePaymentActionEvent:
# config/services.yaml
services:
App\EventListener\BraintreeCustomDataListener:
tags:
- { name: kernel.event_listener, event: aligent_braintree.payment_action.purchase, method: onPurchase }
Single-Page Checkout (SPC) Ensure the Drop-In UI is properly initialized before submission (fixed in v4.1.1). Use:
braintree.dropin.create({
authorization: 'YOUR_TOKEN',
container: '#braintree-container'
}, (err, dropinInstance) => {
// Handle submission
});
Testing
4111 1111 1111 1111 (success), 4000 0000 0000 0002 (decline).Asset Compilation Failures
npm install in web/bundles/braintreeorocommerce and rebuild:
php bin/console oro:assets:build --env=prod
Configuration Overrides
Merchant ID/Public Key pairs.Fraud Protection Conflicts
Drop-In UI Teardown
var/log/prod.log for Braintree API errors (e.g., invalid credentials)./braintree/payment endpoints).dump() in event listeners to inspect payloads:
public function onPurchase(BraintreePaymentActionEvent $event) {
dump($event->getPayload()->getData());
}
Custom Payment Actions
Implement BraintreeActionInterface and tag the service:
services:
App\Payment\Action\CustomBraintreeAction:
tags:
- { name: braintree.action, action: custom_action }
Event Listeners
Extend the aligent_braintree.payment_action.purchase event to modify payloads:
// src/EventListener/CustomBraintreeListener.php
public function __invoke(BraintreePaymentActionEvent $event) {
$event->getPayload()->setCustomField('app_metadata', ['user_id' => 123]);
}
Frontend Customization Override the Drop-In UI template:
templates/braintree/dropin.html.twig to your theme.Environment (sandbox/live) matches your Braintree account settings.composer require braintree/braintree_php:^6.24 if needed.How can I help you explore Laravel packages today?