SslCommerzNotification   F
last analyzed

Complexity

Total Complexity 85

Size/Duplication

Total Lines 448
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 197
c 2
b 0
f 1
dl 0
loc 448
rs 2
wmc 85

20 Methods

Rating   Name   Duplication   Size   Complexity  
A makePayment() 0 35 5
A getIPNUrl() 0 2 1
A setCustomerInfo() 0 14 3
B setRequiredInfo() 0 77 7
A __construct() 0 6 1
A getSuccessUrl() 0 3 1
A setCancelUrl() 0 2 1
A setFailedUrl() 0 2 1
A setAuthenticationInfo() 0 6 1
C validate() 0 99 15
A orderValidate() 0 8 4
F setProductInfo() 0 45 21
A setAdditionalInfo() 0 8 5
A setParams() 0 15 1
A getFailedUrl() 0 3 1
B SSLCOMMERZ_hash_verify() 0 37 8
A setSuccessUrl() 0 2 1
A setShipmentInfo() 0 14 6
A setIPNUrl() 0 2 1
A getCancelUrl() 0 3 1

How to fix   Complexity   

Complex Class

Complex classes like SslCommerzNotification often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use SslCommerzNotification, and based on these observations, apply Extract Interface, too.

1
<?php
2
namespace AfzalSabbir\SSLaraCommerz\Library\SslCommerz;
3
4
class SslCommerzNotification extends AbstractSslCommerz
5
{
6
    protected $data = [];
7
    protected $config = [];
8
9
    private $successUrl;
10
    private $cancelUrl;
11
    private $failedUrl;
12
    private $ipnUrl;
13
    private $error;
14
15
    /**
16
     * SslCommerzNotification constructor.
17
     */
18
    public function __construct()
19
    {
20
        $this->config = config('sslcommerz');
21
22
        $this->setStoreId($this->config['apiCredentials']['store_id']);
23
        $this->setStorePassword($this->config['apiCredentials']['store_password']);
24
    }
25
26
    public function orderValidate($post_data, $trx_id = '', $amount = 0, $currency = "BDT")
27
    {
28
        if ($post_data == '' && $trx_id == '' && !is_array($post_data)) {
29
            $this->error = "Please provide valid transaction ID and post request data";
30
            return $this->error;
31
        }
32
33
        return $this->validate($trx_id, $amount, $currency, $post_data);
34
35
    }
36
37
38
    # VALIDATE SSLCOMMERZ TRANSACTION
39
    protected function validate($merchant_trans_id, $merchant_trans_amount, $merchant_trans_currency, $post_data)
40
    {
41
        # MERCHANT SYSTEM INFO
42
        if (!empty($merchant_trans_id) && !empty($merchant_trans_amount)) {
43
44
            # CALL THE FUNCTION TO CHECK THE RESULT
45
            $post_data['store_id'] = $this->getStoreId();
46
            $post_data['store_pass'] = $this->getStorePassword();
47
48
            $val_id = urlencode($post_data['val_id']);
49
            $store_id = urlencode($this->getStoreId());
50
            $store_passwd = urlencode($this->getStorePassword());
51
            $requested_url = ($this->config['apiDomain'] . $this->config['apiUrl']['order_validate'] . "?val_id=" . $val_id . "&store_id=" . $store_id . "&store_passwd=" . $store_passwd . "&v=1&format=json");
52
53
            $handle = curl_init();
54
            curl_setopt($handle, CURLOPT_URL, $requested_url);
55
            curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
56
57
            if ($this->config['connect_from_localhost']) {
58
                curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, 0);
59
                curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, 0);
60
            } else {
61
                curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, 2);
62
                curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, 2);
63
            }
64
65
66
            $result = curl_exec($handle);
67
68
            $code = curl_getinfo($handle, CURLINFO_HTTP_CODE);
