Иногда BrainTree не может найти клиента впервые!ПОЧЕМУ? - PullRequest
0 голосов
/ 25 сентября 2019

У меня есть приведенная ниже привязка кода, сегодня произошла странная вещь, и именно тогда я впервые захотел получить идентификатор клиента для примера email@host.com, когда Customer::search() Braintree вернул пустую коллекцию, и когда я попыталсяво второй раз был получен фактический идентификатор пользователя (как показано на изображении ниже).

class BraintreeController {
    // [...]
    /**
     * search customers based on email
     * @param  string $email the customer email
     * @return mixed  returns a collection of Customer response objects.
     * @link https://developers.braintreepayments.com/reference/request/customer/search/php
     */
    public function search_customer($email) {
        // search based on customer's email
        return $this->_gateway->customer()->search([ \Braintree\CustomerSearch::email()->is($email) ]);
    }
    /**
     * fetches a customer's ID based on its email
     * @param  string $email the customer email
     * @return integer return the customer's ID if any found; o.w. returns false
     */
    public function get_customer_id($email) {
        // search based on customer's email
        $collection = $this->search_customer($email);
        // fetch the first customer's ID it found
        foreach ($collection as $customer) return $customer->id;
        // return false if nothing found
        return false;
    }
    // [...]
}

enter image description here

Вопросы:

  1. Почему это произошло?
  2. Есть ли у Брэйнтри механизм кэширования, вызывающий такое поведение?
  3. Как предотвратить это?
...