Code Duplication    Length = 14-16 lines in 3 locations

src/Payment/MerchantPay/API.php 1 location

@@ 122-135 (lines=14) @@
119
     *
120
     * @return \EasyWeChat\Support\Collection
121
     */
122
    protected function request($api, array $params, $method = 'post')
123
    {
124
        $params = array_filter($params);
125
        $params['nonce_str'] = uniqid();
126
        $params['sign'] = \EasyWeChat\Payment\generate_sign($params, $this->merchant->key, 'md5');
127
128
        $options = [
129
            'body' => XML::build($params),
130
            'cert' => $this->merchant->get('cert_path'),
131
            'ssl_key' => $this->merchant->get('key_path'),
132
        ];
133
134
        return $this->parseResponse($this->getHttp()->request($api, $method, $options));
135
    }
136
137
    /**
138
     * Parse Response XML to array.

src/Payment/LuckyMoney/API.php 1 location

@@ 187-201 (lines=15) @@
184
     *
185
     * @return \EasyWeChat\Support\Collection
186
     */
187
    protected function request($api, array $params, $method = 'post')
188
    {
189
        $params = array_filter($params);
190
        $params['mch_id'] = $this->merchant->merchant_id;
191
        $params['nonce_str'] = uniqid();
192
        $params['sign'] = \EasyWeChat\Payment\generate_sign($params, $this->merchant->key, 'md5');
193
194
        $options = [
195
            'body' => XML::build($params),
196
            'cert' => $this->merchant->get('cert_path'),
197
            'ssl_key' => $this->merchant->get('key_path'),
198
        ];
199
200
        return $this->parseResponse($this->getHttp()->request($api, $method, $options));
201
    }
202
203
    /**
204
     * Parse Response XML to array.

src/Payment/CashCoupon/API.php 1 location

@@ 126-141 (lines=16) @@
123
     *
124
     * @return \EasyWeChat\Support\Collection
125
     */
126
    protected function request($api, array $params, $method = 'post')
127
    {
128
        $params = array_filter($params);
129
        $params['mch_id'] = $this->merchant->merchant_id;
130
        $params['appid'] = $this->merchant->app_id;
131
        $params['nonce_str'] = uniqid();
132
        $params['sign'] = \EasyWeChat\Payment\generate_sign($params, $this->merchant->key, 'md5');
133
134
        $options = [
135
            'body' => XML::build($params),
136
            'cert' => $this->merchant->get('cert_path'),
137
            'ssl_key' => $this->merchant->get('key_path'),
138
        ];
139
140
        return $this->parseResponse($this->getHttp()->request($api, $method, $options));
141
    }
142
143
    /**
144
     * Parse Response XML to array.