69
70
            if ($code == 200 && !(curl_errno($handle))) {
71
72
                # TO CONVERT AS ARRAY
73
                # $result = json_decode($result, true);
74
                # $status = $result['status'];
75
76
                # TO CONVERT AS OBJECT
77
                $result = json_decode($result);
0 ignored issues
show
Bug introduced by
It seems like $result can also be of type true; however, parameter $json of json_decode() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

77
                $result = json_decode(/** @scrutinizer ignore-type */ $result);
Loading history...
78
                $this->sslc_data = $result;
0 ignored issues
show
Bug Best Practice introduced by
The property sslc_data does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
79
80
                # TRANSACTION INFO
81
                $status = $result->status;
82
                $tran_date = $result->tran_date;
0 ignored issues
show
Unused Code introduced by
The assignment to $tran_date is dead and can be removed.
Loading history...
83
                $tran_id = $result->tran_id;
84
                $val_id = $result->val_id;
0 ignored issues
show
Unused Code introduced by
The assignment to $val_id is dead and can be removed.
Loading history...
85
                $amount = $result->amount;
86
                $store_amount = $result->store_amount;
0 ignored issues
show
Unused Code introduced by
The assignment to $store_amount is dead and can be removed.
Loading history...
87
                $bank_tran_id = $result->bank_tran_id;
0 ignored issues
show
Unused Code introduced by
The assignment to $bank_tran_id is dead and can be removed.
Loading history...
88
                $card_type = $result->card_type;
0 ignored issues
show
Unused Code introduced by
The assignment to $card_type is dead and can be removed.
Loading history...
89
                $currency_type = $result->currency_type;
90
                $currency_amount = $result->currency_amount;
91
92
                # ISSUER INFO
93
                $card_no = $result->card_no;
0 ignored issues
show
Unused Code introduced by
The assignment to $card_no is dead and can be removed.
Loading history...
94
                $card_issuer = $result->card_issuer;
0 ignored issues
show
Unused Code introduced by
The assignment to $card_issuer is dead and can be removed.
Loading history...
95
                $card_brand = $result->card_brand;
0 ignored issues
show
Unused Code introduced by
The assignment to $card_brand is dead and can be removed.
Loading history...
96
                $card_issuer_country = $result->card_issuer_country;
0 ignored issues
show
Unused Code introduced by
The assignment to $card_issuer_country is dead and can be removed.
Loading history...
97
                $card_issuer_country_code = $result->card_issuer_country_code;
0 ignored issues
show
Unused Code introduced by
The assignment to $card_issuer_country_code is dead and can be removed.
Loading history...
98
99
                # API AUTHENTICATION
100
                $APIConnect = $result->APIConnect;
0 ignored issues
show
Unused Code introduced by
The assignment to $APIConnect is dead and can be removed.
Loading history...
101
                $validated_on = $result->validated_on;
0 ignored issues
show
Unused Code introduced by
The assignment to $validated_on is dead and can be removed.
Loading history...
102
                $gw_version = $result->gw_version;
0 ignored issues
show
Unused Code introduced by
The assignment to $gw_version is dead and can be removed.
Loading history...
103
104
                # GIVE SERVICE
105
                if ($status == "VALID" || $status == "VALIDATED") {
106
                    if ($merchant_trans_currency == "BDT") {
107
                        if (trim($merchant_trans_id) == trim($tran_id) && (abs($merchant_trans_amount - $amount) < 1) && trim($merchant_trans_currency) == trim('BDT')) {
108
                            return true;
109
                        } else {
110
                            # DATA TEMPERED
111
                            $this->error = "Data has been tempered";
112
                            return false;
113
                        }
114
                    } else {
115
                        //echo "trim($merchant_trans_id) == trim($tran_id) && ( abs($merchant_trans_amount-$currency_amount) < 1 ) && trim($merchant_trans_currency)==trim($currency_type)";
116
                        if (trim($merchant_trans_id) == trim($tran_id) && (abs($merchant_trans_amount - $currency_amount) < 1) && trim($merchant_trans_currency) == trim($currency_type)) {
117
                            return true;
118
                        } else {
119
                            # DATA TEMPERED
120
                            $this->error = "Data has been tempered";
121
                            return false;
122
                        }
123
                    }
124
                } else {
125
                    # FAILED TRANSACTION
126
                    $this->error = "Failed Transaction";
127
                    return false;
128
                }
129
            } else {
130
                # Failed to connect with SSLCOMMERZ
131
                $this->error = "Faile to connect with SSLCOMMERZ";
132
                return false;
133
            }
