1

I transaction state is not getting updated at Magento when it changes at Braintree. I manually want to get the transaction status from Braintree but unable to call the Braintree method in my custom module. Any sugesstion how can I call Braintree method and get the status of transaction?

$gateway->transaction()->search([
  Braintree_TransactionSearch::status()->is(Braintree_Transaction::SETTLED)
]);

I want to call this method.

  • Add what you have untill now – vitoriodachef May 31 '18 at 14:16
  • That is what I need to know. I have created a helper already but in that I am unable to get the instance of Braintree Adapter. – akshay billore Jun 1 '18 at 5:57
2

Somethink like this

namespace Vendore\ModuleName\Helper\Braintree;
use Magento\Braintree\Model\Adapter\BraintreeAdapterFactory;
use Magento\Braintree\Model\Adapter\BraintreeSearchAdapter;


class Status extends AbstractHelper {

    private $braintreeAdapterFactory;
    /**
     * @var BraintreeSearchAdapter
     */
    private $braintreeSearchAdapter;

    /**
     * Status constructor.
     * @param BraintreeAdapterFactory $braintreeAdapterFactory
     * @param BraintreeSearchAdapter $braintreeSearchAdapter
     */
    public function __construct(
        BraintreeAdapterFactory $braintreeAdapterFactory,
        BraintreeSearchAdapter $braintreeSearchAdapter
        ) {
        $this->braintreeAdapterFactory = $braintreeAdapterFactory;
        $this->braintreeSearchAdapter = $braintreeSearchAdapter;
    }

    /**
     * @param $transactionId
     * @return mixed
     */
    public function get($transactionId)
    {
        $braintreeAdapter = $this->braintreeAdapterFactory->create();
        $collection = $braintreeAdapter->search(
            [
            $this->braintreeSearchAdapter->id()->is($transactionId)
            ]
            );

        //add some check if we got correct response
        //and  get status
        return $collection->firstItem()->status;
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.