Answers.Body: <p>Figured it out. For some reason, the braintree keys were not being loaded at the time before it started to post to Braintree. In Braintree.php I added the following</p>
  
  <pre><code> if (empty(Braintree_Configuration::environment())) {
    $environment = ($this-&gt;_mode == "test" ? 'sandbox' : 'production');
    Braintree_Configuration::environment($environment);
  }
  
  if (empty(Braintree_Configuration::merchantId())) {
    Braintree_Configuration::merchantId($this-&gt;_paymentProcessor["user_name"]);
  }
  
  if (empty(Braintree_Configuration::publicKey())) {
    Braintree_Configuration::publicKey($this-&gt;_paymentProcessor["password"]);
  }
  
  if (empty(Braintree_Configuration::privateKey())) {
    Braintree_Configuration::privateKey($this-&gt;_paymentProcessor["signature"]);
  }
  </code></pre>
  
  <p>Right before the following:</p>
  
  <pre><code>try {
    $result = Braintree_Transaction::sale($requestArray);
  } catch (Exception $e) {
    return self::error("Oops! Looks like there was problem. Payment Response: " . $e-&gt;getMessage());
  }
  </code></pre>
  
  <p>And it worked. I'm not entirely sure why the values weren't being loaded initially but this will do!</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-07T00:09:38.713Z
Answers.LastActivityDate: 2019-11-07T00:09:38.713Z
Answers.UserDisplayName: Frank Chau
Body: <p>I have a wordpress Civicrm instance and we are using Braintree as the payment processor. I'm trying to create a CiviEvent, selling tickets to an event. When I try to test payments out by submitting test payments, I get an error.</p>
  
  <pre><code>Looks like there was problem. Payment Response: Braintree\Configuration::merchantId needs to be set (or accessToken needs to be passed to Braintree\Gateway).:
  </code></pre>
  
  <p>The weird thing is, the merchantId and all the API keys are already defined. I made a test payment on a CiviContribute page and that worked just fine. I'm confused as to why it would work on one Civi module and not work on the other.</p>
  
  <p>Can anyone help advise me on how to fix this? Thanks.</p>
  
Tags: <civievent><payment-processor><payment>
Title: Braintree with Wordpress not working with CiviEvent
ThreadText: # Braintree with Wordpress not working with CiviEvent
  
  (Asked by: username_0 on 2019-06-06)
  
  I have a wordpress Civicrm instance and we are using Braintree as the payment processor. I'm trying to create a CiviEvent, selling tickets to an event. When I try to test payments out by submitting test payments, I get an error.
  Looks like there was problem. Payment Response: Braintree\Configuration::merchantId needs to be set (or accessToken needs to be passed to Braintree\Gateway).:
  
  The weird thing is, the merchantId and all the API keys are already defined. I made a test payment on a CiviContribute page and that worked just fine. I'm confused as to why it would work on one Civi module and not work on the other.
  Can anyone help advise me on how to fix this? Thanks.
  
  **Tags:** civievent, payment-processor, payment
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2019-11-07. Score: 2 | Accepted answer
  
  Figured it out. For some reason, the braintree keys were not being loaded at the time before it started to post to Braintree. In Braintree.php I added the following
   if (empty(Braintree_Configuration::environment())) {
    $environment = ($this->_mode == "test" ? 'sandbox' : 'production');
    Braintree_Configuration::environment($environment);
  }
  
  if (empty(Braintree_Configuration::merchantId())) {
    Braintree_Configuration::merchantId($this->_paymentProcessor["user_name"]);
  }
  
  if (empty(Braintree_Configuration::publicKey())) {
    Braintree_Configuration::publicKey($this->_paymentProcessor["password"]);
  }
  
  if (empty(Braintree_Configuration::privateKey())) {
    Braintree_Configuration::privateKey($this->_paymentProcessor["signature"]);
  }
  
  Right before the following:
  try {
    $result = Braintree_Transaction::sale($requestArray);
  } catch (Exception $e) {
    return self::error("Oops! Looks like there was problem. Payment Response: " . $e->getMessage());
  }
  
  And it worked. I'm not entirely sure why the values weren't being loaded initially but this will do!
  
  
  ---
  
  