134
        } else {
135
            # INVALID DATA
136
            $this->error = "Invalid data";
137
            return false;
138
        }
139
    }
140
141
    # FUNCTION TO CHECK HASH VALUE
142
    protected function SSLCOMMERZ_hash_verify($post_data, $store_passwd = "")
143
    {
144
        if (isset($post_data) && isset($post_data['verify_sign']) && isset($post_data['verify_key'])) {
145
            # NEW ARRAY DECLARED TO TAKE VALUE OF ALL POST
146
            $pre_define_key = explode(',', $post_data['verify_key']);
147
148
            $new_data = array();
149
            if (!empty($pre_define_key)) {
150
                foreach ($pre_define_key as $value) {
151
//                    if (isset($post_data[$value])) {
152
                    $new_data[$value] = ($post_data[$value]);
153
//                    }
154
                }
155
            }
156
            # ADD MD5 OF STORE PASSWORD
157
            $new_data['store_passwd'] = md5($store_passwd);
158
159
            # SORT THE KEY AS BEFORE
160
            ksort($new_data);
161
162
            $hash_string = "";
163
            foreach ($new_data as $key => $value) {
164
                $hash_string .= $key . '=' . ($value) . '&';
165
            }
166
            $hash_string = rtrim($hash_string, '&');
167
168
            if (md5($hash_string) == $post_data['verify_sign']) {
169
170
                return true;
171
172
            } else {
173
                $this->error = "Verification signature not matched";
174
                return false;
175
            }
176
        } else {
177
            $this->error = 'Required data mission. ex: verify_key, verify_sign';
178
            return false;
179
        }
180
    }
181
182
    /**
183
     * @param array $requestData
184
     * @param string $type
185
     * @param string $pattern
186
     * @return false|mixed|string
187
     */
188
    public function makePayment(array $requestData, $type = 'checkout', $pattern = 'json')
189
    {
190
        if (empty($requestData)) {
191
            return "Please provide a valid information list about transaction with transaction id, amount, success url, fail url, cancel url, store id and pass at least";
192
        }
193
194
        $header = [];
195
196
        $this->setApiUrl($this->config['apiDomain'] . $this->config['apiUrl']['make_payment']);
197
198
        // Set the required/additional params
199
        $this->setParams($requestData);
200
201
        // Set the authentication information
202
        $this->setAuthenticationInfo();
203
204
        // Now, call the Gateway API
205
        $response = $this->callToApi($this->data, $header, $this->config['connect_from_localhost']);
206
207
        $formattedResponse = $this->formatResponse($response, $type, $pattern); // Here we will define the response pattern
208
209
        if ($type == 'hosted') {
210
            if (!empty($formattedResponse['GatewayPageURL'])) {
211
                $this->redirect($formattedResponse['GatewayPageURL']);
212
            } else {
213
                if (strpos($formattedResponse['failedreason'], 'Store Credential') === false) {
214
                    $message = $formattedResponse['failedreason'];
215
                } else {
216
                    $message = "Check the SSLCZ_TESTMODE and SSLCZ_STORE_PASSWORD value in your .env; DO NOT USE MERCHANT PANEL PASSWORD HERE.";
217
                }
218
219
                return $message;
220
            }
221
        } else {
222
            return $formattedResponse;
223
        }
224
    }
225
226
    protected function setSuccessUrl() {
227
        $this->successUrl = env('APP_URL') . $this->config['success_url'];
228
    }
229
230
    protected function getSuccessUrl()
231
    {
232
        return $this->successUrl;
233
    }
234
235
    protected function setFailedUrl() {
236
        $this->failedUrl = env('APP_URL') . $this->config['failed_url'];
237
    }
238
239
    protected function getFailedUrl()
240
    {
241
        return $this->failedUrl;
242
    }
243
244
    protected function setCancelUrl() {
245
        $this->cancelUrl = env('APP_URL') . $this->config['cancel_url'];
246
    }
247
248
    protected function getCancelUrl()
