6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
19 |
currency_name)); ?>
20 |
21 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/vendor/rmccue/requests/package.xml.tpl:
--------------------------------------------------------------------------------
1 |
2 |
8 | Requests
9 | pear.ryanmccue.info
10 | A HTTP library written in PHP, for human beings.
11 |
12 | Requests is a HTTP library written in PHP, for human beings. It is
13 | roughly based on the API from the excellent Requests Python library.
14 | Requests is ISC Licensed (similar to the new BSD license) and has
15 | no dependencies.
16 |
17 |
18 | Ryan McCue
19 | rmccue
20 | me+pear@ryanmccue dot info
21 | yes
22 |
23 | {{ date }}
24 |
25 |
26 | {{ version }}
27 | {{ api_version }}
28 |
29 |
30 | {{ stability }}
31 | {{ stability }}
32 |
33 | ISC
34 | -
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 | {{ files }}
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | 5.2.0
53 |
54 |
55 | 1.4.0
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/vendor/razorpay/razorpay/src/Payment.php:
--------------------------------------------------------------------------------
1 | getEntityUrl() . $this->id;
32 |
33 | return $this->request(Requests::PATCH, $url, $attributes);
34 | }
35 |
36 | /**
37 | * @param $id Payment id
38 | */
39 | public function refund($attributes = array())
40 | {
41 | $refund = new Refund;
42 |
43 | $attributes = array_merge($attributes, array('payment_id' => $this->id));
44 |
45 | return $refund->create($attributes);
46 | }
47 |
48 | /**
49 | * @param $id Payment id
50 | */
51 | public function capture($attributes = array())
52 | {
53 | $relativeUrl = $this->getEntityUrl() . $this->id . '/capture';
54 |
55 | return $this->request('POST', $relativeUrl, $attributes);
56 | }
57 |
58 | public function transfer($attributes = array())
59 | {
60 | $relativeUrl = $this->getEntityUrl() . $this->id . '/transfers';
61 |
62 | return $this->request('POST', $relativeUrl, $attributes);
63 | }
64 |
65 | public function refunds()
66 | {
67 | $refund = new Refund;
68 |
69 | $options = array('payment_id' => $this->id);
70 |
71 | return $refund->all($options);
72 | }
73 |
74 | public function transfers()
75 | {
76 | $transfer = new Transfer();
77 |
78 | $transfer->payment_id = $this->id;
79 |
80 | return $transfer->all();
81 | }
82 |
83 | public function bankTransfer()
84 | {
85 | $relativeUrl = $this->getEntityUrl() . $this->id . '/bank_transfer';
86 |
87 | return $this->request('GET', $relativeUrl);
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/vendor/rmccue/requests/library/Requests/Auth/Basic.php:
--------------------------------------------------------------------------------
1 | user, $this->pass) = $args;
46 | }
47 | }
48 |
49 | /**
50 | * Register the necessary callbacks
51 | *
52 | * @see curl_before_send
53 | * @see fsockopen_header
54 | * @param Requests_Hooks $hooks Hook system
55 | */
56 | public function register(Requests_Hooks &$hooks) {
57 | $hooks->register('curl.before_send', array(&$this, 'curl_before_send'));
58 | $hooks->register('fsockopen.after_headers', array(&$this, 'fsockopen_header'));
59 | }
60 |
61 | /**
62 | * Set cURL parameters before the data is sent
63 | *
64 | * @param resource $handle cURL resource
65 | */
66 | public function curl_before_send(&$handle) {
67 | curl_setopt($handle, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
68 | curl_setopt($handle, CURLOPT_USERPWD, $this->getAuthString());
69 | }
70 |
71 | /**
72 | * Add extra headers to the request before sending
73 | *
74 | * @param string $out HTTP header string
75 | */
76 | public function fsockopen_header(&$out) {
77 | $out .= sprintf("Authorization: Basic %s\r\n", base64_encode($this->getAuthString()));
78 | }
79 |
80 | /**
81 | * Get the authentication string (user:pass)
82 | *
83 | * @return string
84 | */
85 | public function getAuthString() {
86 | return $this->user . ':' . $this->pass;
87 | }
88 | }
--------------------------------------------------------------------------------
/vendor/rmccue/requests/LICENSE:
--------------------------------------------------------------------------------
1 | Requests
2 | ========
3 |
4 | Copyright (c) 2010-2012 Ryan McCue and contributors
5 |
6 | Permission to use, copy, modify, and/or distribute this software for any
7 | purpose with or without fee is hereby granted, provided that the above
8 | copyright notice and this permission notice appear in all copies.
9 |
10 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 |
18 |
19 | ComplexPie IRI Parser
20 | =====================
21 |
22 | Copyright (c) 2007-2010, Geoffrey Sneddon and Steve Minutillo.
23 | All rights reserved.
24 |
25 | Redistribution and use in source and binary forms, with or without
26 | modification, are permitted provided that the following conditions are met:
27 |
28 | * Redistributions of source code must retain the above copyright notice,
29 | this list of conditions and the following disclaimer.
30 |
31 | * Redistributions in binary form must reproduce the above copyright notice,
32 | this list of conditions and the following disclaimer in the documentation
33 | and/or other materials provided with the distribution.
34 |
35 | * Neither the name of the SimplePie Team nor the names of its contributors
36 | may be used to endorse or promote products derived from this software
37 | without specific prior written permission.
38 |
39 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
40 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
42 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
43 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
44 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
45 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
46 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
47 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
49 | POSSIBILITY OF SUCH DAMAGE.
50 |
--------------------------------------------------------------------------------
/vendor/razorpay/razorpay/src/Utility.php:
--------------------------------------------------------------------------------
1 | hashEquals($expectedSignature, $actualSignature);
55 | }
56 |
57 | if ($verified === false)
58 | {
59 | throw new Errors\SignatureVerificationError(
60 | 'Invalid signature passed');
61 | }
62 | }
63 |
64 | private function hashEquals($expectedSignature, $actualSignature)
65 | {
66 | if (strlen($expectedSignature) === strlen($actualSignature))
67 | {
68 | $res = $expectedSignature ^ $actualSignature;
69 | $return = 0;
70 |
71 | for ($i = strlen($res) - 1; $i >= 0; $i--)
72 | {
73 | $return |= ord($res[$i]);
74 | }
75 |
76 | return ($return === 0);
77 | }
78 |
79 | return false;
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/vendor/rmccue/requests/library/Requests/Response/Headers.php:
--------------------------------------------------------------------------------
1 | data[$key])) {
29 | return null;
30 | }
31 |
32 | return $this->flatten($this->data[$key]);
33 | }
34 |
35 | /**
36 | * Set the given item
37 | *
38 | * @throws Requests_Exception On attempting to use dictionary as list (`invalidset`)
39 | *
40 | * @param string $key Item name
41 | * @param string $value Item value
42 | */
43 | public function offsetSet($key, $value) {
44 | if ($key === null) {
45 | throw new Requests_Exception('Object is a dictionary, not a list', 'invalidset');
46 | }
47 |
48 | $key = strtolower($key);
49 |
50 | if (!isset($this->data[$key])) {
51 | $this->data[$key] = array();
52 | }
53 |
54 | $this->data[$key][] = $value;
55 | }
56 |
57 | /**
58 | * Get all values for a given header
59 | *
60 | * @param string $key
61 | * @return array Header values
62 | */
63 | public function getValues($key) {
64 | $key = strtolower($key);
65 | if (!isset($this->data[$key])) {
66 | return null;
67 | }
68 |
69 | return $this->data[$key];
70 | }
71 |
72 | /**
73 | * Flattens a value into a string
74 | *
75 | * Converts an array into a string by imploding values with a comma, as per
76 | * RFC2616's rules for folding headers.
77 | *
78 | * @param string|array $value Value to flatten
79 | * @return string Flattened value
80 | */
81 | public function flatten($value) {
82 | if (is_array($value)) {
83 | $value = implode(',', $value);
84 | }
85 |
86 | return $value;
87 | }
88 |
89 | /**
90 | * Get an iterator for the data
91 | *
92 | * Converts the internal
93 | * @return ArrayIterator
94 | */
95 | public function getIterator() {
96 | return new Requests_Utility_FilteredIterator($this->data, array($this, 'flatten'));
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/vendor/rmccue/requests/library/Requests/Utility/CaseInsensitiveDictionary.php:
--------------------------------------------------------------------------------
1 | $value) {
30 | $this->offsetSet($key, $value);
31 | }
32 | }
33 |
34 | /**
35 | * Check if the given item exists
36 | *
37 | * @param string $key Item key
38 | * @return boolean Does the item exist?
39 | */
40 | public function offsetExists($key) {
41 | $key = strtolower($key);
42 | return isset($this->data[$key]);
43 | }
44 |
45 | /**
46 | * Get the value for the item
47 | *
48 | * @param string $key Item key
49 | * @return string Item value
50 | */
51 | public function offsetGet($key) {
52 | $key = strtolower($key);
53 | if (!isset($this->data[$key])) {
54 | return null;
55 | }
56 |
57 | return $this->data[$key];
58 | }
59 |
60 | /**
61 | * Set the given item
62 | *
63 | * @throws Requests_Exception On attempting to use dictionary as list (`invalidset`)
64 | *
65 | * @param string $key Item name
66 | * @param string $value Item value
67 | */
68 | public function offsetSet($key, $value) {
69 | if ($key === null) {
70 | throw new Requests_Exception('Object is a dictionary, not a list', 'invalidset');
71 | }
72 |
73 | $key = strtolower($key);
74 | $this->data[$key] = $value;
75 | }
76 |
77 | /**
78 | * Unset the given header
79 | *
80 | * @param string $key
81 | */
82 | public function offsetUnset($key) {
83 | unset($this->data[strtolower($key)]);
84 | }
85 |
86 | /**
87 | * Get an iterator for the data
88 | *
89 | * @return ArrayIterator
90 | */
91 | public function getIterator() {
92 | return new ArrayIterator($this->data);
93 | }
94 |
95 | /**
96 | * Get the headers as an array
97 | *
98 | * @return array Header data
99 | */
100 | public function getAll() {
101 | return $this->data;
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/vendor/rmccue/requests/tests/Auth/Basic.php:
--------------------------------------------------------------------------------
1 | markTestSkipped($transport . ' is not available');
18 | return;
19 | }
20 |
21 | $options = array(
22 | 'auth' => array('user', 'passwd'),
23 | 'transport' => $transport,
24 | );
25 | $request = Requests::get(httpbin('/basic-auth/user/passwd'), array(), $options);
26 | $this->assertEquals(200, $request->status_code);
27 |
28 | $result = json_decode($request->body);
29 | $this->assertEquals(true, $result->authenticated);
30 | $this->assertEquals('user', $result->user);
31 | }
32 |
33 | /**
34 | * @dataProvider transportProvider
35 | */
36 | public function testUsingInstantiation($transport) {
37 | if (!call_user_func(array($transport, 'test'))) {
38 | $this->markTestSkipped($transport . ' is not available');
39 | return;
40 | }
41 |
42 | $options = array(
43 | 'auth' => new Requests_Auth_Basic(array('user', 'passwd')),
44 | 'transport' => $transport,
45 | );
46 | $request = Requests::get(httpbin('/basic-auth/user/passwd'), array(), $options);
47 | $this->assertEquals(200, $request->status_code);
48 |
49 | $result = json_decode($request->body);
50 | $this->assertEquals(true, $result->authenticated);
51 | $this->assertEquals('user', $result->user);
52 | }
53 |
54 | /**
55 | * @dataProvider transportProvider
56 | */
57 | public function testPOSTUsingInstantiation($transport) {
58 | if (!call_user_func(array($transport, 'test'))) {
59 | $this->markTestSkipped($transport . ' is not available');
60 | return;
61 | }
62 |
63 | $options = array(
64 | 'auth' => new Requests_Auth_Basic(array('user', 'passwd')),
65 | 'transport' => $transport,
66 | );
67 | $data = 'test';
68 | $request = Requests::post(httpbin('/post'), array(), $data, $options);
69 | $this->assertEquals(200, $request->status_code);
70 |
71 | $result = json_decode($request->body);
72 |
73 | $auth = $result->headers->Authorization;
74 | $auth = explode(' ', $auth);
75 |
76 | $this->assertEquals(base64_encode('user:passwd'), $auth[1]);
77 | $this->assertEquals('test', $result->data);
78 | }
79 |
80 | /**
81 | * @expectedException Requests_Exception
82 | */
83 | public function testMissingPassword() {
84 | $auth = new Requests_Auth_Basic(array('user'));
85 | }
86 |
87 | }
--------------------------------------------------------------------------------
/vendor/rmccue/requests/tests/Encoding.php:
--------------------------------------------------------------------------------
1 | $set) {
66 | $real_set = self::mapData($key, $set);
67 | $data = array_merge($data, $real_set);
68 | }
69 | return $data;
70 | }
71 |
72 | /**
73 | * @dataProvider encodedData
74 | */
75 | public function testDecompress($original, $encoded) {
76 | $decoded = Requests::decompress($encoded);
77 | $this->assertEquals($original, $decoded);
78 | }
79 |
80 | /**
81 | * @dataProvider encodedData
82 | */
83 | public function testCompatibleInflate($original, $encoded) {
84 | $decoded = Requests::compatible_gzinflate($encoded);
85 | $this->assertEquals($original, $decoded);
86 | }
87 |
88 | protected function bin2hex($field) {
89 | $field = bin2hex($field);
90 | $field = chunk_split($field,2,"\\x");
91 | $field = "\\x" . substr($field,0,-2);
92 | return $field;
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/vendor/rmccue/requests/docs/usage-advanced.md:
--------------------------------------------------------------------------------
1 | Advanced Usage
2 | ==============
3 |
4 | Session Handling
5 | ----------------
6 | Making multiple requests to the same site with similar options can be a pain,
7 | since you end up repeating yourself. The Session object can be used to set
8 | default parameters for these.
9 |
10 | Let's simulate communicating with GitHub.
11 |
12 | ```php
13 | $session = new Requests_Session('https://api.github.com/');
14 | $session->headers['X-ContactAuthor'] = 'rmccue';
15 | $session->useragent = 'My-Awesome-App';
16 |
17 | $response = $session->get('/zen');
18 | ```
19 |
20 | You can use the `url`, `headers`, `data` and `options` properties of the Session
21 | object to set the defaults for this session, and the constructor also takes
22 | parameters in the same order as `Requests::request()`. Accessing any other
23 | properties will set the corresponding key in the options array; that is:
24 |
25 | ```php
26 | // Setting the property...
27 | $session->useragent = 'My-Awesome-App';
28 |
29 | // ...is the same as setting the option
30 | $session->options['useragent'] = 'My-Awesome-App';
31 | ```
32 |
33 |
34 | Secure Requests with SSL
35 | ------------------------
36 | By default, HTTPS requests will use the most secure options available:
37 |
38 | ```php
39 | $response = Requests::get('https://httpbin.org/');
40 | ```
41 |
42 | Requests bundles certificates from the [Mozilla certificate authority list][],
43 | which is the same list of root certificates used in most browsers. If you're
44 | accessing sites with certificates from other CAs, or self-signed certificates,
45 | you can point Requests to a custom CA list in PEM form (the same format
46 | accepted by cURL and OpenSSL):
47 |
48 | ```php
49 | $options = array(
50 | 'verify' => '/path/to/cacert.pem'
51 | );
52 | $response = Requests::get('https://httpbin.org/', array(), $options);
53 | ```
54 |
55 | Alternatively, if you want to disable verification completely, this is possible
56 | with `'verify' => false`, but note that this is extremely insecure and should be
57 | avoided.
58 |
59 | ### Security Note
60 | Requests supports SSL across both cURL and fsockopen in a transparent manner.
61 | Unlike other PHP HTTP libraries, support for verifying the certificate name is
62 | built-in; that is, a request for `https://github.com/` will actually verify the
63 | certificate's name even with the fsockopen transport. This makes Requests the
64 | first and currently only PHP HTTP library that supports full SSL verification.
65 |
66 | (Note that WordPress now also supports this verification, thanks to efforts by
67 | the Requests development team.)
68 |
69 | (See also the [related PHP][php-bug-47030] and [OpenSSL-related][php-bug-55820]
70 | bugs in PHP for more information on Subject Alternate Name field.)
71 |
72 | [Mozilla certificate authority list]: http://www.mozilla.org/projects/security/certs/
73 | [php-bug-47030]: https://bugs.php.net/bug.php?id=47030
74 | [php-bug-55820]:https://bugs.php.net/bug.php?id=55820
75 |
--------------------------------------------------------------------------------
/vendor/razorpay/razorpay/src/Invoice.php:
--------------------------------------------------------------------------------
1 | getEntityUrl() . $this->id . '/cancel';
58 |
59 | return $this->request(Requests::POST, $url);
60 | }
61 |
62 | /**
63 | * Send/re-send notification for invoice by given medium
64 | *
65 | * @param $medium - sms|email
66 | *
67 | * @return array
68 | */
69 | public function notifyBy($medium)
70 | {
71 | $url = $this->getEntityUrl() . $this->id . '/notify_by/' . $medium;
72 | $r = new Request();
73 |
74 | return $r->request(Requests::POST, $url);
75 | }
76 |
77 | /**
78 | * Patches given invoice with new attributes
79 | *
80 | * @param array $attributes
81 | *
82 | * @return Invoice
83 | */
84 | public function edit($attributes = array())
85 | {
86 | $url = $this->getEntityUrl() . $this->id;
87 |
88 | return $this->request(Requests::PATCH, $url, $attributes);
89 | }
90 |
91 | /**
92 | * Issues drafted invoice
93 | *
94 | * @return Invoice
95 | */
96 | public function issue()
97 | {
98 | $url = $this->getEntityUrl() . $this->id . '/issue';
99 |
100 | return $this->request(Requests::POST, $url);
101 | }
102 |
103 | /**
104 | * Deletes drafted invoice
105 | *
106 | * @return Invoice
107 | */
108 | public function delete()
109 | {
110 | $url = $this->getEntityUrl() . $this->id;
111 | $r = new Request();
112 |
113 | return $r->request(Requests::DELETE, $url);
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/vendor/rmccue/requests/docs/hooks.md:
--------------------------------------------------------------------------------
1 | Hooks
2 | =====
3 | Requests has a hook system that you can use to manipulate parts of the request
4 | process along with internal transport hooks.
5 |
6 | Check out the [API documentation for `Requests_Hooks`][requests_hooks] for more
7 | information on how to use the hook system.
8 |
9 | Available Hooks
10 | ---------------
11 |
12 | * `requests.before_request`
13 |
14 | Alter the request before it's sent to the transport.
15 |
16 | Parameters: `string &$url`, `array &$headers`, `array|string &$data`,
17 | `string &$type`, `array &$options`
18 |
19 | * `requests.before_parse`
20 |
21 | Alter the raw HTTP response before parsing
22 |
23 | Parameters: `string &$response`
24 |
25 | * `requests.after_request`
26 |
27 | Alter the response object before it's returned to the user
28 |
29 | Parameters: `Requests_Response &$return`
30 |
31 | * `curl.before_request`
32 |
33 | Set cURL options before the transport sets any (note that Requests may
34 | override these)
35 |
36 | Parameters: `cURL resource &$fp`
37 |
38 | * `curl.before_send`
39 |
40 | Set cURL options just before the request is actually sent via `curl_exec`
41 |
42 | Parameters: `cURL resource &$fp`
43 |
44 | * `curl.after_request`
45 |
46 | Alter the raw HTTP response before returning for parsing
47 |
48 | Parameters: `string &$response, array &$info`
49 |
50 | `$info` contains the associated array as defined in [curl-getinfo-returnvalues](http://php.net/manual/en/function.curl-getinfo.php#refsect1-function.curl-getinfo-returnvalues)
51 |
52 | * `fsockopen.before_request`
53 |
54 | Run events before the transport does anything
55 |
56 | * `fsockopen.after_headers`
57 |
58 | Add extra headers before the body begins (i.e. before `\r\n\r\n`)
59 |
60 | Parameters: `string &$out`
61 |
62 | * `fsockopen.before_send`
63 |
64 | Add body data before sending the request
65 |
66 | Parameters: `string &$out`
67 |
68 | * `fsockopen.after_send`
69 |
70 | Run events after writing the data to the socket
71 |
72 | * `fsockopen.after_request`
73 |
74 | Alter the raw HTTP response before returning for parsing
75 |
76 | Parameters: `string &$response, array &$info`
77 |
78 | `$info` contains the associated array as defined in [stream-get-meta-data-returnvalues](http://php.net/manual/en/function.stream-get-meta-data.php#refsect1-function.stream-get-meta-data-returnvalues)
79 |
80 |
81 | Registering Hooks
82 | -----------------
83 | Note: if you're doing this in an authentication handler, see the [Custom
84 | Authentication guide][authentication-custom] instead.
85 |
86 | [authentication-custom]: authentication-custom.md
87 |
88 | In order to register your own hooks, you need to instantiate `Requests_hooks`
89 | and pass this in via the 'hooks' option.
90 |
91 | ```php
92 | $hooks = new Requests_Hooks();
93 | $hooks->register('requests.after_request', 'mycallback');
94 |
95 | $request = Requests::get('http://httpbin.org/get', array(), array('hooks' => $hooks));
96 | ```
97 |
--------------------------------------------------------------------------------
/controllers/Razorpay.php:
--------------------------------------------------------------------------------
1 | load->model('invoices_model');
20 | $invoice = $this->invoices_model->get($id);
21 | $language = load_client_language($invoice->clientid);
22 |
23 | $data['invoice'] = $invoice;
24 |
25 | $contact = is_client_logged_in() ? $this->clients_model->get_contact(get_contact_user_id()) : null;
26 |
27 | $data['order_id'] = $this->input->get('order_id');
28 | $data['total'] = $this->input->get('total');
29 | $data['name'] = $contact ? $contact->firstname . ' ' . $contact->lastname : '';
30 | $data['email'] = $contact ? $contact->email : '';
31 | $data['phonenumber'] = $contact ? $contact->phonenumber : '';
32 | $data['key_id'] = $this->razor_pay_gateway->getSetting('key_id');
33 | $data['description'] = str_replace(
34 | '{invoice_number}',
35 | format_invoice_number($invoice->id),
36 | $this->razor_pay_gateway->getSetting('description_dashboard')
37 | );
38 |
39 | $this->app_css->add('razorpay-css', module_dir_url('razorpay', 'assets/style.css'), PAYMENT_GATEWAYS_ASSETS_GROUP);
40 |
41 | $this->load->view('pay', $data);
42 | }
43 |
44 | /**
45 | * Endpoint for after the Razorpay checkout.js form is submitted
46 | *
47 | * @param string $id invoice id
48 | * @param string $hash invoice hash
49 | *
50 | * @return mixed
51 | */
52 | public function success($id, $hash)
53 | {
54 | check_invoice_restrictions($id, $hash);
55 |
56 | $this->load->model('invoices_model');
57 | $invoice = $this->invoices_model->get($id);
58 | $language = load_client_language($invoice->clientid);
59 |
60 | $payment_id = $this->input->post('razorpay_payment_id');
61 | $order_id = $this->input->post('razorpay_order_id');
62 | $signature = $this->input->post('razorpay_signature');
63 |
64 | $result = $this->razor_pay_gateway->verifyPayment($signature, $payment_id, $order_id);
65 |
66 | if ($result['success'] === false) {
67 | set_alert('warning', $result['error']);
68 | } else {
69 | // After verification, record the payment in database
70 | $result = $this->razor_pay_gateway->recordPayment($order_id, $payment_id, $invoice);
71 |
72 | if ($result['success'] === false) {
73 | set_alert('warning', $result['error']);
74 | } else {
75 | set_alert('success', $result['message']);
76 | }
77 | }
78 |
79 | redirect(site_url('invoice/' . $id . '/' . $hash));
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/vendor/rmccue/requests/tests/IDNAEncoder.php:
--------------------------------------------------------------------------------
1 | assertEquals($expected, $result);
23 | }
24 |
25 | /**
26 | * @expectedException Requests_Exception
27 | */
28 | public function testASCIITooLong() {
29 | $data = str_repeat("abcd", 20);
30 | $result = Requests_IDNAEncoder::encode($data);
31 | }
32 |
33 | /**
34 | * @expectedException Requests_Exception
35 | */
36 | public function testEncodedTooLong() {
37 | $data = str_repeat("\xe4\xbb\x96", 60);
38 | $result = Requests_IDNAEncoder::encode($data);
39 | }
40 |
41 | /**
42 | * @expectedException Requests_Exception
43 | */
44 | public function testAlreadyPrefixed() {
45 | $result = Requests_IDNAEncoder::encode("xn--\xe4\xbb\x96");
46 | }
47 |
48 | public function testASCIICharacter() {
49 | $result = Requests_IDNAEncoder::encode("a");
50 | $this->assertEquals('a', $result);
51 | }
52 |
53 | public function testTwoByteCharacter() {
54 | $result = Requests_IDNAEncoder::encode("\xc2\xb6"); // Pilcrow character
55 | $this->assertEquals('xn--tba', $result);
56 | }
57 |
58 | public function testThreeByteCharacter() {
59 | $result = Requests_IDNAEncoder::encode("\xe2\x82\xac"); // Euro symbol
60 | $this->assertEquals('xn--lzg', $result);
61 | }
62 |
63 | public function testFourByteCharacter() {
64 | $result = Requests_IDNAEncoder::encode("\xf0\xa4\xad\xa2"); // Chinese symbol?
65 | $this->assertEquals('xn--ww6j', $result);
66 | }
67 |
68 | /**
69 | * @expectedException Requests_Exception
70 | */
71 | public function testFiveByteCharacter() {
72 | $result = Requests_IDNAEncoder::encode("\xfb\xb6\xb6\xb6\xb6");
73 | }
74 |
75 | /**
76 | * @expectedException Requests_Exception
77 | */
78 | public function testSixByteCharacter() {
79 | $result = Requests_IDNAEncoder::encode("\xfd\xb6\xb6\xb6\xb6\xb6");
80 | }
81 |
82 | /**
83 | * @expectedException Requests_Exception
84 | */
85 | public function testInvalidASCIICharacterWithMultibyte() {
86 | $result = Requests_IDNAEncoder::encode("\0\xc2\xb6");
87 | }
88 |
89 | /**
90 | * @expectedException Requests_Exception
91 | */
92 | public function testUnfinishedMultibyte() {
93 | $result = Requests_IDNAEncoder::encode("\xc2");
94 | }
95 |
96 | /**
97 | * @expectedException Requests_Exception
98 | */
99 | public function testPartialMultibyte() {
100 | $result = Requests_IDNAEncoder::encode("\xc2\xc2\xb6");
101 | }
102 | }
--------------------------------------------------------------------------------
/vendor/rmccue/requests/library/Requests/Response.php:
--------------------------------------------------------------------------------
1 | headers = new Requests_Response_Headers();
21 | $this->cookies = new Requests_Cookie_Jar();
22 | }
23 |
24 | /**
25 | * Response body
26 | *
27 | * @var string
28 | */
29 | public $body = '';
30 |
31 | /**
32 | * Raw HTTP data from the transport
33 | *
34 | * @var string
35 | */
36 | public $raw = '';
37 |
38 | /**
39 | * Headers, as an associative array
40 | *
41 | * @var Requests_Response_Headers Array-like object representing headers
42 | */
43 | public $headers = array();
44 |
45 | /**
46 | * Status code, false if non-blocking
47 | *
48 | * @var integer|boolean
49 | */
50 | public $status_code = false;
51 |
52 | /**
53 | * Protocol version, false if non-blocking
54 | * @var float|boolean
55 | */
56 | public $protocol_version = false;
57 |
58 | /**
59 | * Whether the request succeeded or not
60 | *
61 | * @var boolean
62 | */
63 | public $success = false;
64 |
65 | /**
66 | * Number of redirects the request used
67 | *
68 | * @var integer
69 | */
70 | public $redirects = 0;
71 |
72 | /**
73 | * URL requested
74 | *
75 | * @var string
76 | */
77 | public $url = '';
78 |
79 | /**
80 | * Previous requests (from redirects)
81 | *
82 | * @var array Array of Requests_Response objects
83 | */
84 | public $history = array();
85 |
86 | /**
87 | * Cookies from the request
88 | *
89 | * @var Requests_Cookie_Jar Array-like object representing a cookie jar
90 | */
91 | public $cookies = array();
92 |
93 | /**
94 | * Is the response a redirect?
95 | *
96 | * @return boolean True if redirect (3xx status), false if not.
97 | */
98 | public function is_redirect() {
99 | $code = $this->status_code;
100 | return in_array($code, array(300, 301, 302, 303, 307)) || $code > 307 && $code < 400;
101 | }
102 |
103 | /**
104 | * Throws an exception if the request was not successful
105 | *
106 | * @throws Requests_Exception If `$allow_redirects` is false, and code is 3xx (`response.no_redirects`)
107 | * @throws Requests_Exception_HTTP On non-successful status code. Exception class corresponds to code (e.g. {@see Requests_Exception_HTTP_404})
108 | * @param boolean $allow_redirects Set to false to throw on a 3xx as well
109 | */
110 | public function throw_for_status($allow_redirects = true) {
111 | if ($this->is_redirect()) {
112 | if (!$allow_redirects) {
113 | throw new Requests_Exception('Redirection not allowed', 'response.no_redirects', $this);
114 | }
115 | }
116 | elseif (!$this->success) {
117 | $exception = Requests_Exception_HTTP::get_class($this->status_code);
118 | throw new $exception(null, $this);
119 | }
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/vendor/rmccue/requests/tests/ChunkedEncoding.php:
--------------------------------------------------------------------------------
1 | body = $body;
39 | $transport->chunked = true;
40 |
41 | $options = array(
42 | 'transport' => $transport
43 | );
44 | $response = Requests::get('http://example.com/', array(), $options);
45 |
46 | $this->assertEquals($expected, $response->body);
47 | }
48 |
49 | public static function notChunkedProvider() {
50 | return array(
51 | 'invalid chunk size' => array( 'Hello! This is a non-chunked response!' ),
52 | 'invalid chunk extension' => array( '1BNot chunked\r\nLooks chunked but it is not\r\n' ),
53 | 'unquoted chunk-ext-val with space' => array( "02;foo=unquoted with space\r\nab\r\n04\r\nra\nc\r\n06\r\nadabra\r\n0c\r\n\nall we got\n" ),
54 | 'unquoted chunk-ext-val with forbidden character' => array( "02;foo={unquoted}\r\nab\r\n04\r\nra\nc\r\n06\r\nadabra\r\n0c\r\n\nall we got\n" ),
55 | 'invalid chunk-ext-name' => array( "02;{foo}=bar\r\nab\r\n04\r\nra\nc\r\n06\r\nadabra\r\n0c\r\n\nall we got\n" ),
56 | 'incomplete quote for chunk-ext-value' => array( "02;foo=\"no end quote\r\nab\r\n04\r\nra\nc\r\n06\r\nadabra\r\n0c\r\n\nall we got\n" ),
57 | );
58 | }
59 |
60 | /**
61 | * Response says it's chunked, but actually isn't
62 | * @dataProvider notChunkedProvider
63 | */
64 | public function testNotActuallyChunked($body) {
65 | $transport = new MockTransport();
66 | $transport->body = $body;
67 | $transport->chunked = true;
68 |
69 | $options = array(
70 | 'transport' => $transport
71 | );
72 | $response = Requests::get('http://example.com/', array(), $options);
73 |
74 | $this->assertEquals($transport->body, $response->body);
75 | }
76 |
77 |
78 | /**
79 | * Response says it's chunked and starts looking like it is, but turns out
80 | * that they're lying to us
81 | */
82 | public function testMixedChunkiness() {
83 | $transport = new MockTransport();
84 | $transport->body = "02\r\nab\r\nNot actually chunked!";
85 | $transport->chunked = true;
86 |
87 | $options = array(
88 | 'transport' => $transport
89 | );
90 | $response = Requests::get('http://example.com/', array(), $options);
91 | $this->assertEquals($transport->body, $response->body);
92 | }
93 | }
--------------------------------------------------------------------------------
/vendor/rmccue/requests/tests/SSL.php:
--------------------------------------------------------------------------------
1 | assertTrue(Requests_SSL::match_domain($base, $dnsname));
39 | }
40 |
41 | /**
42 | * @dataProvider domainNoMatchProvider
43 | */
44 | public function testNoMatch($base, $dnsname) {
45 | $this->assertFalse(Requests_SSL::match_domain($base, $dnsname));
46 | }
47 |
48 | protected function fakeCertificate($dnsname, $with_san = true) {
49 | $certificate = array(
50 | 'subject' => array(
51 | 'CN' => $dnsname
52 | ),
53 | );
54 |
55 | if ($with_san !== false) {
56 | // If SAN is set to true, default it to the dNSName
57 | if ($with_san === true) {
58 | $with_san = $dnsname;
59 | }
60 | $certificate['extensions'] = array(
61 | 'subjectAltName' => 'DNS: ' . $with_san,
62 | );
63 | }
64 |
65 | return $certificate;
66 | }
67 |
68 | /**
69 | * @dataProvider domainMatchProvider
70 | */
71 | public function testMatchViaCertificate($base, $dnsname) {
72 | $certificate = $this->fakeCertificate($dnsname);
73 | $this->assertTrue(Requests_SSL::verify_certificate($base, $certificate));
74 | }
75 |
76 | /**
77 | * @dataProvider domainNoMatchProvider
78 | */
79 | public function testNoMatchViaCertificate($base, $dnsname) {
80 | $certificate = $this->fakeCertificate($dnsname);
81 | $this->assertFalse(Requests_SSL::verify_certificate($base, $certificate));
82 | }
83 |
84 | public function testCNFallback() {
85 | $certificate = $this->fakeCertificate('example.com', false);
86 | $this->assertTrue(Requests_SSL::verify_certificate('example.com', $certificate));
87 | }
88 |
89 | public function testInvalidCNFallback() {
90 | $certificate = $this->fakeCertificate('example.com', false);
91 | $this->assertFalse(Requests_SSL::verify_certificate('example.net', $certificate));
92 | }
93 |
94 | /**
95 | * Test a certificate with both CN and SAN fields
96 | *
97 | * As per RFC2818, if the SAN field exists, we should parse that and ignore
98 | * the value of the CN field.
99 | *
100 | * @link http://tools.ietf.org/html/rfc2818#section-3.1
101 | */
102 | public function testIgnoreCNWithSAN() {
103 | $certificate = $this->fakeCertificate('example.net', 'example.com');
104 |
105 | $this->assertTrue(Requests_SSL::verify_certificate('example.com', $certificate), 'Checking SAN validation');
106 | $this->assertFalse(Requests_SSL::verify_certificate('example.net', $certificate), 'Checking CN non-validation');
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/vendor/composer/installed.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "razorpay/razorpay",
4 | "version": "2.5.0",
5 | "version_normalized": "2.5.0.0",
6 | "source": {
7 | "type": "git",
8 | "url": "https://github.com/razorpay/razorpay-php.git",
9 | "reference": "96c0167176cf53e3da15640622e9b993a3450ec7"
10 | },
11 | "dist": {
12 | "type": "zip",
13 | "url": "https://api.github.com/repos/razorpay/razorpay-php/zipball/96c0167176cf53e3da15640622e9b993a3450ec7",
14 | "reference": "96c0167176cf53e3da15640622e9b993a3450ec7",
15 | "shasum": ""
16 | },
17 | "require": {
18 | "ext-json": "*",
19 | "php": ">=5.3.0",
20 | "rmccue/requests": "v1.7.0"
21 | },
22 | "require-dev": {
23 | "phpunit/phpunit": "~4.8|~5.0",
24 | "raveren/kint": "1.*"
25 | },
26 | "time": "2019-05-20T13:15:50+00:00",
27 | "type": "library",
28 | "installation-source": "dist",
29 | "autoload": {
30 | "psr-4": {
31 | "Razorpay\\Api\\": "src/",
32 | "Razorpay\\Tests\\": "tests/"
33 | }
34 | },
35 | "notification-url": "https://packagist.org/downloads/",
36 | "license": [
37 | "MIT"
38 | ],
39 | "authors": [
40 | {
41 | "name": "Abhay Rana",
42 | "email": "nemo@razorpay.com",
43 | "homepage": "https://captnemo.in",
44 | "role": "Developer"
45 | },
46 | {
47 | "name": "Shashank Kumar",
48 | "email": "shashank@razorpay.com",
49 | "role": "Developer"
50 | }
51 | ],
52 | "description": "Razorpay PHP Client Library",
53 | "homepage": "https://docs.razorpay.com",
54 | "keywords": [
55 | "api",
56 | "client",
57 | "php",
58 | "razorpay"
59 | ]
60 | },
61 | {
62 | "name": "rmccue/requests",
63 | "version": "v1.7.0",
64 | "version_normalized": "1.7.0.0",
65 | "source": {
66 | "type": "git",
67 | "url": "https://github.com/rmccue/Requests.git",
68 | "reference": "87932f52ffad70504d93f04f15690cf16a089546"
69 | },
70 | "dist": {
71 | "type": "zip",
72 | "url": "https://api.github.com/repos/rmccue/Requests/zipball/87932f52ffad70504d93f04f15690cf16a089546",
73 | "reference": "87932f52ffad70504d93f04f15690cf16a089546",
74 | "shasum": ""
75 | },
76 | "require": {
77 | "php": ">=5.2"
78 | },
79 | "require-dev": {
80 | "requests/test-server": "dev-master"
81 | },
82 | "time": "2016-10-13T00:11:37+00:00",
83 | "type": "library",
84 | "installation-source": "dist",
85 | "autoload": {
86 | "psr-0": {
87 | "Requests": "library/"
88 | }
89 | },
90 | "notification-url": "https://packagist.org/downloads/",
91 | "license": [
92 | "ISC"
93 | ],
94 | "authors": [
95 | {
96 | "name": "Ryan McCue",
97 | "homepage": "http://ryanmccue.info"
98 | }
99 | ],
100 | "description": "A HTTP library written in PHP, for human beings.",
101 | "homepage": "http://github.com/rmccue/Requests",
102 | "keywords": [
103 | "curl",
104 | "fsockopen",
105 | "http",
106 | "idna",
107 | "ipv6",
108 | "iri",
109 | "sockets"
110 | ]
111 | }
112 | ]
113 |
--------------------------------------------------------------------------------
/vendor/rmccue/requests/tests/Proxy/HTTP.php:
--------------------------------------------------------------------------------
1 | markTestSkipped('Proxy not available');
17 | }
18 | }
19 |
20 | public function transportProvider() {
21 | return array(
22 | array('Requests_Transport_cURL'),
23 | array('Requests_Transport_fsockopen'),
24 | );
25 | }
26 |
27 | /**
28 | * @dataProvider transportProvider
29 | */
30 | public function testConnectWithString($transport) {
31 | $this->checkProxyAvailable();
32 |
33 | $options = array(
34 | 'proxy' => REQUESTS_HTTP_PROXY,
35 | 'transport' => $transport,
36 | );
37 | $response = Requests::get(httpbin('/get'), array(), $options);
38 | $this->assertEquals('http', $response->headers['x-requests-proxied']);
39 |
40 | $data = json_decode($response->body, true);
41 | $this->assertEquals('http', $data['headers']['x-requests-proxy']);
42 | }
43 |
44 | /**
45 | * @dataProvider transportProvider
46 | */
47 | public function testConnectWithArray($transport) {
48 | $this->checkProxyAvailable();
49 |
50 | $options = array(
51 | 'proxy' => array(REQUESTS_HTTP_PROXY),
52 | 'transport' => $transport,
53 | );
54 | $response = Requests::get(httpbin('/get'), array(), $options);
55 | $this->assertEquals('http', $response->headers['x-requests-proxied']);
56 |
57 | $data = json_decode($response->body, true);
58 | $this->assertEquals('http', $data['headers']['x-requests-proxy']);
59 | }
60 |
61 | /**
62 | * @dataProvider transportProvider
63 | * @expectedException Requests_Exception
64 | */
65 | public function testConnectInvalidParameters($transport) {
66 | $this->checkProxyAvailable();
67 |
68 | $options = array(
69 | 'proxy' => array(REQUESTS_HTTP_PROXY, 'testuser', 'password', 'something'),
70 | 'transport' => $transport,
71 | );
72 | $response = Requests::get(httpbin('/get'), array(), $options);
73 | }
74 |
75 | /**
76 | * @dataProvider transportProvider
77 | */
78 | public function testConnectWithInstance($transport) {
79 | $this->checkProxyAvailable();
80 |
81 | $options = array(
82 | 'proxy' => new Requests_Proxy_HTTP(REQUESTS_HTTP_PROXY),
83 | 'transport' => $transport,
84 | );
85 | $response = Requests::get(httpbin('/get'), array(), $options);
86 | $this->assertEquals('http', $response->headers['x-requests-proxied']);
87 |
88 | $data = json_decode($response->body, true);
89 | $this->assertEquals('http', $data['headers']['x-requests-proxy']);
90 | }
91 |
92 | /**
93 | * @dataProvider transportProvider
94 | */
95 | public function testConnectWithAuth($transport) {
96 | $this->checkProxyAvailable('auth');
97 |
98 | $options = array(
99 | 'proxy' => array(
100 | REQUESTS_HTTP_PROXY_AUTH,
101 | REQUESTS_HTTP_PROXY_AUTH_USER,
102 | REQUESTS_HTTP_PROXY_AUTH_PASS
103 | ),
104 | 'transport' => $transport,
105 | );
106 | $response = Requests::get(httpbin('/get'), array(), $options);
107 | $this->assertEquals(200, $response->status_code);
108 | $this->assertEquals('http', $response->headers['x-requests-proxied']);
109 |
110 | $data = json_decode($response->body, true);
111 | $this->assertEquals('http', $data['headers']['x-requests-proxy']);
112 | }
113 |
114 | /**
115 | * @dataProvider transportProvider
116 | */
117 | public function testConnectWithInvalidAuth($transport) {
118 | $this->checkProxyAvailable('auth');
119 |
120 | $options = array(
121 | 'proxy' => array(
122 | REQUESTS_HTTP_PROXY_AUTH,
123 | REQUESTS_HTTP_PROXY_AUTH_USER . '!',
124 | REQUESTS_HTTP_PROXY_AUTH_PASS . '!'
125 | ),
126 | 'transport' => $transport,
127 | );
128 | $response = Requests::get(httpbin('/get'), array(), $options);
129 | $this->assertEquals(407, $response->status_code);
130 | }
131 | }
132 |
--------------------------------------------------------------------------------
/vendor/rmccue/requests/library/Requests/Proxy/HTTP.php:
--------------------------------------------------------------------------------
1 | proxy = $args;
60 | }
61 | elseif (is_array($args)) {
62 | if (count($args) == 1) {
63 | list($this->proxy) = $args;
64 | }
65 | elseif (count($args) == 3) {
66 | list($this->proxy, $this->user, $this->pass) = $args;
67 | $this->use_authentication = true;
68 | }
69 | else {
70 | throw new Requests_Exception('Invalid number of arguments', 'proxyhttpbadargs');
71 | }
72 | }
73 | }
74 |
75 | /**
76 | * Register the necessary callbacks
77 | *
78 | * @since 1.6
79 | * @see curl_before_send
80 | * @see fsockopen_remote_socket
81 | * @see fsockopen_remote_host_path
82 | * @see fsockopen_header
83 | * @param Requests_Hooks $hooks Hook system
84 | */
85 | public function register(Requests_Hooks &$hooks) {
86 | $hooks->register('curl.before_send', array(&$this, 'curl_before_send'));
87 |
88 | $hooks->register('fsockopen.remote_socket', array(&$this, 'fsockopen_remote_socket'));
89 | $hooks->register('fsockopen.remote_host_path', array(&$this, 'fsockopen_remote_host_path'));
90 | if ($this->use_authentication) {
91 | $hooks->register('fsockopen.after_headers', array(&$this, 'fsockopen_header'));
92 | }
93 | }
94 |
95 | /**
96 | * Set cURL parameters before the data is sent
97 | *
98 | * @since 1.6
99 | * @param resource $handle cURL resource
100 | */
101 | public function curl_before_send(&$handle) {
102 | curl_setopt($handle, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
103 | curl_setopt($handle, CURLOPT_PROXY, $this->proxy);
104 |
105 | if ($this->use_authentication) {
106 | curl_setopt($handle, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
107 | curl_setopt($handle, CURLOPT_PROXYUSERPWD, $this->get_auth_string());
108 | }
109 | }
110 |
111 | /**
112 | * Alter remote socket information before opening socket connection
113 | *
114 | * @since 1.6
115 | * @param string $remote_socket Socket connection string
116 | */
117 | public function fsockopen_remote_socket(&$remote_socket) {
118 | $remote_socket = $this->proxy;
119 | }
120 |
121 | /**
122 | * Alter remote path before getting stream data
123 | *
124 | * @since 1.6
125 | * @param string $path Path to send in HTTP request string ("GET ...")
126 | * @param string $url Full URL we're requesting
127 | */
128 | public function fsockopen_remote_host_path(&$path, $url) {
129 | $path = $url;
130 | }
131 |
132 | /**
133 | * Add extra headers to the request before sending
134 | *
135 | * @since 1.6
136 | * @param string $out HTTP header string
137 | */
138 | public function fsockopen_header(&$out) {
139 | $out .= sprintf("Proxy-Authorization: Basic %s\r\n", base64_encode($this->get_auth_string()));
140 | }
141 |
142 | /**
143 | * Get the authentication string (user:pass)
144 | *
145 | * @since 1.6
146 | * @return string
147 | */
148 | public function get_auth_string() {
149 | return $this->user . ':' . $this->pass;
150 | }
151 | }
--------------------------------------------------------------------------------
/vendor/rmccue/requests/docs/usage.md:
--------------------------------------------------------------------------------
1 | Usage
2 | =====
3 |
4 | Ready to go? Make sure you have Requests installed before attempting any of the
5 | steps in this guide.
6 |
7 |
8 | Loading Requests
9 | ----------------
10 | Before we can load Requests up, we'll need to make sure it's loaded. This is a
11 | simple two-step:
12 |
13 | ```php
14 | // First, include Requests
15 | include('/path/to/library/Requests.php');
16 |
17 | // Next, make sure Requests can load internal classes
18 | Requests::register_autoloader();
19 | ```
20 |
21 | If you'd like to bring along your own autoloader, you can forget about this
22 | completely.
23 |
24 |
25 | Make a GET Request
26 | ------------------
27 | One of the most basic things you can do with HTTP is make a GET request.
28 |
29 | Let's grab GitHub's public timeline:
30 |
31 | ```php
32 | $response = Requests::get('https://github.com/timeline.json');
33 | ```
34 |
35 | `$response` is now a **Requests_Response** object. Response objects are what
36 | you'll be working with whenever you want to get data back from your request.
37 |
38 |
39 | Using the Response Object
40 | -------------------------
41 | Now that we have the response from GitHub, let's get the body of the response.
42 |
43 | ```php
44 | var_dump($response->body);
45 | // string(42865) "[{"repository":{"url":"...
46 | ```
47 |
48 |
49 | Custom Headers
50 | --------------
51 | If you want to add custom headers to the request, simply pass them in as an
52 | associative array as the second parameter:
53 |
54 | ```php
55 | $response = Requests::get('https://github.com/timeline.json', array('X-Requests' => 'Is Awesome!'));
56 | ```
57 |
58 |
59 | Make a POST Request
60 | -------------------
61 | Making a POST request is very similar to making a GET:
62 |
63 | ```php
64 | $response = Requests::post('http://httpbin.org/post');
65 | ```
66 |
67 | You'll probably also want to pass in some data. You can pass in either a
68 | string, an array or an object (Requests uses [`http_build_query`][build_query]
69 | internally) as the third parameter (after the URL and headers):
70 |
71 | [build_query]: http://php.net/http_build_query
72 |
73 | ```php
74 | $data = array('key1' => 'value1', 'key2' => 'value2');
75 | $response = Requests::post('http://httpbin.org/post', array(), $data);
76 | var_dump($response->body);
77 | ```
78 |
79 | This gives the output:
80 |
81 | string(503) "{
82 | "origin": "124.191.162.147",
83 | "files": {},
84 | "form": {
85 | "key2": "value2",
86 | "key1": "value1"
87 | },
88 | "headers": {
89 | "Content-Length": "23",
90 | "Accept-Encoding": "deflate;q=1.0, compress;q=0.5, gzip;q=0.5",
91 | "X-Forwarded-Port": "80",
92 | "Connection": "keep-alive",
93 | "User-Agent": "php-requests/1.6-dev",
94 | "Host": "httpbin.org",
95 | "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
96 | },
97 | "url": "http://httpbin.org/post",
98 | "args": {},
99 | "data": ""
100 | }"
101 |
102 | To send raw data, simply pass in a string instead. You'll probably also want to
103 | set the Content-Type header to ensure the remote server knows what you're
104 | sending it:
105 |
106 | ```php
107 | $url = 'https://api.github.com/some/endpoint';
108 | $headers = array('Content-Type' => 'application/json');
109 | $data = array('some' => 'data');
110 | $response = Requests::post($url, $headers, json_encode($data));
111 | ```
112 |
113 | Note that if you don't manually specify a Content-Type header, Requests has
114 | undefined behaviour for the header. It may be set to various values depending
115 | on the internal execution path, so it's recommended to set this explicitly if
116 | you need to.
117 |
118 |
119 | Status Codes
120 | ------------
121 | The Response object also gives you access to the status code:
122 |
123 | ```php
124 | var_dump($response->status_code);
125 | // int(200)
126 | ```
127 |
128 | You can also easily check if this status code is a success code, or if it's an
129 | error:
130 |
131 | ```php
132 | var_dump($response->success);
133 | // bool(true)
134 | ```
135 |
136 |
137 | Response Headers
138 | ----------------
139 | We can also grab headers pretty easily:
140 |
141 | ```php
142 | var_dump($response->headers['Date']);
143 | // string(29) "Thu, 09 Feb 2012 15:22:06 GMT"
144 | ```
145 |
146 | Note that this is case-insensitive, so the following are all equivalent:
147 |
148 | * `$response->headers['Date']`
149 | * `$response->headers['date']`
150 | * `$response->headers['DATE']`
151 | * `$response->headers['dAtE']`
152 |
153 | If a header isn't set, this will give `null`. You can also check with
154 | `isset($response->headers['date'])`
155 |
--------------------------------------------------------------------------------
/composer.lock:
--------------------------------------------------------------------------------
1 | {
2 | "_readme": [
3 | "This file locks the dependencies of your project to a known state",
4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
5 | "This file is @generated automatically"
6 | ],
7 | "content-hash": "c03f4a4f5ecea74473fbe486d28b7b25",
8 | "packages": [
9 | {
10 | "name": "razorpay/razorpay",
11 | "version": "2.5.0",
12 | "source": {
13 | "type": "git",
14 | "url": "https://github.com/razorpay/razorpay-php.git",
15 | "reference": "96c0167176cf53e3da15640622e9b993a3450ec7"
16 | },
17 | "dist": {
18 | "type": "zip",
19 | "url": "https://api.github.com/repos/razorpay/razorpay-php/zipball/96c0167176cf53e3da15640622e9b993a3450ec7",
20 | "reference": "96c0167176cf53e3da15640622e9b993a3450ec7",
21 | "shasum": ""
22 | },
23 | "require": {
24 | "ext-json": "*",
25 | "php": ">=5.3.0",
26 | "rmccue/requests": "v1.7.0"
27 | },
28 | "require-dev": {
29 | "phpunit/phpunit": "~4.8|~5.0",
30 | "raveren/kint": "1.*"
31 | },
32 | "type": "library",
33 | "autoload": {
34 | "psr-4": {
35 | "Razorpay\\Api\\": "src/",
36 | "Razorpay\\Tests\\": "tests/"
37 | }
38 | },
39 | "notification-url": "https://packagist.org/downloads/",
40 | "license": [
41 | "MIT"
42 | ],
43 | "authors": [
44 | {
45 | "name": "Abhay Rana",
46 | "email": "nemo@razorpay.com",
47 | "homepage": "https://captnemo.in",
48 | "role": "Developer"
49 | },
50 | {
51 | "name": "Shashank Kumar",
52 | "email": "shashank@razorpay.com",
53 | "role": "Developer"
54 | }
55 | ],
56 | "description": "Razorpay PHP Client Library",
57 | "homepage": "https://docs.razorpay.com",
58 | "keywords": [
59 | "api",
60 | "client",
61 | "php",
62 | "razorpay"
63 | ],
64 | "time": "2019-05-20T13:15:50+00:00"
65 | },
66 | {
67 | "name": "rmccue/requests",
68 | "version": "v1.7.0",
69 | "source": {
70 | "type": "git",
71 | "url": "https://github.com/rmccue/Requests.git",
72 | "reference": "87932f52ffad70504d93f04f15690cf16a089546"
73 | },
74 | "dist": {
75 | "type": "zip",
76 | "url": "https://api.github.com/repos/rmccue/Requests/zipball/87932f52ffad70504d93f04f15690cf16a089546",
77 | "reference": "87932f52ffad70504d93f04f15690cf16a089546",
78 | "shasum": ""
79 | },
80 | "require": {
81 | "php": ">=5.2"
82 | },
83 | "require-dev": {
84 | "requests/test-server": "dev-master"
85 | },
86 | "type": "library",
87 | "autoload": {
88 | "psr-0": {
89 | "Requests": "library/"
90 | }
91 | },
92 | "notification-url": "https://packagist.org/downloads/",
93 | "license": [
94 | "ISC"
95 | ],
96 | "authors": [
97 | {
98 | "name": "Ryan McCue",
99 | "homepage": "http://ryanmccue.info"
100 | }
101 | ],
102 | "description": "A HTTP library written in PHP, for human beings.",
103 | "homepage": "http://github.com/rmccue/Requests",
104 | "keywords": [
105 | "curl",
106 | "fsockopen",
107 | "http",
108 | "idna",
109 | "ipv6",
110 | "iri",
111 | "sockets"
112 | ],
113 | "time": "2016-10-13T00:11:37+00:00"
114 | }
115 | ],
116 | "packages-dev": [],
117 | "aliases": [],
118 | "minimum-stability": "stable",
119 | "stability-flags": [],
120 | "prefer-stable": false,
121 | "prefer-lowest": false,
122 | "platform": [],
123 | "platform-dev": []
124 | }
125 |
--------------------------------------------------------------------------------
/vendor/rmccue/requests/library/Requests/Cookie/Jar.php:
--------------------------------------------------------------------------------
1 | cookies = $cookies;
30 | }
31 |
32 | /**
33 | * Normalise cookie data into a Requests_Cookie
34 | *
35 | * @param string|Requests_Cookie $cookie
36 | * @return Requests_Cookie
37 | */
38 | public function normalize_cookie($cookie, $key = null) {
39 | if ($cookie instanceof Requests_Cookie) {
40 | return $cookie;
41 | }
42 |
43 | return Requests_Cookie::parse($cookie, $key);
44 | }
45 |
46 | /**
47 | * Normalise cookie data into a Requests_Cookie
48 | *
49 | * @codeCoverageIgnore
50 | * @deprecated Use {@see Requests_Cookie_Jar::normalize_cookie}
51 | * @return Requests_Cookie
52 | */
53 | public function normalizeCookie($cookie, $key = null) {
54 | return $this->normalize_cookie($cookie, $key);
55 | }
56 |
57 | /**
58 | * Check if the given item exists
59 | *
60 | * @param string $key Item key
61 | * @return boolean Does the item exist?
62 | */
63 | public function offsetExists($key) {
64 | return isset($this->cookies[$key]);
65 | }
66 |
67 | /**
68 | * Get the value for the item
69 | *
70 | * @param string $key Item key
71 | * @return string Item value
72 | */
73 | public function offsetGet($key) {
74 | if (!isset($this->cookies[$key])) {
75 | return null;
76 | }
77 |
78 | return $this->cookies[$key];
79 | }
80 |
81 | /**
82 | * Set the given item
83 | *
84 | * @throws Requests_Exception On attempting to use dictionary as list (`invalidset`)
85 | *
86 | * @param string $key Item name
87 | * @param string $value Item value
88 | */
89 | public function offsetSet($key, $value) {
90 | if ($key === null) {
91 | throw new Requests_Exception('Object is a dictionary, not a list', 'invalidset');
92 | }
93 |
94 | $this->cookies[$key] = $value;
95 | }
96 |
97 | /**
98 | * Unset the given header
99 | *
100 | * @param string $key
101 | */
102 | public function offsetUnset($key) {
103 | unset($this->cookies[$key]);
104 | }
105 |
106 | /**
107 | * Get an iterator for the data
108 | *
109 | * @return ArrayIterator
110 | */
111 | public function getIterator() {
112 | return new ArrayIterator($this->cookies);
113 | }
114 |
115 | /**
116 | * Register the cookie handler with the request's hooking system
117 | *
118 | * @param Requests_Hooker $hooks Hooking system
119 | */
120 | public function register(Requests_Hooker $hooks) {
121 | $hooks->register('requests.before_request', array($this, 'before_request'));
122 | $hooks->register('requests.before_redirect_check', array($this, 'before_redirect_check'));
123 | }
124 |
125 | /**
126 | * Add Cookie header to a request if we have any
127 | *
128 | * As per RFC 6265, cookies are separated by '; '
129 | *
130 | * @param string $url
131 | * @param array $headers
132 | * @param array $data
133 | * @param string $type
134 | * @param array $options
135 | */
136 | public function before_request($url, &$headers, &$data, &$type, &$options) {
137 | if (!$url instanceof Requests_IRI) {
138 | $url = new Requests_IRI($url);
139 | }
140 |
141 | if (!empty($this->cookies)) {
142 | $cookies = array();
143 | foreach ($this->cookies as $key => $cookie) {
144 | $cookie = $this->normalize_cookie($cookie, $key);
145 |
146 | // Skip expired cookies
147 | if ($cookie->is_expired()) {
148 | continue;
149 | }
150 |
151 | if ($cookie->domain_matches($url->host)) {
152 | $cookies[] = $cookie->format_for_header();
153 | }
154 | }
155 |
156 | $headers['Cookie'] = implode('; ', $cookies);
157 | }
158 | }
159 |
160 | /**
161 | * Parse all cookies from a response and attach them to the response
162 | *
163 | * @var Requests_Response $response
164 | */
165 | public function before_redirect_check(Requests_Response &$return) {
166 | $url = $return->url;
167 | if (!$url instanceof Requests_IRI) {
168 | $url = new Requests_IRI($url);
169 | }
170 |
171 | $cookies = Requests_Cookie::parse_from_headers($return->headers, $url);
172 | $this->cookies = array_merge($this->cookies, $cookies);
173 | $return->cookies = $this;
174 | }
175 | }
--------------------------------------------------------------------------------
/vendor/rmccue/requests/library/Requests/SSL.php:
--------------------------------------------------------------------------------
1 | assertEquals(200, $request->status_code);
14 | }
15 |
16 | /**
17 | * Standard response header parsing
18 | */
19 | public function testHeaderParsing() {
20 | $transport = new RawTransport();
21 | $transport->data =
22 | "HTTP/1.0 200 OK\r\n".
23 | "Host: localhost\r\n".
24 | "Host: ambiguous\r\n".
25 | "Nospace:here\r\n".
26 | "Muchspace: there \r\n".
27 | "Empty:\r\n".
28 | "Empty2: \r\n".
29 | "Folded: one\r\n".
30 | "\ttwo\r\n".
31 | " three\r\n\r\n".
32 | "stop\r\n";
33 |
34 | $options = array(
35 | 'transport' => $transport
36 | );
37 | $response = Requests::get('http://example.com/', array(), $options);
38 | $expected = new Requests_Response_Headers();
39 | $expected['host'] = 'localhost,ambiguous';
40 | $expected['nospace'] = 'here';
41 | $expected['muchspace'] = 'there';
42 | $expected['empty'] = '';
43 | $expected['empty2'] = '';
44 | $expected['folded'] = 'one two three';
45 | foreach ($expected as $key => $value) {
46 | $this->assertEquals($value, $response->headers[$key]);
47 | }
48 |
49 | foreach ($response->headers as $key => $value) {
50 | $this->assertEquals($value, $expected[$key]);
51 | }
52 | }
53 |
54 | public function testProtocolVersionParsing() {
55 | $transport = new RawTransport();
56 | $transport->data =
57 | "HTTP/1.0 200 OK\r\n".
58 | "Host: localhost\r\n\r\n";
59 |
60 | $options = array(
61 | 'transport' => $transport
62 | );
63 |
64 | $response = Requests::get('http://example.com/', array(), $options);
65 | $this->assertEquals(1.0, $response->protocol_version);
66 | }
67 |
68 | public function testRawAccess() {
69 | $transport = new RawTransport();
70 | $transport->data =
71 | "HTTP/1.0 200 OK\r\n".
72 | "Host: localhost\r\n\r\n".
73 | "Test";
74 |
75 | $options = array(
76 | 'transport' => $transport
77 | );
78 | $response = Requests::get('http://example.com/', array(), $options);
79 | $this->assertEquals($transport->data, $response->raw);
80 | }
81 |
82 | /**
83 | * Headers with only \n delimiting should be treated as if they're \r\n
84 | */
85 | public function testHeaderOnlyLF() {
86 | $transport = new RawTransport();
87 | $transport->data = "HTTP/1.0 200 OK\r\nTest: value\nAnother-Test: value\r\n\r\n";
88 |
89 | $options = array(
90 | 'transport' => $transport
91 | );
92 | $response = Requests::get('http://example.com/', array(), $options);
93 | $this->assertEquals('value', $response->headers['test']);
94 | $this->assertEquals('value', $response->headers['another-test']);
95 | }
96 |
97 | /**
98 | * Check that invalid protocols are not accepted
99 | *
100 | * We do not support HTTP/0.9. If this is really an issue for you, file a
101 | * new issue, and update your server/proxy to support a proper protocol.
102 | *
103 | * @expectedException Requests_Exception
104 | */
105 | public function testInvalidProtocolVersion() {
106 | $transport = new RawTransport();
107 | $transport->data = "HTTP/0.9 200 OK\r\n\r\n
Test";
108 |
109 | $options = array(
110 | 'transport' => $transport
111 | );
112 | $response = Requests::get('http://example.com/', array(), $options);
113 | }
114 |
115 | /**
116 | * HTTP/0.9 also appears to use a single CRLF instead of two
117 | *
118 | * @expectedException Requests_Exception
119 | */
120 | public function testSingleCRLFSeparator() {
121 | $transport = new RawTransport();
122 | $transport->data = "HTTP/0.9 200 OK\r\n
Test";
123 |
124 | $options = array(
125 | 'transport' => $transport
126 | );
127 | $response = Requests::get('http://example.com/', array(), $options);
128 | }
129 |
130 | /**
131 | * @expectedException Requests_Exception
132 | */
133 | public function testInvalidStatus() {
134 | $transport = new RawTransport();
135 | $transport->data = "HTTP/1.1 OK\r\nTest: value\nAnother-Test: value\r\n\r\nTest";
136 |
137 | $options = array(
138 | 'transport' => $transport
139 | );
140 | $response = Requests::get('http://example.com/', array(), $options);
141 | }
142 |
143 | public function test30xWithoutLocation() {
144 | $transport = new MockTransport();
145 | $transport->code = 302;
146 |
147 | $options = array(
148 | 'transport' => $transport
149 | );
150 | $response = Requests::get('http://example.com/', array(), $options);
151 | $this->assertEquals(302, $response->status_code);
152 | $this->assertEquals(0, $response->redirects);
153 | }
154 |
155 | /**
156 | * @expectedException Requests_Exception
157 | */
158 | public function testTimeoutException() {
159 | $options = array('timeout' => 0.5);
160 | $response = Requests::get(httpbin('/delay/3'), array(), $options);
161 | }
162 | }
163 |
--------------------------------------------------------------------------------
/vendor/razorpay/razorpay/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | Changelog for Razorpay-PHP SDK. Follows [keepachangelog.com](https://keepachangelog.com/en/1.0.0/) for formatting.
4 |
5 | ## Unreleased
6 |
7 | ## [2.5.0][2.5.0] - 2019-05-20
8 |
9 | ### Added
10 |
11 | - Adds support for payment edit API [[#100](https://github.com/razorpay/razorpay-php/pull/100)]
12 |
13 | ## [2.4.0-beta][2.4.0-beta] - 2018-11-28
14 |
15 | ### Changed
16 |
17 | - Upgrades [requests](https://github.com/rmccue/Requests/) to v1.7. [[#89](https://github.com/razorpay/razorpay-php/pull/89)]
18 | - Enforces TLS1.1+ for all requests. Workaround for a bug in RHEL 6. [[#76](https://github.com/razorpay/razorpay-php/pull/76)]
19 |
20 | ## [2.3.0][2.3.0] - 2018-09-15
21 |
22 | ### Added
23 |
24 | - Add parameters to Subscription Cancel API
25 | - Support for fetching Settlements
26 |
27 | ## [2.2.1][2.2.1] - 2018-05-28
28 |
29 | ### Added
30 |
31 | - Support for fetching all customer entities
32 |
33 | ## [2.2.0][2.2.0] - 2017-10-23
34 |
35 | ### Added
36 |
37 | - Support for VirtualAccount entity
38 | - Support for Subscriptions
39 |
40 | ## [2.1.0][2.1.0] - 2017-10-10
41 |
42 | ### Added
43 |
44 | - Support for new actions(cancel, notifyBy, edit, issue, delete) on invoices
45 | - Removes PHP 5.3 from list of versions to test build against
46 |
47 | ## [2.0.2][2.0.2] - 2017-08-03
48 |
49 | ### Added
50 |
51 | - Support for creating and fetching Transfers
52 | - Support for creating Reversals on transfers
53 |
54 | ## [2.0.1][2.0.1] - 2017-07-31
55 |
56 | ### Fixed
57 |
58 | - Webhook signature verification
59 | - Conditional require of Request class
60 |
61 | ## [2.0.0][2.0.0] - 2017-03-07
62 |
63 | ### Added
64 |
65 | - Support for custom Application header
66 | - Support for card entity
67 | - Support for Webhook and Order Signature verification
68 | - Support for direct refund creation via Razorpay\Api\Refund::create()
69 | - Support for Utility functions via Razorpay\Api\Utility::verifyPaymentSignature and Razorpay\Api\Utility::verifyWebhookSignature
70 | - Support for case insensitive error codes
71 | - Support for 2xx HTTP status codes
72 |
73 | ### Changed
74 |
75 | - Razorpay\Api\Payment::refunds() now returns a Razorpay\Api\Collection object instead of Razorpay\Api\Refund object
76 | - Razorpay\Api\Api::$baseUrl, Razorpay\Api\Api::$key and Razorpay\Api\Api::$secret are now `protected` instead of `public`
77 |
78 | ## [1.2.9][1.2.9] - 2017-01-03
79 |
80 | ### Added
81 |
82 | - Support for creating and fetching Invoices
83 |
84 | ## [1.2.8][1.2.8] - 2016-10-12
85 |
86 | ### Added
87 |
88 | - Support for Customer and Token entities
89 |
90 | ## [1.2.7][1.2.7] - 2016-09-21
91 |
92 | ### Added
93 |
94 | - Increases the request timeout to 30 seconds for all requests.
95 |
96 | ## [1.2.6][1.2.6] - 2016-03-28
97 |
98 | ### Added
99 |
100 | - Adds better tracing when client is not able to recognize server response.
101 |
102 | ## [1.2.5][1.2.5] - 2016-03-28
103 |
104 | ### Added
105 |
106 | - Add support for overriding request headers via setHeader
107 |
108 | ## [1.2.3][1.2.3] - 2016-02-24
109 |
110 | ### Added
111 |
112 | - Add support for Orders
113 |
114 | ## [1.2.2][1.2.2] - 2016-02-17
115 |
116 | ### Changed
117 |
118 | - Razorpay\Api\Request::checkErrors is now `protected` instead of `private`
119 | - The final build is now leaner and includes just requests, instead of entire vendor directory
120 |
121 | ## [1.2.1][1.2.1] - 2016-01-21
122 |
123 | ### Added
124 |
125 | - Add version.txt in release with current git tag
126 | - This changelog file
127 | - `Api\Request::getHeaders()` method
128 |
129 | ## [1.2.0][1.2.0] - 2015-10-23
130 |
131 | ### Added
132 |
133 | - Add version string to User Agent
134 |
135 | ### Changed
136 |
137 | - New release process that pushes pre-packaged zip files to GitHub
138 |
139 | ## 1.0.0 - 2015-01-18
140 |
141 | ### Added
142 |
143 | - Initial Release
144 |
145 | [unreleased]: https://github.com/razorpay/razorpay-php/compare/2.5.0...HEAD
146 | [1.2.1]: https://github.com/razorpay/razorpay-php/compare/1.2.0...1.2.1
147 | [1.2.0]: https://github.com/razorpay/razorpay-php/compare/1.1.0...1.2.0
148 | [1.2.2]: https://github.com/razorpay/razorpay-php/compare/1.2.1...1.2.2
149 | [1.2.3]: https://github.com/razorpay/razorpay-php/compare/1.2.2...1.2.3
150 | [1.2.4]: https://github.com/razorpay/razorpay-php/compare/1.2.3...1.2.4
151 | [1.2.5]: https://github.com/razorpay/razorpay-php/compare/1.2.4...1.2.5
152 | [1.2.6]: https://github.com/razorpay/razorpay-php/compare/1.2.5...1.2.6
153 | [1.2.7]: https://github.com/razorpay/razorpay-php/compare/1.2.6...1.2.7
154 | [1.2.8]: https://github.com/razorpay/razorpay-php/compare/1.2.7...1.2.8
155 | [1.2.9]: https://github.com/razorpay/razorpay-php/compare/1.2.8...1.2.9
156 | [2.0.0]: https://github.com/razorpay/razorpay-php/compare/1.2.9...2.0.0
157 | [2.0.1]: https://github.com/razorpay/razorpay-php/compare/2.0.0...2.0.1
158 | [2.0.2]: https://github.com/razorpay/razorpay-php/compare/2.0.1...2.0.2
159 | [2.1.0]: https://github.com/razorpay/razorpay-php/compare/2.0.2...2.1.0
160 | [2.2.0]: https://github.com/razorpay/razorpay-php/compare/2.1.0...2.2.0
161 | [2.2.1]: https://github.com/razorpay/razorpay-php/compare/2.2.0...2.2.1
162 | [2.3.0]: https://github.com/razorpay/razorpay-php/compare/2.2.1...2.3.0
163 | [2.4.0-beta]: https://github.com/razorpay/razorpay-php/compare/2.3.0...2.4.0-beta
164 | [2.5.0]: https://github.com/razorpay/razorpay-php/compare/2.4.0-beta...2.5.0
165 |
--------------------------------------------------------------------------------
/vendor/rmccue/requests/README.md:
--------------------------------------------------------------------------------
1 | Requests for PHP
2 | ================
3 |
4 | [](https://travis-ci.org/rmccue/Requests)
5 | [](http://codecov.io/github/rmccue/Requests?branch=master)
6 |
7 | Requests is a HTTP library written in PHP, for human beings. It is roughly
8 | based on the API from the excellent [Requests Python
9 | library](http://python-requests.org/). Requests is [ISC
10 | Licensed](https://github.com/rmccue/Requests/blob/master/LICENSE) (similar to
11 | the new BSD license) and has no dependencies, except for PHP 5.2+.
12 |
13 | Despite PHP's use as a language for the web, its tools for sending HTTP requests
14 | are severely lacking. cURL has an
15 | [interesting API](http://php.net/manual/en/function.curl-setopt.php), to say the
16 | least, and you can't always rely on it being available. Sockets provide only low
17 | level access, and require you to build most of the HTTP response parsing
18 | yourself.
19 |
20 | We all have better things to do. That's why Requests was born.
21 |
22 | ```php
23 | $headers = array('Accept' => 'application/json');
24 | $options = array('auth' => array('user', 'pass'));
25 | $request = Requests::get('https://api.github.com/gists', $headers, $options);
26 |
27 | var_dump($request->status_code);
28 | // int(200)
29 |
30 | var_dump($request->headers['content-type']);
31 | // string(31) "application/json; charset=utf-8"
32 |
33 | var_dump($request->body);
34 | // string(26891) "[...]"
35 | ```
36 |
37 | Requests allows you to send **HEAD**, **GET**, **POST**, **PUT**, **DELETE**,
38 | and **PATCH** HTTP requests. You can add headers, form data, multipart files,
39 | and parameters with simple arrays, and access the response data in the same way.
40 | Requests uses cURL and fsockopen, depending on what your system has available,
41 | but abstracts all the nasty stuff out of your way, providing a consistent API.
42 |
43 |
44 | Features
45 | --------
46 |
47 | - International Domains and URLs
48 | - Browser-style SSL Verification
49 | - Basic/Digest Authentication
50 | - Automatic Decompression
51 | - Connection Timeouts
52 |
53 |
54 | Installation
55 | ------------
56 |
57 | ### Install with Composer
58 | If you're using [Composer](https://github.com/composer/composer) to manage
59 | dependencies, you can add Requests with it.
60 |
61 | ```sh
62 | composer require rmccue/requests
63 | ```
64 |
65 | or
66 |
67 | {
68 | "require": {
69 | "rmccue/requests": ">=1.0"
70 | }
71 | }
72 |
73 | ### Install source from GitHub
74 | To install the source code:
75 |
76 | $ git clone git://github.com/rmccue/Requests.git
77 |
78 | And include it in your scripts:
79 |
80 | require_once '/path/to/Requests/library/Requests.php';
81 |
82 | You'll probably also want to register an autoloader:
83 |
84 | Requests::register_autoloader();
85 |
86 |
87 | ### Install source from zip/tarball
88 | Alternatively, you can fetch a [tarball][] or [zipball][]:
89 |
90 | $ curl -L https://github.com/rmccue/Requests/tarball/master | tar xzv
91 | (or)
92 | $ wget https://github.com/rmccue/Requests/tarball/master -O - | tar xzv
93 |
94 | [tarball]: https://github.com/rmccue/Requests/tarball/master
95 | [zipball]: https://github.com/rmccue/Requests/zipball/master
96 |
97 |
98 | ### Using a Class Loader
99 | If you're using a class loader (e.g., [Symfony Class Loader][]) for
100 | [PSR-0][]-style class loading:
101 |
102 | $loader->registerPrefix('Requests', 'path/to/vendor/Requests/library');
103 |
104 | [Symfony Class Loader]: https://github.com/symfony/ClassLoader
105 | [PSR-0]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md
106 |
107 |
108 | Documentation
109 | -------------
110 | The best place to start is our [prose-based documentation][], which will guide
111 | you through using Requests.
112 |
113 | After that, take a look at [the documentation for
114 | `Requests::request()`][request_method], where all the parameters are fully
115 | documented.
116 |
117 | Requests is [100% documented with PHPDoc](http://requests.ryanmccue.info/api/).
118 | If you find any problems with it, [create a new
119 | issue](https://github.com/rmccue/Requests/issues/new)!
120 |
121 | [prose-based documentation]: https://github.com/rmccue/Requests/blob/master/docs/README.md
122 | [request_method]: http://requests.ryanmccue.info/api/class-Requests.html#_request
123 |
124 | Testing
125 | -------
126 |
127 | Requests strives to have 100% code-coverage of the library with an extensive
128 | set of tests. We're not quite there yet, but [we're getting close][codecov].
129 |
130 | [codecov]: http://codecov.io/github/rmccue/Requests
131 |
132 | To run the test suite, first check that you have the [PHP
133 | JSON extension ](http://php.net/manual/en/book.json.php) enabled. Then
134 | simply:
135 |
136 | $ cd tests
137 | $ phpunit
138 |
139 | If you'd like to run a single set of tests, specify just the name:
140 |
141 | $ phpunit Transport/cURL
142 |
143 | Contribute
144 | ----------
145 |
146 | 1. Check for open issues or open a new issue for a feature request or a bug
147 | 2. Fork [the repository][] on Github to start making your changes to the
148 | `master` branch (or branch off of it)
149 | 3. Write a test which shows that the bug was fixed or that the feature works as expected
150 | 4. Send a pull request and bug me until I merge it
151 |
152 | [the repository]: https://github.com/rmccue/Requests
153 |
--------------------------------------------------------------------------------
/vendor/rmccue/requests/tests/bootstrap.php:
--------------------------------------------------------------------------------
1 | '100 Continue',
54 | 101 => '101 Switching Protocols',
55 | 200 => '200 OK',
56 | 201 => '201 Created',
57 | 202 => '202 Accepted',
58 | 203 => '203 Non-Authoritative Information',
59 | 204 => '204 No Content',
60 | 205 => '205 Reset Content',
61 | 206 => '206 Partial Content',
62 | 300 => '300 Multiple Choices',
63 | 301 => '301 Moved Permanently',
64 | 302 => '302 Found',
65 | 303 => '303 See Other',
66 | 304 => '304 Not Modified',
67 | 305 => '305 Use Proxy',
68 | 306 => '306 (Unused)',
69 | 307 => '307 Temporary Redirect',
70 | 400 => '400 Bad Request',
71 | 401 => '401 Unauthorized',
72 | 402 => '402 Payment Required',
73 | 403 => '403 Forbidden',
74 | 404 => '404 Not Found',
75 | 405 => '405 Method Not Allowed',
76 | 406 => '406 Not Acceptable',
77 | 407 => '407 Proxy Authentication Required',
78 | 408 => '408 Request Timeout',
79 | 409 => '409 Conflict',
80 | 410 => '410 Gone',
81 | 411 => '411 Length Required',
82 | 412 => '412 Precondition Failed',
83 | 413 => '413 Request Entity Too Large',
84 | 414 => '414 Request-URI Too Long',
85 | 415 => '415 Unsupported Media Type',
86 | 416 => '416 Requested Range Not Satisfiable',
87 | 417 => '417 Expectation Failed',
88 | 418 => '418 I\'m a teapot',
89 | 428 => '428 Precondition Required',
90 | 429 => '429 Too Many Requests',
91 | 431 => '431 Request Header Fields Too Large',
92 | 500 => '500 Internal Server Error',
93 | 501 => '501 Not Implemented',
94 | 502 => '502 Bad Gateway',
95 | 503 => '503 Service Unavailable',
96 | 504 => '504 Gateway Timeout',
97 | 505 => '505 HTTP Version Not Supported',
98 | 511 => '511 Network Authentication Required',
99 | );
100 |
101 | public function request($url, $headers = array(), $data = array(), $options = array()) {
102 | $status = isset(self::$messages[$this->code]) ? self::$messages[$this->code] : $this->code . ' unknown';
103 | $response = "HTTP/1.0 $status\r\n";
104 | $response .= "Content-Type: text/plain\r\n";
105 | if ($this->chunked) {
106 | $response .= "Transfer-Encoding: chunked\r\n";
107 | }
108 | $response .= $this->raw_headers;
109 | $response .= "Connection: close\r\n\r\n";
110 | $response .= $this->body;
111 | return $response;
112 | }
113 |
114 | public function request_multiple($requests, $options) {
115 | $responses = array();
116 | foreach ($requests as $id => $request) {
117 | $handler = new MockTransport();
118 | $handler->code = $request['options']['mock.code'];
119 | $handler->chunked = $request['options']['mock.chunked'];
120 | $handler->body = $request['options']['mock.body'];
121 | $handler->raw_headers = $request['options']['mock.raw_headers'];
122 | $responses[$id] = $handler->request($request['url'], $request['headers'], $request['data'], $request['options']);
123 |
124 | if (!empty($options['mock.parse'])) {
125 | $request['options']['hooks']->dispatch('transport.internal.parse_response', array(&$responses[$id], $request));
126 | $request['options']['hooks']->dispatch('multiple.request.complete', array(&$responses[$id], $id));
127 | }
128 | }
129 |
130 | return $responses;
131 | }
132 |
133 | public static function test() {
134 | return true;
135 | }
136 | }
137 |
138 | class RawTransport implements Requests_Transport {
139 | public $data = '';
140 | public function request($url, $headers = array(), $data = array(), $options = array()) {
141 | return $this->data;
142 | }
143 | public function request_multiple($requests, $options) {
144 | foreach ($requests as $id => &$request) {
145 | $handler = new RawTransport();
146 | $handler->data = $request['options']['raw.data'];
147 | $request = $handler->request($request['url'], $request['headers'], $request['data'], $request['options']);
148 | }
149 |
150 | return $requests;
151 | }
152 | public static function test() {
153 | return true;
154 | }
155 | }
156 |
--------------------------------------------------------------------------------
/vendor/rmccue/requests/library/Requests/IPv6.php:
--------------------------------------------------------------------------------
1 | FF01:0:0:0:0:0:0:101
27 | * ::1 -> 0:0:0:0:0:0:0:1
28 | *
29 | * @author Alexander Merz
30 | * @author elfrink at introweb dot nl
31 | * @author Josh Peck
32 | * @copyright 2003-2005 The PHP Group
33 | * @license http://www.opensource.org/licenses/bsd-license.php
34 | * @param string $ip An IPv6 address
35 | * @return string The uncompressed IPv6 address
36 | */
37 | public static function uncompress($ip) {
38 | if (substr_count($ip, '::') !== 1) {
39 | return $ip;
40 | }
41 |
42 | list($ip1, $ip2) = explode('::', $ip);
43 | $c1 = ($ip1 === '') ? -1 : substr_count($ip1, ':');
44 | $c2 = ($ip2 === '') ? -1 : substr_count($ip2, ':');
45 |
46 | if (strpos($ip2, '.') !== false) {
47 | $c2++;
48 | }
49 | // ::
50 | if ($c1 === -1 && $c2 === -1) {
51 | $ip = '0:0:0:0:0:0:0:0';
52 | }
53 | // ::xxx
54 | else if ($c1 === -1) {
55 | $fill = str_repeat('0:', 7 - $c2);
56 | $ip = str_replace('::', $fill, $ip);
57 | }
58 | // xxx::
59 | else if ($c2 === -1) {
60 | $fill = str_repeat(':0', 7 - $c1);
61 | $ip = str_replace('::', $fill, $ip);
62 | }
63 | // xxx::xxx
64 | else {
65 | $fill = ':' . str_repeat('0:', 6 - $c2 - $c1);
66 | $ip = str_replace('::', $fill, $ip);
67 | }
68 | return $ip;
69 | }
70 |
71 | /**
72 | * Compresses an IPv6 address
73 | *
74 | * RFC 4291 allows you to compress consecutive zero pieces in an address to
75 | * '::'. This method expects a valid IPv6 address and compresses consecutive
76 | * zero pieces to '::'.
77 | *
78 | * Example: FF01:0:0:0:0:0:0:101 -> FF01::101
79 | * 0:0:0:0:0:0:0:1 -> ::1
80 | *
81 | * @see uncompress()
82 | * @param string $ip An IPv6 address
83 | * @return string The compressed IPv6 address
84 | */
85 | public static function compress($ip) {
86 | // Prepare the IP to be compressed
87 | $ip = self::uncompress($ip);
88 | $ip_parts = self::split_v6_v4($ip);
89 |
90 | // Replace all leading zeros
91 | $ip_parts[0] = preg_replace('/(^|:)0+([0-9])/', '\1\2', $ip_parts[0]);
92 |
93 | // Find bunches of zeros
94 | if (preg_match_all('/(?:^|:)(?:0(?::|$))+/', $ip_parts[0], $matches, PREG_OFFSET_CAPTURE)) {
95 | $max = 0;
96 | $pos = null;
97 | foreach ($matches[0] as $match) {
98 | if (strlen($match[0]) > $max) {
99 | $max = strlen($match[0]);
100 | $pos = $match[1];
101 | }
102 | }
103 |
104 | $ip_parts[0] = substr_replace($ip_parts[0], '::', $pos, $max);
105 | }
106 |
107 | if ($ip_parts[1] !== '') {
108 | return implode(':', $ip_parts);
109 | }
110 | else {
111 | return $ip_parts[0];
112 | }
113 | }
114 |
115 | /**
116 | * Splits an IPv6 address into the IPv6 and IPv4 representation parts
117 | *
118 | * RFC 4291 allows you to represent the last two parts of an IPv6 address
119 | * using the standard IPv4 representation
120 | *
121 | * Example: 0:0:0:0:0:0:13.1.68.3
122 | * 0:0:0:0:0:FFFF:129.144.52.38
123 | *
124 | * @param string $ip An IPv6 address
125 | * @return string[] [0] contains the IPv6 represented part, and [1] the IPv4 represented part
126 | */
127 | protected static function split_v6_v4($ip) {
128 | if (strpos($ip, '.') !== false) {
129 | $pos = strrpos($ip, ':');
130 | $ipv6_part = substr($ip, 0, $pos);
131 | $ipv4_part = substr($ip, $pos + 1);
132 | return array($ipv6_part, $ipv4_part);
133 | }
134 | else {
135 | return array($ip, '');
136 | }
137 | }
138 |
139 | /**
140 | * Checks an IPv6 address
141 | *
142 | * Checks if the given IP is a valid IPv6 address
143 | *
144 | * @param string $ip An IPv6 address
145 | * @return bool true if $ip is a valid IPv6 address
146 | */
147 | public static function check_ipv6($ip) {
148 | $ip = self::uncompress($ip);
149 | list($ipv6, $ipv4) = self::split_v6_v4($ip);
150 | $ipv6 = explode(':', $ipv6);
151 | $ipv4 = explode('.', $ipv4);
152 | if (count($ipv6) === 8 && count($ipv4) === 1 || count($ipv6) === 6 && count($ipv4) === 4) {
153 | foreach ($ipv6 as $ipv6_part) {
154 | // The section can't be empty
155 | if ($ipv6_part === '') {
156 | return false;
157 | }
158 |
159 | // Nor can it be over four characters
160 | if (strlen($ipv6_part) > 4) {
161 | return false;
162 | }
163 |
164 | // Remove leading zeros (this is safe because of the above)
165 | $ipv6_part = ltrim($ipv6_part, '0');
166 | if ($ipv6_part === '') {
167 | $ipv6_part = '0';
168 | }
169 |
170 | // Check the value is valid
171 | $value = hexdec($ipv6_part);
172 | if (dechex($value) !== strtolower($ipv6_part) || $value < 0 || $value > 0xFFFF) {
173 | return false;
174 | }
175 | }
176 | if (count($ipv4) === 4) {
177 | foreach ($ipv4 as $ipv4_part) {
178 | $value = (int) $ipv4_part;
179 | if ((string) $value !== $ipv4_part || $value < 0 || $value > 0xFF) {
180 | return false;
181 | }
182 | }
183 | }
184 | return true;
185 | }
186 | else {
187 | return false;
188 | }
189 | }
190 | }
191 |
--------------------------------------------------------------------------------
/vendor/razorpay/razorpay/src/Entity.php:
--------------------------------------------------------------------------------
1 | getEntityUrl();
14 |
15 | return $this->request('POST', $entityUrl, $attributes);
16 | }
17 |
18 | protected function fetch($id)
19 | {
20 | $entityUrl = $this->getEntityUrl();
21 |
22 | $this->validateIdPresence($id);
23 |
24 | $relativeUrl = $entityUrl . $id;
25 |
26 | return $this->request('GET', $relativeUrl);
27 | }
28 |
29 | protected function validateIdPresence($id)
30 | {
31 | if ($id !== null)
32 | {
33 | return;
34 | }
35 |
36 | $path = explode('\\', get_class($this));
37 | $class = strtolower(array_pop($path));
38 |
39 | $message = 'The ' . $class . ' id provided is null';
40 |
41 | $code = Errors\ErrorCode::BAD_REQUEST_ERROR;
42 |
43 | throw new Errors\BadRequestError($message, $code, 500);
44 | }
45 |
46 | protected function all($options = array())
47 | {
48 | $entityUrl = $this->getEntityUrl();
49 |
50 | return $this->request('GET', $entityUrl, $options);
51 | }
52 |
53 | protected function getEntityUrl()
54 | {
55 | $fullClassName = get_class($this);
56 | $pos = strrpos($fullClassName, '\\');
57 | $className = substr($fullClassName, $pos + 1);
58 | $className = $this->snakeCase($className);
59 | return $className.'s/';
60 | }
61 |
62 | protected function snakeCase($input)
63 | {
64 | $delimiter = '_';
65 | $output = preg_replace('/\s+/u', '', ucwords($input));
66 | $output = preg_replace('/(.)(?=[A-Z])/u', '$1'.$delimiter, $output);
67 | $output = strtolower($output);
68 | return $output;
69 | }
70 |
71 | /**
72 | * Makes a HTTP request using Request class and assuming the API returns
73 | * formatted entity or collection result, wraps the returned JSON as entity
74 | * and returns.
75 | *
76 | * @param string $method
77 | * @param string $relativeUrl
78 | * @param array $data
79 | *
80 | * @return Entity
81 | */
82 | protected function request($method, $relativeUrl, $data = null)
83 | {
84 | $request = new Request();
85 |
86 | $response = $request->request($method, $relativeUrl, $data);
87 |
88 | if ((isset($response['entity'])) and
89 | ($response['entity'] == $this->getEntity()))
90 | {
91 | $this->fill($response);
92 |
93 | return $this;
94 | }
95 | else
96 | {
97 | return static::buildEntity($response);
98 | }
99 | }
100 |
101 | /**
102 | * Given the JSON response of an API call, wraps it to corresponding entity
103 | * class or a collection and returns the same.
104 | *
105 | * @param array $data
106 | *
107 | * @return Entity
108 | */
109 | protected static function buildEntity($data)
110 | {
111 | $entities = static::getDefinedEntitiesArray();
112 |
113 | if (isset($data['entity']))
114 | {
115 | if (in_array($data['entity'], $entities))
116 | {
117 | $class = static::getEntityClass($data['entity']);
118 | $entity = new $class;
119 | }
120 | else
121 | {
122 | $entity = new static;
123 | }
124 | }
125 | else
126 | {
127 | $entity = new static;
128 | }
129 |
130 | $entity->fill($data);
131 |
132 | return $entity;
133 | }
134 |
135 | protected static function getDefinedEntitiesArray()
136 | {
137 | return array(
138 | 'collection',
139 | 'payment',
140 | 'refund',
141 | 'order',
142 | 'customer',
143 | 'token',
144 | 'settlement');
145 | }
146 |
147 | protected static function getEntityClass($name)
148 | {
149 | return __NAMESPACE__.'\\'.ucfirst($name);
150 | }
151 |
152 | protected function getEntity()
153 | {
154 | $class = get_class($this);
155 | $pos = strrpos($class, '\\');
156 | $entity = strtolower(substr($class, $pos));
157 |
158 | return $entity;
159 | }
160 |
161 | public function fill($data)
162 | {
163 | $attributes = array();
164 |
165 | foreach ($data as $key => $value)
166 | {
167 | if (is_array($value))
168 | {
169 | if (static::isAssocArray($value) === false)
170 | {
171 | $collection = array();
172 |
173 | foreach ($value as $v)
174 | {
175 | if (is_array($v))
176 | {
177 | $entity = static::buildEntity($v);
178 | array_push($collection, $entity);
179 | }
180 | else
181 | {
182 | array_push($collection, $v);
183 | }
184 | }
185 |
186 | $value = $collection;
187 | }
188 | else
189 | {
190 | $value = static::buildEntity($value);
191 | }
192 | }
193 |
194 | $attributes[$key] = $value;
195 | }
196 |
197 | $this->attributes = $attributes;
198 | }
199 |
200 | public static function isAssocArray($arr)
201 | {
202 | return array_keys($arr) !== range(0, count($arr) - 1);
203 | }
204 |
205 | public function toArray()
206 | {
207 | return $this->convertToArray($this->attributes);
208 | }
209 |
210 | protected function convertToArray($attributes)
211 | {
212 | $array = $attributes;
213 |
214 | foreach ($attributes as $key => $value)
215 | {
216 | if (is_object($value))
217 | {
218 | $array[$key] = $value->toArray();
219 | }
220 | else if (is_array($value) and self::isAssocArray($value) == false)
221 | {
222 | $array[$key] = $this->convertToArray($value);
223 | }
224 | }
225 |
226 | return $array;
227 | }
228 | }
229 |
--------------------------------------------------------------------------------
/vendor/razorpay/razorpay/src/Request.php:
--------------------------------------------------------------------------------
1 | 1
30 | );
31 |
32 | /**
33 | * Fires a request to the API
34 | * @param string $method HTTP Verb
35 | * @param string $url Relative URL for the request
36 | * @param array $data Data to be passed along the request
37 | * @return array Response data in array format. Not meant
38 | * to be used directly
39 | */
40 | public function request($method, $url, $data = array())
41 | {
42 | $url = Api::getFullUrl($url);
43 |
44 | $hooks = new Requests_Hooks();
45 |
46 | $hooks->register('curl.before_send', array($this, 'setCurlSslOpts'));
47 |
48 | $options = array(
49 | 'auth' => array(Api::getKey(), Api::getSecret()),
50 | 'hook' => $hooks,
51 | 'timeout' => 60,
52 | );
53 |
54 | $headers = $this->getRequestHeaders();
55 |
56 | $response = Requests::request($url, $headers, $data, $method, $options);
57 |
58 | $this->checkErrors($response);
59 |
60 | return json_decode($response->body, true);
61 | }
62 |
63 | public function setCurlSslOpts($curl)
64 | {
65 | curl_setopt($curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_1);
66 | }
67 |
68 | /**
69 | * Adds an additional header to all API requests
70 | * @param string $key Header key
71 | * @param string $value Header value
72 | * @return null
73 | */
74 | public static function addHeader($key, $value)
75 | {
76 | self::$headers[$key] = $value;
77 | }
78 |
79 | /**
80 | * Returns all headers attached so far
81 | * @return array headers
82 | */
83 | public static function getHeaders()
84 | {
85 | return self::$headers;
86 | }
87 |
88 | /**
89 | * Process the statusCode of the response and throw exception if necessary
90 | * @param Object $response The response object returned by Requests
91 | */
92 | protected function checkErrors($response)
93 | {
94 | $body = $response->body;
95 | $httpStatusCode = $response->status_code;
96 |
97 | try
98 | {
99 | $body = json_decode($response->body, true);
100 | }
101 | catch (Exception $e)
102 | {
103 | $this->throwServerError($body, $httpStatusCode);
104 | }
105 |
106 | if (($httpStatusCode < 200) or
107 | ($httpStatusCode >= 300))
108 | {
109 | $this->processError($body, $httpStatusCode, $response);
110 | }
111 | }
112 |
113 | protected function processError($body, $httpStatusCode, $response)
114 | {
115 | $this->verifyErrorFormat($body, $httpStatusCode);
116 |
117 | $code = $body['error']['code'];
118 |
119 | // We are basically converting the error code to the Error class name
120 | // Replace underscores with space
121 | // Lowercase the words, capitalize first letter of each word
122 | // Remove spaces
123 | $error = str_replace('_', ' ', $code);
124 | $error = ucwords(strtolower($error));
125 | $error = str_replace(' ', '', $error);
126 |
127 | // Add namespace
128 | // This is the fully qualified error class name
129 | $error = __NAMESPACE__.'\Errors\\' . $error;
130 |
131 | $description = $body['error']['description'];
132 |
133 | $field = null;
134 | if (isset($body['error']['field']))
135 | {
136 | $field = $body['error']['field'];
137 |
138 | // Create an instance of the error and then throw it
139 | throw new $error($description, $code, $httpStatusCode, $field);
140 | }
141 |
142 | throw new $error($description, $code, $httpStatusCode);
143 | }
144 |
145 | protected function throwServerError($body, $httpStatusCode)
146 | {
147 | $description = "The server did not send back a well-formed response. " . PHP_EOL .
148 | "Server Response: $body";
149 |
150 | throw new Errors\ServerError(
151 | $description,
152 | ErrorCode::SERVER_ERROR,
153 | $httpStatusCode);
154 | }
155 |
156 | protected function getRequestHeaders()
157 | {
158 | $uaHeader = array(
159 | 'User-Agent' => $this->constructUa()
160 | );
161 |
162 | $headers = array_merge(self::$headers, $uaHeader);
163 |
164 | return $headers;
165 | }
166 |
167 | protected function constructUa()
168 | {
169 | $ua = 'Razorpay/v1 PHPSDK/' . Api::VERSION . ' PHP/' . phpversion();
170 |
171 | $ua .= ' ' . $this->getAppDetailsUa();
172 |
173 | return $ua;
174 | }
175 |
176 | protected function getAppDetailsUa()
177 | {
178 | $appsDetails = Api::$appsDetails;
179 |
180 | $appsDetailsUa = '';
181 |
182 | foreach ($appsDetails as $app)
183 | {
184 | if ((isset($app['title'])) and (is_string($app['title'])))
185 | {
186 | $appUa = $app['title'];
187 |
188 | if ((isset($app['version'])) and (is_scalar($app['version'])))
189 | {
190 | $appUa .= '/' . $app['version'];
191 | }
192 |
193 | $appsDetailsUa .= $appUa . ' ';
194 | }
195 | }
196 |
197 | return $appsDetailsUa;
198 | }
199 |
200 | /**
201 | * Verifies error is in proper format. If not then
202 | * throws ServerErrorException
203 | *
204 | * @param array $body
205 | * @param int $httpStatusCode
206 | * @return void
207 | */
208 | protected function verifyErrorFormat($body, $httpStatusCode)
209 | {
210 | if (is_array($body) === false)
211 | {
212 | $this->throwServerError($body, $httpStatusCode);
213 | }
214 |
215 | if ((isset($body['error']) === false) or
216 | (isset($body['error']['code']) === false))
217 | {
218 | $this->throwServerError($body, $httpStatusCode);
219 | }
220 |
221 | $code = $body['error']['code'];
222 |
223 | if (Errors\ErrorCode::exists($code) === false)
224 | {
225 | $this->throwServerError($body, $httpStatusCode);
226 | }
227 | }
228 | }
--------------------------------------------------------------------------------