Code Duplication    Length = 10-14 lines in 9 locations

catalog/includes/apps/braintree/lib/Braintree/CreditCardGateway.php 2 locations

@@ 151-164 (lines=14) @@
148
     * @return CreditCard
149
     * @throws Exception\NotFound
150
     */
151
    public function find($token)
152
    {
153
        $this->_validateId($token);
154
        try {
155
            $path = $this->_config->merchantPath() . '/payment_methods/credit_card/' . $token;
156
            $response = $this->_http->get($path);
157
            return CreditCard::factory($response['creditCard']);
158
        } catch (Exception\NotFound $e) {
159
            throw new Exception\NotFound(
160
                'credit card with token ' . $token . ' not found'
161
            );
162
        }
163
164
    }
165
166
    /**
167
     * Convert a payment method nonce to a credit card
@@ 174-187 (lines=14) @@
171
     * @return CreditCard
172
     * @throws Exception\NotFound
173
     */
174
    public function fromNonce($nonce)
175
    {
176
        $this->_validateId($nonce, "nonce");
177
        try {
178
            $path = $this->_config->merchantPath() . '/payment_methods/from_nonce/' . $nonce;
179
            $response = $this->_http->get($path);
180
            return CreditCard::factory($response['creditCard']);
181
        } catch (Exception\NotFound $e) {
182
            throw new Exception\NotFound(
183
                'credit card with nonce ' . $nonce . ' locked, consumed or not found'
184
            );
185
        }
186
187
    }
188
189
   /**
190
     * create a credit on the card for the passed transaction

catalog/includes/apps/braintree/lib/Braintree/CustomerGateway.php 1 location

@@ 196-208 (lines=13) @@
193
     * @return Customer|boolean The customer object or false if the request fails.
194
     * @throws Exception\NotFound
195
     */
196
    public function find($id)
197
    {
198
        $this->_validateId($id);
199
        try {
200
            $path = $this->_config->merchantPath() . '/customers/' . $id;
201
            $response = $this->_http->get($path);
202
            return Customer::factory($response['customer']);
203
        } catch (Exception\NotFound $e) {
204
            throw new Exception\NotFound(
205
            'customer with id ' . $id . ' not found'
206
            );
207
        }
208
    }
209
210
    /**
211
     * credit a customer for the passed transaction

catalog/includes/apps/braintree/lib/Braintree/MerchantAccountGateway.php 1 location

@@ 24-33 (lines=10) @@
21
        return $this->_doCreate('/merchant_accounts/create_via_api', ['merchant_account' => $attribs]);
22
    }
23
24
    public function find($merchant_account_id)
25
    {
26
        try {
27
            $path = $this->_config->merchantPath() . '/merchant_accounts/' . $merchant_account_id;
28
            $response = $this->_http->get($path);
29
            return MerchantAccount::factory($response['merchantAccount']);
30
        } catch (Exception\NotFound $e) {
31
            throw new Exception\NotFound('merchant account with id ' . $merchant_account_id . ' not found');
32
        }
33
    }
34
35
    public function update($merchant_account_id, $attributes)
36
    {

catalog/includes/apps/braintree/lib/Braintree/PaymentMethodNonceGateway.php 1 location

@@ 53-65 (lines=13) @@
50
     * @access public
51
     *
52
     */
53
    public function find($nonce)
54
    {
55
        try {
56
            $path = $this->_config->merchantPath() . '/payment_method_nonces/' . $nonce;
57
            $response = $this->_http->get($path);
58
            return PaymentMethodNonce::factory($response['paymentMethodNonce']);
59
        } catch (Exception\NotFound $e) {
60
            throw new Exception\NotFound(
61
            'payment method nonce with id ' . $nonce . ' not found'
62
            );
63
        }
64
65
    }
66
}
67
class_alias('Braintree\PaymentMethodNonceGateway', 'Braintree_PaymentMethodNonceGateway');
68

catalog/includes/apps/braintree/lib/Braintree/PayPalAccountGateway.php 1 location

@@ 47-60 (lines=14) @@
44
     * @return PayPalAccount
45
     * @throws Exception\NotFound
46
     */
47
    public function find($token)
48
    {
49
        $this->_validateId($token);
50
        try {
51
            $path = $this->_config->merchantPath() . '/payment_methods/paypal_account/' . $token;
52
            $response = $this->_http->get($path);
53
            return PayPalAccount::factory($response['paypalAccount']);
54
        } catch (Exception\NotFound $e) {
55
            throw new Exception\NotFound(
56
                'paypal account with token ' . $token . ' not found'
57
            );
58
        }
59
60
    }
61
62
    /**
63
     * updates the paypalAccount record

catalog/includes/apps/braintree/lib/Braintree/SubscriptionGateway.php 1 location

@@ 40-52 (lines=13) @@
37
        return $this->_verifyGatewayResponse($response);
38
    }
39
40
    public function find($id)
41
    {
42
        $this->_validateId($id);
43
44
        try {
45
            $path = $this->_config->merchantPath() . '/subscriptions/' . $id;
46
            $response = $this->_http->get($path);
47
            return Subscription::factory($response['subscription']);
48
        } catch (Exception\NotFound $e) {
49
            throw new Exception\NotFound('subscription with id ' . $id . ' not found');
50
        }
51
52
    }
53
54
    public function search($query)
55
    {

catalog/includes/apps/braintree/lib/Braintree/TransactionGateway.php 1 location

@@ 263-275 (lines=13) @@
260
     * @param string id
261
     * @return Transaction
262
     */
263
    public function find($id)
264
    {
265
        $this->_validateId($id);
266
        try {
267
            $path = $this->_config->merchantPath() . '/transactions/' . $id;
268
            $response = $this->_http->get($path);
269
            return Transaction::factory($response['transaction']);
270
        } catch (Exception\NotFound $e) {
271
            throw new Exception\NotFound(
272
            'transaction with id ' . $id . ' not found'
273
            );
274
        }
275
    }
276
    /**
277
     * new sale
278
     * @param array $attribs

catalog/includes/apps/braintree/lib/Braintree/UsBankAccountGateway.php 1 location

@@ 47-59 (lines=13) @@
44
     * @return UsBankAccount
45
     * @throws Exception\NotFound
46
     */
47
    public function find($token)
48
    {
49
        try {
50
            $path = $this->_config->merchantPath() . '/payment_methods/us_bank_account/' . $token;
51
            $response = $this->_http->get($path);
52
            return UsBankAccount::factory($response['usBankAccount']);
53
        } catch (Exception\NotFound $e) {
54
            throw new Exception\NotFound(
55
                'US bank account with token ' . $token . ' not found'
56
            );
57
        }
58
59
    }
60
61
    /**
62
     * create a new sale for the current UsBank account