249
    {
250
        return $this->cancelUrl;
251
    }
252
253
    protected function setIPNUrl() {
254
        $this->ipnUrl = env('APP_URL') . $this->config['ipn_url'];
255
    }
256
257
    protected function getIPNUrl() {
258
        return $this->ipnUrl;
259
    }
260
261
    public function setParams($requestData) {
262
        ##  Integration Required Parameters
263
        $this->setRequiredInfo($requestData);
264
265
        ##  Customer Information
266
        $this->setCustomerInfo($requestData);
267
268
        ##  Shipment Information
269
        $this->setShipmentInfo($requestData);
270
271
        ##  Product Information
272
        $this->setProductInfo($requestData);
273
274
        ##  Customized or Additional Parameters
275
        $this->setAdditionalInfo($requestData);
276
    }
277
278
    public function setAuthenticationInfo()
279
    {
280
        $this->data['store_id'] = $this->getStoreId();
281
        $this->data['store_passwd'] = $this->getStorePassword();
282
283
        return $this->data;
284
    }
285
286
    public function setRequiredInfo(array $info)
287
    {
288
        $this->data['total_amount'] = $info['total_amount']; // decimal (10,2)	Mandatory - The amount which will process by SSLCommerz. It shall be decimal value (10,2). Example : 55.40. The transaction amount must be from 10.00 BDT to 500000.00 BDT
289
        $this->data['currency'] = $info['currency']; // string (3)	Mandatory - The currency type must be mentioned. It shall be three characters. Example : BDT, USD, EUR, SGD, INR, MYR, etc. If the transaction currency is not BDT, then it will be converted to BDT based on the current convert rate. Example : 1 USD = 82.22 BDT.
290
        $this->data['tran_id'] = $info['tran_id']; // string (30)	Mandatory - Unique transaction ID to identify your order in both your end and SSLCommerz
291
        $this->data['product_category'] = $info['product_category']; // string (50)	Mandatory - Mention the product category. It is a open field. Example - clothing,shoes,watches,gift,healthcare, jewellery,top up,toys,baby care,pants,laptop,donation,etc
292
293
        // Set the SUCCESS, FAIL, CANCEL Redirect URL before setting the other parameters
294
        $this->setSuccessUrl();
295
        $this->setFailedUrl();
296
        $this->setCancelUrl();
297
        $this->setIPNUrl();
298
299
        $this->data['success_url'] = $this->getSuccessUrl(); // string (255)	Mandatory - It is the callback URL of your website where user will redirect after successful payment (Length: 255)
300
        $this->data['fail_url'] = $this->getFailedUrl(); // string (255)	Mandatory - It is the callback URL of your website where user will redirect after any failure occure during payment (Length: 255)
301
        $this->data['cancel_url'] = $this->getCancelUrl(); // string (255)	Mandatory - It is the callback URL of your website where user will redirect if user canceled the transaction (Length: 255)
302
303
        /*
304
         * IPN is very important feature to integrate with your site(s).
305
         * Some transaction could be pending or customer lost his/her session, in such cases back-end IPN plays a very important role to update your backend office.
306
         *
307
         * Type: string (255)
308
         * Important! Not mandatory, however better to use to avoid missing any payment notification - It is the Instant Payment Notification (IPN) URL of your website where SSLCOMMERZ will send the transaction's status (Length: 255).
309
         * The data will be communicated as SSLCOMMERZ Server to your Server. So, customer session will not work.
310
		*/
311
        $this->data['ipn_url'] = $this->getIPNUrl();
312
313
        /*
314
         * Type: string (30)
315
         * Do not Use! If you do not customize the gateway list - You can control to display the gateway list at SSLCommerz gateway selection page by providing this parameters.
316
         * Multi Card:
317
            brac_visa = BRAC VISA
318
            dbbl_visa = Dutch Bangla VISA
319
            city_visa = City Bank Visa
320
            ebl_visa = EBL Visa
321
            sbl_visa = Southeast Bank Visa
322
            brac_master = BRAC MASTER
323
            dbbl_master = MASTER Dutch-Bangla
324
            city_master = City Master Card
325
            ebl_master = EBL Master Card
326
            sbl_master = Southeast Bank Master Card
327
            city_amex = City Bank AMEX
328
            qcash = QCash
329
            dbbl_nexus = DBBL Nexus
330
            bankasia = Bank Asia IB
331
            abbank = AB Bank IB
332
            ibbl = IBBL IB and Mobile Banking
333
            mtbl = Mutual Trust Bank IB
334
            bkash = Bkash Mobile Banking
335
            dbblmobilebanking = DBBL Mobile Banking
336
            city = City Touch IB
337
            upay = Upay
338
            tapnpay = Tap N Pay Gateway
339
         * GROUP GATEWAY
340
            internetbank = For all internet banking
341
            mobilebank = For all mobile banking
342
            othercard = For all cards except visa,master and amex
343
            visacard = For all visa
344
            mastercard = For All Master card
345
            amexcard = For Amex Card
346
         * */
347
        $this->data['multi_card_name'] = (isset($info['multi_card_name'])) ? $info['multi_card_name'] : null;
348
349
        /*
350
         * Type: string (255)
351
         * Do not Use! If you do not control on transaction - You can provide the BIN of card to allow the transaction must be completed by this BIN. You can declare by coma ',' separate of these BIN.
352
         * Example: 371598,371599,376947,376948,376949
353
         * */
354
        $this->data['allowed_bin'] = (isset($info['allowed_bin'])) ? $info['allowed_bin'] : null;
355
356
        ##   Parameters to Handle EMI Transaction ##
357
        $this->data['emi_option'] = (isset($info['emi_option'])) ? $info['emi_option'] : null; // integer (1)	Mandatory - This is mandatory if transaction is EMI enabled and Value must be 1/0. Here, 1 means customer will get EMI facility for this transaction
358
        $this->data['emi_max_inst_option'] = (isset($info['emi_max_inst_option'])) ? $info['emi_max_inst_option'] : null; // integer (2)	Max instalment Option, Here customer will get 3,6, 9 instalment at gateway page
359
        $this->data['emi_selected_inst'] = (isset($info['emi_selected_inst'])) ? $info['emi_selected_inst'] : null; // integer (2)	Customer has selected from your Site, So no instalment option will be displayed at gateway page
360
        $this->data['emi_allow_only'] = (isset($info['emi_allow_only'])) ? $info['emi_allow_only'] : 0;
361
362
        return $this->data;
363
    }
364
365
    public function setCustomerInfo(array $info)
366
    {
367
        $this->data['cus_name'] = $info['cus_name']; // string (50)	Mandatory - Your customer name to address the customer in payment receipt email
368
        $this->data['cus_email'] = $info['cus_email']; // string (50)	Mandatory - Valid email address of your customer to send payment receipt from SSLCommerz end
369
        $this->data['cus_add1'] = $info['cus_add1']; // string (50)	Mandatory - Address of your customer. Not mandatory but useful if provided
370
        $this->data['cus_add2'] = $info['cus_add2']; // string (50)	Address line 2 of your customer. Not mandatory but useful if provided
371
        $this->data['cus_city'] = $info['cus_city']; // string (50)	Mandatory - City of your customer. Not mandatory but useful if provided
372
        $this->data['cus_state'] = (isset($info['cus_state'])) ? $info['cus_state'] : null; // string (50)	State of your customer. Not mandatory but useful if provided
373
        $this->data['cus_postcode'] = $info['cus_postcode']; // string (30)	Mandatory - Postcode of your customer. Not mandatory but useful if provided
374
        $this->data['cus_country'] = $info['cus_country']; // string (50)	Mandatory - Country of your customer. Not mandatory but useful if provided
375
        $this->data['cus_phone'] = $info['cus_phone']; // string (20)	Mandatory - The phone/mobile number of your customer to contact if any issue arises
376
        $this->data['cus_fax'] = (isset($info['cus_fax'])) ? $info['cus_fax'] : null; // string (20)	Fax number of your customer. Not mandatory but useful if provided
377
378
        return $this->data;
379
    }
380
381
    public function setShipmentInfo(array $info)
382
    {
383
384
        $this->data['shipping_method'] = $info['shipping_method']; // string (50)	Mandatory - Shipping method of the order. Example: YES or NO or Courier
385
        $this->data['num_of_item'] = isset($info['num_of_item']) ? $info['num_of_item'] : 1; // integer (1)	Mandatory - No of product will be shipped. Example: 1 or 2 or etc
386
        $this->data['ship_name'] = $info['ship_name']; // string (50)	Mandatory, if shipping_method is YES - Shipping Address of your order. Not mandatory but useful if provided
387
        $this->data['ship_add1'] = $info['ship_add1']; // string (50)	Mandatory, if shipping_method is YES - Additional Shipping Address of your order. Not mandatory but useful if provided
388
        $this->data['ship_add2'] = (isset($info['ship_add2'])) ? $info['ship_add2'] : null; // string (50)	Additional Shipping Address of your order. Not mandatory but useful if provided
389
        $this->data['ship_city'] = $info['ship_city']; // string (50)	Mandatory, if shipping_method is YES - Shipping city of your order. Not mandatory but useful if provided
390
        $this->data['ship_state'] = (isset($info['ship_state'])) ? $info['ship_state'] : null; // string (50)	Shipping state of your order. Not mandatory but useful if provided
391
        $this->data['ship_postcode'] = (isset($info['ship_postcode'])) ? $info['ship_postcode'] : null; // string (50)	Mandatory, if shipping_method is YES - Shipping postcode of your order. Not mandatory but useful if provided
392
        $this->data['ship_country'] = (isset($info['ship_country'])) ? $info['ship_country'] : null; // string (50)	Mandatory, if shipping_method is YES - Shipping country of your order. Not mandatory but useful if provided
393
394
        return $this->data;
395
    }
396
397
    public function setProductInfo(array $info)
398
    {
399
400
        $this->data['product_name'] = (isset($info['product_name'])) ? $info['product_name'] : ''; // String (256)	Mandatory - Mention the product name briefly. Mention the product name by coma separate. Example: Computer,Speaker
401
        $this->data['product_category'] = (isset($info['product_category'])) ? $info['product_category'] : ''; // String (100)	Mandatory - Mention the product category. Example: Electronic or topup or bus ticket or air ticket
402
403
        /*
404
         * String (100)
405
         * Mandatory - Mention goods vertical. It is very much necessary for online transactions to avoid chargeback.
406
         * Please use the below keys :
407
            1) general
408
            2) physical-goods
409
            3) non-physical-goods
410
            4) airline-tickets
411
            5) travel-vertical
412
            6) telecom-vertical
413
        */
414
        $this->data['product_profile'] = (isset($info['product_profile'])) ? $info['product_profile'] : '';
415
416
        $this->data['hours_till_departure'] = (isset($info['hours_till_departure'])) ? $info['hours_till_departure'] : null; // string (30)	Mandatory, if product_profile is airline-tickets - Provide the remaining time of departure of flight till at the time of purchasing the ticket. Example: 12 hrs or 36 hrs
417
        $this->data['flight_type'] = (isset($info['flight_type'])) ? $info['flight_type'] : null; // string (30)	Mandatory, if product_profile is airline-tickets - Provide the flight type. Example: Oneway or Return or Multistop
418
        $this->data['pnr'] = (isset($info['pnr'])) ? $info['pnr'] : null; // string (50)	Mandatory, if product_profile is airline-tickets - Provide the PNR.
419
        $this->data['journey_from_to'] = (isset($info['journey_from_to'])) ? $info['journey_from_to'] : null; // string (256) - Mandatory, if product_profile is airline-tickets - Provide the journey route. Example: DAC-CGP or DAC-CGP CGP-DAC
420
        $this->data['third_party_booking'] = (isset($info['third_party_booking'])) ? $info['third_party_booking'] : null; // string (20)	Mandatory, if product_profile is airline-tickets - No/Yes. Whether the ticket has been taken from third party booking system.
421
        $this->data['hotel_name'] = (isset($info['hotel_name'])) ? $info['hotel_name'] : null; // string (256)	Mandatory, if product_profile is travel-vertical - Please provide the hotel name. Example: Sheraton
422
        $this->data['length_of_stay'] = (isset($info['length_of_stay'])) ? $info['length_of_stay'] : null; // string (30)	Mandatory, if product_profile is travel-vertical - How long stay in hotel. Example: 2 days
423
        $this->data['check_in_time'] = (isset($info['check_in_time'])) ? $info['check_in_time'] : null; // string (30)	Mandatory, if product_profile is travel-vertical - Checking hours for the hotel room. Example: 24 hrs
424
        $this->data['hotel_city'] = (isset($info['hotel_city'])) ? $info['hotel_city'] : null; // string (50)	Mandatory, if product_profile is travel-vertical - Location of the hotel. Example: Dhaka
425
        $this->data['product_type'] = (isset($info['product_type'])) ? $info['product_type'] : null; // string (30)	Mandatory, if product_profile is telecom-vertical - For mobile or any recharge, this information is necessary. Example: Prepaid or Postpaid
426
        $this->data['topup_number'] = (isset($info['topup_number'])) ? $info['topup_number'] : null; // string (150)	Mandatory, if product_profile is telecom-vertical - Provide the mobile number which will be recharged. Example: 8801700000000 or 8801700000000,8801900000000
427
        $this->data['country_topup'] = (isset($info['country_topup'])) ? $info['country_topup'] : null; // string (30)	Mandatory, if product_profile is telecom-vertical - Provide the country name in where the service is given. Example: Bangladesh
428
429
        /*
430
         * Type: JSON
431
         * JSON data with two elements. product : Max 255 characters, quantity : Quantity in numeric value and amount : Decimal (12,2)
432
         * Example:
433
           [{"product":"DHK TO BRS AC A1","quantity":"1","amount":"200.00"},{"product":"DHK TO BRS AC A2","quantity":"1","amount":"200.00"},{"product":"DHK TO BRS AC A3","quantity":"1","amount":"200.00"},{"product":"DHK TO BRS AC A4","quantity":"2","amount":"200.00"}]
434
         * */
435
        $this->data['cart'] = (isset($info['cart'])) ? $info['cart'] : null;
436
        $this->data['product_amount'] = (isset($info['product_amount'])) ? $info['product_amount'] : null; // decimal (10,2)	Product price which will be displayed in your merchant panel and will help you to reconcile the transaction. It shall be decimal value (10,2). Example : 50.40
437
        $this->data['vat'] = (isset($info['vat'])) ? $info['vat'] : null; // decimal (10,2)	The VAT included on the product price which will be displayed in your merchant panel and will help you to reconcile the transaction. It shall be decimal value (10,2). Example : 4.00
438
        $this->data['discount_amount'] = (isset($info['discount_amount'])) ? $info['discount_amount'] : null; // decimal (10,2)	Discount given on the invoice which will be displayed in your merchant panel and will help you to reconcile the transaction. It shall be decimal value (10,2). Example : 2.00
439
        $this->data['convenience_fee'] = (isset($info['convenience_fee'])) ? $info['convenience_fee'] : null; // decimal (10,2)	Any convenience fee imposed on the invoice which will be displayed in your merchant panel and will help you to reconcile the transaction. It shall be decimal value (10,2). Example : 3.00
440
441
        return $this->data;
442
    }
443
444
    public function setAdditionalInfo(array $info)
445
    {
446
        $this->data['value_a'] = (isset($info['value_a'])) ? $info['value_a'] : null; // value_a [ string (255)	- Extra parameter to pass your meta data if it is needed. Not mandatory]
447
        $this->data['value_b'] = (isset($info['value_b'])) ? $info['value_b'] : null; // value_b [ string (255)	- Extra parameter to pass your meta data if it is needed. Not mandatory]
448
        $this->data['value_c'] = (isset($info['value_c'])) ? $info['value_c'] : null; // value_c [ string (255)	- Extra parameter to pass your meta data if it is needed. Not mandatory]
449
        $this->data['value_d'] = (isset($info['value_d'])) ? $info['value_d'] : null; // value_d [ string (255)	- Extra parameter to pass your meta data if it is needed. Not mandatory]
450
451
        return $this->data;
452
    }
453
}