From 34074fbda20ee2a256c006d7f68d4cfe33b6270f Mon Sep 17 00:00:00 2001 From: AfzalSabbir Date: Sun, 11 Sep 2022 20:46:18 +0600 Subject: [PATCH 01/26] Controller and Library added - Controller added: - SslCommerzPaymentController controller added - Library added: - src\Library\SslCommerz\AbstractSslCommerz.php - src\Library\SslCommerz\SslCommerzInterface.php - src\Library\SslCommerz\SslCommerzNotification.php --- .../SslCommerzPaymentController.php | 313 ++++++++++++ src/Library/SslCommerz/AbstractSslCommerz.php | 123 +++++ .../SslCommerz/SslCommerzInterface.php | 23 + .../SslCommerz/SslCommerzNotification.php | 454 ++++++++++++++++++ 4 files changed, 913 insertions(+) create mode 100644 src/Http/Controllers/SslCommerzPaymentController.php create mode 100644 src/Library/SslCommerz/AbstractSslCommerz.php create mode 100644 src/Library/SslCommerz/SslCommerzInterface.php create mode 100644 src/Library/SslCommerz/SslCommerzNotification.php diff --git a/src/Http/Controllers/SslCommerzPaymentController.php b/src/Http/Controllers/SslCommerzPaymentController.php new file mode 100644 index 0000000..e712fa0 --- /dev/null +++ b/src/Http/Controllers/SslCommerzPaymentController.php @@ -0,0 +1,313 @@ +where('transaction_id', $post_data['tran_id']) + ->updateOrInsert([ + 'name' => $post_data['cus_name'], + 'email' => $post_data['cus_email'], + 'phone' => $post_data['cus_phone'], + 'amount' => $post_data['total_amount'], + 'status' => 'Pending', + 'address' => $post_data['cus_add1'], + 'transaction_id' => $post_data['tran_id'], + 'currency' => $post_data['currency'] + ]); + + $sslc = new SslCommerzNotification(); + # initiate(Transaction Data , false: Redirect to SSLCOMMERZ gateway/ true: Show all the Payement gateway here ) + $payment_options = $sslc->makePayment($post_data, 'hosted'); + + if (!is_array($payment_options)) { + print_r($payment_options); + $payment_options = array(); + } + + } + + public function payViaAjax(Request $request) + { + + # Here you have to receive all the order data to initate the payment. + # Lets your oder trnsaction informations are saving in a table called "orders" + # In orders table order uniq identity is "transaction_id","status" field contain status of the transaction, "amount" is the order amount to be paid and "currency" is for storing Site Currency which will be checked with paid currency. + + $post_data = array(); + $post_data['total_amount'] = '10'; # You cant not pay less than 10 + $post_data['currency'] = "BDT"; + $post_data['tran_id'] = uniqid(); // tran_id must be unique + + # CUSTOMER INFORMATION + $post_data['cus_name'] = 'Customer Name'; + $post_data['cus_email'] = 'customer@mail.com'; + $post_data['cus_add1'] = 'Customer Address'; + $post_data['cus_add2'] = ""; + $post_data['cus_city'] = ""; + $post_data['cus_state'] = ""; + $post_data['cus_postcode'] = ""; + $post_data['cus_country'] = "Bangladesh"; + $post_data['cus_phone'] = '8801XXXXXXXXX'; + $post_data['cus_fax'] = ""; + + # SHIPMENT INFORMATION + $post_data['ship_name'] = "Store Test"; + $post_data['ship_add1'] = "Dhaka"; + $post_data['ship_add2'] = "Dhaka"; + $post_data['ship_city'] = "Dhaka"; + $post_data['ship_state'] = "Dhaka"; + $post_data['ship_postcode'] = "1000"; + $post_data['ship_phone'] = ""; + $post_data['ship_country'] = "Bangladesh"; + + $post_data['shipping_method'] = "NO"; + $post_data['product_name'] = "Computer"; + $post_data['product_category'] = "Goods"; + $post_data['product_profile'] = "physical-goods"; + + # OPTIONAL PARAMETERS + $post_data['value_a'] = "ref001"; + $post_data['value_b'] = "ref002"; + $post_data['value_c'] = "ref003"; + $post_data['value_d'] = "ref004"; + + + #Before going to initiate the payment order status need to update as Pending. + $update_product = DB::table('orders') + ->where('transaction_id', $post_data['tran_id']) + ->updateOrInsert([ + 'name' => $post_data['cus_name'], + 'email' => $post_data['cus_email'], + 'phone' => $post_data['cus_phone'], + 'amount' => $post_data['total_amount'], + 'status' => 'Pending', + 'address' => $post_data['cus_add1'], + 'transaction_id' => $post_data['tran_id'], + 'currency' => $post_data['currency'] + ]); + + $sslc = new SslCommerzNotification(); + # initiate(Transaction Data , false: Redirect to SSLCOMMERZ gateway/ true: Show all the Payement gateway here ) + $payment_options = $sslc->makePayment($post_data, 'checkout', 'json'); + + if (!is_array($payment_options)) { + print_r($payment_options); + $payment_options = array(); + } + + } + + public function success(Request $request) + { + echo "Transaction is Successful"; + + $tran_id = $request->input('tran_id'); + $amount = $request->input('amount'); + $currency = $request->input('currency'); + + $sslc = new SslCommerzNotification(); + + #Check order status in order tabel against the transaction id or order id. + $order_detials = DB::table('orders') + ->where('transaction_id', $tran_id) + ->select('transaction_id', 'status', 'currency', 'amount')->first(); + + if ($order_detials->status == 'Pending') { + $validation = $sslc->orderValidate($tran_id, $amount, $currency, $request->all()); + + if ($validation == TRUE) { + /* + That means IPN did not work or IPN URL was not set in your merchant panel. Here you need to update order status + in order table as Processing or Complete. + Here you can also sent sms or email for successfull transaction to customer + */ + $update_product = DB::table('orders') + ->where('transaction_id', $tran_id) + ->update(['status' => 'Processing']); + + echo "
Transaction is successfully Completed"; + } else { + /* + That means IPN did not work or IPN URL was not set in your merchant panel and Transation validation failed. + Here you need to update order status as Failed in order table. + */ + $update_product = DB::table('orders') + ->where('transaction_id', $tran_id) + ->update(['status' => 'Failed']); + echo "validation Fail"; + } + } else if ($order_detials->status == 'Processing' || $order_detials->status == 'Complete') { + /* + That means through IPN Order status already updated. Now you can just show the customer that transaction is completed. No need to udate database. + */ + echo "Transaction is successfully Completed"; + } else { + #That means something wrong happened. You can redirect customer to your product page. + echo "Invalid Transaction"; + } + + + } + + public function fail(Request $request) + { + $tran_id = $request->input('tran_id'); + + $order_detials = DB::table('orders') + ->where('transaction_id', $tran_id) + ->select('transaction_id', 'status', 'currency', 'amount')->first(); + + if ($order_detials->status == 'Pending') { + $update_product = DB::table('orders') + ->where('transaction_id', $tran_id) + ->update(['status' => 'Failed']); + echo "Transaction is Falied"; + } else if ($order_detials->status == 'Processing' || $order_detials->status == 'Complete') { + echo "Transaction is already Successful"; + } else { + echo "Transaction is Invalid"; + } + + } + + public function cancel(Request $request) + { + $tran_id = $request->input('tran_id'); + + $order_detials = DB::table('orders') + ->where('transaction_id', $tran_id) + ->select('transaction_id', 'status', 'currency', 'amount')->first(); + + if ($order_detials->status == 'Pending') { + $update_product = DB::table('orders') + ->where('transaction_id', $tran_id) + ->update(['status' => 'Canceled']); + echo "Transaction is Cancel"; + } else if ($order_detials->status == 'Processing' || $order_detials->status == 'Complete') { + echo "Transaction is already Successful"; + } else { + echo "Transaction is Invalid"; + } + + + } + + public function ipn(Request $request) + { + #Received all the payement information from the gateway + if ($request->input('tran_id')) #Check transation id is posted or not. + { + + $tran_id = $request->input('tran_id'); + + #Check order status in order tabel against the transaction id or order id. + $order_details = DB::table('orders') + ->where('transaction_id', $tran_id) + ->select('transaction_id', 'status', 'currency', 'amount')->first(); + + if ($order_details->status == 'Pending') { + $sslc = new SslCommerzNotification(); + $validation = + $sslc->orderValidate($tran_id, $order_details->amount, $order_details->currency, $request->all()); + if ($validation == TRUE) { + /* + That means IPN worked. Here you need to update order status + in order table as Processing or Complete. + Here you can also sent sms or email for successful transaction to customer + */ + $update_product = DB::table('orders') + ->where('transaction_id', $tran_id) + ->update(['status' => 'Processing']); + + echo "Transaction is successfully Completed"; + } else { + /* + That means IPN worked, but Transation validation failed. + Here you need to update order status as Failed in order table. + */ + $update_product = DB::table('orders') + ->where('transaction_id', $tran_id) + ->update(['status' => 'Failed']); + + echo "validation Fail"; + } + + } else if ($order_details->status == 'Processing' || $order_details->status == 'Complete') { + + #That means Order status already updated. No need to udate database. + + echo "Transaction is already successfully Completed"; + } else { + #That means something wrong happened. You can redirect customer to your product page. + + echo "Invalid Transaction"; + } + } else { + echo "Invalid Data"; + } + } + +} diff --git a/src/Library/SslCommerz/AbstractSslCommerz.php b/src/Library/SslCommerz/AbstractSslCommerz.php new file mode 100644 index 0000000..6303b35 --- /dev/null +++ b/src/Library/SslCommerz/AbstractSslCommerz.php @@ -0,0 +1,123 @@ +storeId = $storeID; + } + + protected function getStoreId() + { + return $this->storeId; + } + + protected function setStorePassword($storePassword) + { + $this->storePassword = $storePassword; + } + + protected function getStorePassword() + { + return $this->storePassword; + } + + protected function setApiUrl($url) + { + $this->apiUrl = $url; + } + + protected function getApiUrl() + { + return $this->apiUrl; + } + + /** + * @param $data + * @param array $header + * @param bool $setLocalhost + * @return bool|string + */ + public function callToApi($data, $header = [], $setLocalhost = false) + { + $curl = curl_init(); + + if (!$setLocalhost) { + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true); + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2); // The default value for this option is 2. It means, it has to have the same name in the certificate as is in the URL you operate against. + } else { + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); // When the verify value is 0, the connection succeeds regardless of the names in the certificate. + } + + curl_setopt($curl, CURLOPT_URL, $this->getApiUrl()); + curl_setopt($curl, CURLOPT_HEADER, 0); + curl_setopt($curl, CURLOPT_HTTPHEADER, $header); + curl_setopt($curl, CURLOPT_TIMEOUT, 60); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); + + curl_setopt($curl, CURLOPT_POST, 1); + curl_setopt($curl, CURLOPT_POSTFIELDS, $data); + + $response = curl_exec($curl); + $err = curl_error($curl); + $code = curl_getinfo($curl, CURLINFO_HTTP_CODE); + $curlErrorNo = curl_errno($curl); + curl_close($curl); + + if ($code == 200 & !($curlErrorNo)) { + return $response; + } else { + return "FAILED TO CONNECT WITH SSLCOMMERZ API"; + //return "cURL Error #:" . $err; + } + } + + /** + * @param $response + * @param string $type + * @param string $pattern + * @return false|mixed|string + */ + public function formatResponse($response, $type = 'checkout', $pattern = 'json') + { + $sslcz = json_decode($response, true); + + if ($type != 'checkout') { + return $sslcz; + } else { + if (isset($sslcz['GatewayPageURL']) && $sslcz['GatewayPageURL'] != "") { + // this is important to show the popup, return or echo to send json response back + if($this->getApiUrl() != null && $this->getApiUrl() == 'https://securepay.sslcommerz.com') { + $response = json_encode(['status' => 'SUCCESS', 'data' => $sslcz['GatewayPageURL'], 'logo' => $sslcz['storeLogo']]); + } else { + $response = json_encode(['status' => 'success', 'data' => $sslcz['GatewayPageURL'], 'logo' => $sslcz['storeLogo']]); + } + } else { + $response = json_encode(['status' => 'fail', 'data' => null, 'message' => "JSON Data parsing error!"]); + } + + if ($pattern == 'json') { + return $response; + } else { + echo $response; + } + } + } + + /** + * @param $url + * @param bool $permanent + */ + public function redirect($url, $permanent = false) + { + header('Location: ' . $url, true, $permanent ? 301 : 302); + + exit(); + } +} diff --git a/src/Library/SslCommerz/SslCommerzInterface.php b/src/Library/SslCommerz/SslCommerzInterface.php new file mode 100644 index 0000000..602a02a --- /dev/null +++ b/src/Library/SslCommerz/SslCommerzInterface.php @@ -0,0 +1,23 @@ +config = config('sslcommerz'); + + $this->setStoreId($this->config['apiCredentials']['store_id']); + $this->setStorePassword($this->config['apiCredentials']['store_password']); + } + + public function orderValidate($trx_id = '', $amount = 0, $currency = "BDT", $post_data) + { + if ($post_data == '' && $trx_id == '' && !is_array($post_data)) { + $this->error = "Please provide valid transaction ID and post request data"; + return $this->error; + } + + $validation = $this->validate($trx_id, $amount, $currency, $post_data); + + if ($validation) { + return true; + } else { + return false; + } + } + + + # VALIDATE SSLCOMMERZ TRANSACTION + protected function validate($merchant_trans_id, $merchant_trans_amount, $merchant_trans_currency, $post_data) + { + # MERCHANT SYSTEM INFO + if ($merchant_trans_id != "" && $merchant_trans_amount != 0) { + + # CALL THE FUNCTION TO CHECK THE RESULT + $post_data['store_id'] = $this->getStoreId(); + $post_data['store_pass'] = $this->getStorePassword(); + + if ($this->SSLCOMMERZ_hash_varify($this->getStorePassword(), $post_data)) { + + $val_id = urlencode($post_data['val_id']); + $store_id = urlencode($this->getStoreId()); + $store_passwd = urlencode($this->getStorePassword()); + $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"); + + $handle = curl_init(); + curl_setopt($handle, CURLOPT_URL, $requested_url); + curl_setopt($handle, CURLOPT_RETURNTRANSFER, true); + + if ($this->config['connect_from_localhost']) { + curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, 0); + curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, 0); + } else { + curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, 2); + curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, 2); + } + + + $result = curl_exec($handle); + + $code = curl_getinfo($handle, CURLINFO_HTTP_CODE); + + if ($code == 200 && !(curl_errno($handle))) { + + # TO CONVERT AS ARRAY + # $result = json_decode($result, true); + # $status = $result['status']; + + # TO CONVERT AS OBJECT + $result = json_decode($result); + $this->sslc_data = $result; + + # TRANSACTION INFO + $status = $result->status; + $tran_date = $result->tran_date; + $tran_id = $result->tran_id; + $val_id = $result->val_id; + $amount = $result->amount; + $store_amount = $result->store_amount; + $bank_tran_id = $result->bank_tran_id; + $card_type = $result->card_type; + $currency_type = $result->currency_type; + $currency_amount = $result->currency_amount; + + # ISSUER INFO + $card_no = $result->card_no; + $card_issuer = $result->card_issuer; + $card_brand = $result->card_brand; + $card_issuer_country = $result->card_issuer_country; + $card_issuer_country_code = $result->card_issuer_country_code; + + # API AUTHENTICATION + $APIConnect = $result->APIConnect; + $validated_on = $result->validated_on; + $gw_version = $result->gw_version; + + # GIVE SERVICE + if ($status == "VALID" || $status == "VALIDATED") { + if ($merchant_trans_currency == "BDT") { + if (trim($merchant_trans_id) == trim($tran_id) && (abs($merchant_trans_amount - $amount) < 1) && trim($merchant_trans_currency) == trim('BDT')) { + return true; + } else { + # DATA TEMPERED + $this->error = "Data has been tempered"; + return false; + } + } else { + //echo "trim($merchant_trans_id) == trim($tran_id) && ( abs($merchant_trans_amount-$currency_amount) < 1 ) && trim($merchant_trans_currency)==trim($currency_type)"; + if (trim($merchant_trans_id) == trim($tran_id) && (abs($merchant_trans_amount - $currency_amount) < 1) && trim($merchant_trans_currency) == trim($currency_type)) { + return true; + } else { + # DATA TEMPERED + $this->error = "Data has been tempered"; + return false; + } + } + } else { + # FAILED TRANSACTION + $this->error = "Failed Transaction"; + return false; + } + } else { + # Failed to connect with SSLCOMMERZ + $this->error = "Faile to connect with SSLCOMMERZ"; + return false; + } + } else { + # Hash validation failed + $this->error = "Hash validation failed"; + return false; + } + } else { + # INVALID DATA + $this->error = "Invalid data"; + return false; + } + } + + # FUNCTION TO CHECK HASH VALUE + protected function SSLCOMMERZ_hash_varify($store_passwd = "", $post_data) + { + if (isset($post_data) && isset($post_data['verify_sign']) && isset($post_data['verify_key'])) { + # NEW ARRAY DECLARED TO TAKE VALUE OF ALL POST + $pre_define_key = explode(',', $post_data['verify_key']); + + $new_data = array(); + if (!empty($pre_define_key)) { + foreach ($pre_define_key as $value) { +// if (isset($post_data[$value])) { + $new_data[$value] = ($post_data[$value]); +// } + } + } + # ADD MD5 OF STORE PASSWORD + $new_data['store_passwd'] = md5($store_passwd); + + # SORT THE KEY AS BEFORE + ksort($new_data); + + $hash_string = ""; + foreach ($new_data as $key => $value) { + $hash_string .= $key . '=' . ($value) . '&'; + } + $hash_string = rtrim($hash_string, '&'); + + if (md5($hash_string) == $post_data['verify_sign']) { + + return true; + + } else { + $this->error = "Verification signature not matched"; + return false; + } + } else { + $this->error = 'Required data mission. ex: verify_key, verify_sign'; + return false; + } + } + + /** + * @param array $requestData + * @param string $type + * @param string $pattern + * @return false|mixed|string + */ + public function makePayment(array $requestData, $type = 'checkout', $pattern = 'json') + { + if (empty($requestData)) { + 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"; + } + + $header = []; + + $this->setApiUrl($this->config['apiDomain'] . $this->config['apiUrl']['make_payment']); + + // Set the required/additional params + $this->setParams($requestData); + + // Set the authentication information + $this->setAuthenticationInfo(); + + // Now, call the Gateway API + $response = $this->callToApi($this->data, $header, $this->config['connect_from_localhost']); + + $formattedResponse = $this->formatResponse($response, $type, $pattern); // Here we will define the response pattern + + if ($type == 'hosted') { + if (isset($formattedResponse['GatewayPageURL']) && $formattedResponse['GatewayPageURL'] != '') { + $this->redirect($formattedResponse['GatewayPageURL']); + } else { + $errorMessage = "No redirect URL found!"; + return $errorMessage; + } + } else { + return $formattedResponse; + } + } + + + protected function setSuccessUrl() + { + $this->successUrl = url('/') . $this->config['success_url']; + } + + protected function getSuccessUrl() + { + return $this->successUrl; + } + + protected function setFailedUrl() + { + $this->failedUrl = url('/') . $this->config['failed_url']; + } + + protected function getFailedUrl() + { + return $this->failedUrl; + } + + protected function setCancelUrl() + { + $this->cancelUrl = url('/') . $this->config['cancel_url']; + } + + protected function getCancelUrl() + { + return $this->cancelUrl; + } + + public function setParams($requestData) + { + ## Integration Required Parameters + $this->setRequiredInfo($requestData); + + ## Customer Information + $this->setCustomerInfo($requestData); + + ## Shipment Information + $this->setShipmentInfo($requestData); + + ## Product Information + $this->setProductInfo($requestData); + + ## Customized or Additional Parameters + $this->setAdditionalInfo($requestData); + } + + public function setAuthenticationInfo() + { + $this->data['store_id'] = $this->getStoreId(); + $this->data['store_passwd'] = $this->getStorePassword(); + + return $this->data; + } + + public function setRequiredInfo(array $info) + { + $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 + $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. + $this->data['tran_id'] = $info['tran_id']; // string (30) Mandatory - Unique transaction ID to identify your order in both your end and SSLCommerz + $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 + + // Set the SUCCESS, FAIL, CANCEL Redirect URL before setting the other parameters + $this->setSuccessUrl(); + $this->setFailedUrl(); + $this->setCancelUrl(); + + $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) + $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) + $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) + + /* + * IPN is very important feature to integrate with your site(s). + * 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. + * + * Type: string (255) + * 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). + * The data will be communicated as SSLCOMMERZ Server to your Server. So, customer session will not work. + * */ + $this->data['ipn_url'] = (isset($info['ipn_url'])) ? $info['ipn_url'] : null; + + /* + * Type: string (30) + * 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. + * Multi Card: + brac_visa = BRAC VISA + dbbl_visa = Dutch Bangla VISA + city_visa = City Bank Visa + ebl_visa = EBL Visa + sbl_visa = Southeast Bank Visa + brac_master = BRAC MASTER + dbbl_master = MASTER Dutch-Bangla + city_master = City Master Card + ebl_master = EBL Master Card + sbl_master = Southeast Bank Master Card + city_amex = City Bank AMEX + qcash = QCash + dbbl_nexus = DBBL Nexus + bankasia = Bank Asia IB + abbank = AB Bank IB + ibbl = IBBL IB and Mobile Banking + mtbl = Mutual Trust Bank IB + bkash = Bkash Mobile Banking + dbblmobilebanking = DBBL Mobile Banking + city = City Touch IB + upay = Upay + tapnpay = Tap N Pay Gateway + * GROUP GATEWAY + internetbank = For all internet banking + mobilebank = For all mobile banking + othercard = For all cards except visa,master and amex + visacard = For all visa + mastercard = For All Master card + amexcard = For Amex Card + * */ + $this->data['multi_card_name'] = (isset($info['multi_card_name'])) ? $info['multi_card_name'] : null; + + /* + * Type: string (255) + * 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. + * Example: 371598,371599,376947,376948,376949 + * */ + $this->data['allowed_bin'] = (isset($info['allowed_bin'])) ? $info['allowed_bin'] : null; + + ## Parameters to Handle EMI Transaction ## + $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 + $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 + $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 + + return $this->data; + } + + public function setCustomerInfo(array $info) + { + $this->data['cus_name'] = $info['cus_name']; // string (50) Mandatory - Your customer name to address the customer in payment receipt email + $this->data['cus_email'] = $info['cus_email']; // string (50) Mandatory - Valid email address of your customer to send payment receipt from SSLCommerz end + $this->data['cus_add1'] = $info['cus_add1']; // string (50) Mandatory - Address of your customer. Not mandatory but useful if provided + $this->data['cus_add2'] = $info['cus_add2']; // string (50) Address line 2 of your customer. Not mandatory but useful if provided + $this->data['cus_city'] = $info['cus_city']; // string (50) Mandatory - City of your customer. Not mandatory but useful if provided + $this->data['cus_state'] = (isset($info['cus_state'])) ? $info['cus_state'] : null; // string (50) State of your customer. Not mandatory but useful if provided + $this->data['cus_postcode'] = $info['cus_postcode']; // string (30) Mandatory - Postcode of your customer. Not mandatory but useful if provided + $this->data['cus_country'] = $info['cus_country']; // string (50) Mandatory - Country of your customer. Not mandatory but useful if provided + $this->data['cus_phone'] = $info['cus_phone']; // string (20) Mandatory - The phone/mobile number of your customer to contact if any issue arises + $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 + + return $this->data; + } + + public function setShipmentInfo(array $info) + { + + $this->data['shipping_method'] = $info['shipping_method']; // string (50) Mandatory - Shipping method of the order. Example: YES or NO or Courier + $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 + $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 + $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 + $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 + $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 + $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 + $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 + $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 + + return $this->data; + } + + public function setProductInfo(array $info) + { + + $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 + $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 + + /* + * String (100) + * Mandatory - Mention goods vertical. It is very much necessary for online transactions to avoid chargeback. + * Please use the below keys : + 1) general + 2) physical-goods + 3) non-physical-goods + 4) airline-tickets + 5) travel-vertical + 6) telecom-vertical + */ + $this->data['product_profile'] = (isset($info['product_profile'])) ? $info['product_profile'] : ''; + + $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 + $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 + $this->data['pnr'] = (isset($info['pnr'])) ? $info['pnr'] : null; // string (50) Mandatory, if product_profile is airline-tickets - Provide the PNR. + $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 + $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. + $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 + $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 + $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 + $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 + $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 + $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 + $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 + + /* + * Type: JSON + * JSON data with two elements. product : Max 255 characters, quantity : Quantity in numeric value and amount : Decimal (12,2) + * Example: + [{"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"}] + * */ + $this->data['cart'] = (isset($info['cart'])) ? $info['cart'] : null; + $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 + $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 + $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 + $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 + + return $this->data; + } + + public function setAdditionalInfo(array $info) + { + $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] + $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] + $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] + $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] + + return $this->data; + } +} From 7e813c286fffbb6446dbb17a71eb8dd36a4ba85d Mon Sep 17 00:00:00 2001 From: AfzalSabbir Date: Sun, 11 Sep 2022 20:58:20 +0600 Subject: [PATCH 02/26] publishable config added Config added: sslcommerz.php --- config/s_s_lara_commerz.php | 5 ----- config/sslcommerz.php | 25 +++++++++++++++++++++++++ src/SSLaraCommerzServiceProvider.php | 2 +- 3 files changed, 26 insertions(+), 6 deletions(-) delete mode 100644 config/s_s_lara_commerz.php create mode 100644 config/sslcommerz.php diff --git a/config/s_s_lara_commerz.php b/config/s_s_lara_commerz.php deleted file mode 100644 index 035fcd5..0000000 --- a/config/s_s_lara_commerz.php +++ /dev/null @@ -1,5 +0,0 @@ - env('PROJECT_PATH'), + // For Sandbox, use "https://sandbox.sslcommerz.com" + // For Live, use "https://securepay.sslcommerz.com" + 'apiDomain' => env("API_DOMAIN_URL", "https://sandbox.sslcommerz.com"), + 'apiCredentials' => [ + 'store_id' => env("STORE_ID"), + 'store_password' => env("STORE_PASSWORD"), + ], + 'apiUrl' => [ + 'make_payment' => "/gwprocess/v4/api.php", + 'transaction_status' => "/validator/api/merchantTransIDvalidationAPI.php", + 'order_validate' => "/validator/api/validationserverAPI.php", + 'refund_payment' => "/validator/api/merchantTransIDvalidationAPI.php", + 'refund_status' => "/validator/api/merchantTransIDvalidationAPI.php", + ], + 'connect_from_localhost' => env("IS_LOCALHOST", true), // For Sandbox, use "true", For Live, use "false" + 'success_url' => '/success', + 'failed_url' => '/fail', + 'cancel_url' => '/cancel', + 'ipn_url' => '/ipn', +]; diff --git a/src/SSLaraCommerzServiceProvider.php b/src/SSLaraCommerzServiceProvider.php index ab5cda0..fc6d1c7 100644 --- a/src/SSLaraCommerzServiceProvider.php +++ b/src/SSLaraCommerzServiceProvider.php @@ -71,7 +71,7 @@ public function publishConfig() { if ($this->app->runningInConsole()) { $this->publishes([ - __DIR__ . '/../config/SSLaraCommerz.php' => config_path('SSLaraCommerz.php'), + __DIR__ . '/../config/sslcommerz.php' => config_path('sslcommerz.php'), ], 'config'); } } From fca491231de5065e6145bee2af45afb97fe7310c Mon Sep 17 00:00:00 2001 From: AfzalSabbir Date: Sun, 11 Sep 2022 21:03:49 +0600 Subject: [PATCH 03/26] Routes added --- src/Http/routes.php | 20 ++++++++++++++++++++ src/SSLaraCommerzServiceProvider.php | 14 +++++++------- 2 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 src/Http/routes.php diff --git a/src/Http/routes.php b/src/Http/routes.php new file mode 100644 index 0000000..961f0ac --- /dev/null +++ b/src/Http/routes.php @@ -0,0 +1,20 @@ +group(function () { + Route::get('/example1', 'exampleEasyCheckout'); + Route::get('/example2', 'exampleHostedCheckout'); + + Route::post('/pay', 'index'); + Route::post('/pay-via-ajax', 'payViaAjax'); + + Route::post('/success', 'success'); + Route::post('/fail', 'fail'); + Route::post('/cancel', 'cancel'); + + Route::post('/ipn', 'ipn'); +}); +//SSLCOMMERZ END diff --git a/src/SSLaraCommerzServiceProvider.php b/src/SSLaraCommerzServiceProvider.php index fc6d1c7..73f7f76 100644 --- a/src/SSLaraCommerzServiceProvider.php +++ b/src/SSLaraCommerzServiceProvider.php @@ -36,16 +36,16 @@ private function registerRoutes() } /** - * Get route group configuration array. - * - * @return array - */ + * Get route group configuration array. + * + * @return array + */ private function routeConfiguration() { return [ - 'namespace' => "AfzalSabbir\SSLaraCommerz\Http\Controllers", - 'middleware' => 'api', - 'prefix' => 'api' + 'namespace' => "AfzalSabbir\SSLaraCommerz\Http\Controllers", + // 'middleware' => 'api', + // 'prefix' => 'api' ]; } From d124a28d977201336701fd58f605186cc841ba04 Mon Sep 17 00:00:00 2001 From: AfzalSabbir Date: Sun, 11 Sep 2022 21:06:52 +0600 Subject: [PATCH 04/26] Migrations added --- .../2022_09_11_134122_create_orders_table.php | 50 +++++++++++++++++++ src/SSLaraCommerzServiceProvider.php | 2 +- 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 database/migrations/2022_09_11_134122_create_orders_table.php diff --git a/database/migrations/2022_09_11_134122_create_orders_table.php b/database/migrations/2022_09_11_134122_create_orders_table.php new file mode 100644 index 0000000..4d7b7c2 --- /dev/null +++ b/database/migrations/2022_09_11_134122_create_orders_table.php @@ -0,0 +1,50 @@ +id(); + $table->string('name', 191)->nullable(); + $table->string('email', 100)->nullable(); + $table->string('phone', 20)->nullable(); + $table->double('amount')->nullable(); + $table->text('address')->nullable(); + $table->string('status', 10)->nullable(); + $table->string('transaction_id', 191)->nullable(); + $table->string('currency', 20)->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('orders'); + } +}; diff --git a/src/SSLaraCommerzServiceProvider.php b/src/SSLaraCommerzServiceProvider.php index 73f7f76..55eb281 100644 --- a/src/SSLaraCommerzServiceProvider.php +++ b/src/SSLaraCommerzServiceProvider.php @@ -19,7 +19,7 @@ public function boot() $this->publishConfig(); // $this->loadViewsFrom(__DIR__.'/resources/views', 'sslaracommerz'); - // $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); + $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); // $this->registerRoutes(); } From 326560a3f91b39a06aa5ae3972163a5332fd9f74 Mon Sep 17 00:00:00 2001 From: AfzalSabbir Date: Sun, 11 Sep 2022 21:09:57 +0600 Subject: [PATCH 05/26] Views added --- src/SSLaraCommerzServiceProvider.php | 4 +- .../views/exampleEasycheckout.blade.php | 218 ++++++++++++++++++ src/resources/views/exampleHosted.blade.php | 188 +++++++++++++++ 3 files changed, 408 insertions(+), 2 deletions(-) create mode 100644 src/resources/views/exampleEasycheckout.blade.php create mode 100644 src/resources/views/exampleHosted.blade.php diff --git a/src/SSLaraCommerzServiceProvider.php b/src/SSLaraCommerzServiceProvider.php index 55eb281..006c5e6 100644 --- a/src/SSLaraCommerzServiceProvider.php +++ b/src/SSLaraCommerzServiceProvider.php @@ -18,9 +18,9 @@ public function boot() $this->publishConfig(); - // $this->loadViewsFrom(__DIR__.'/resources/views', 'sslaracommerz'); + $this->loadViewsFrom(__DIR__.'/resources/views', 'SSLaraCommerz'); $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); - // $this->registerRoutes(); + $this->registerRoutes(); } /** diff --git a/src/resources/views/exampleEasycheckout.blade.php b/src/resources/views/exampleEasycheckout.blade.php new file mode 100644 index 0000000..d82920a --- /dev/null +++ b/src/resources/views/exampleEasycheckout.blade.php @@ -0,0 +1,218 @@ + + + + + + + + Example - EasyCheckout (Popup) | SSLCommerz + + + + + + + +
+
+

EasyCheckout (Popup) - SSLCommerz

+ +

Below is an example form built entirely with Bootstrap’s form controls. We have provided this + sample form for understanding EasyCheckout (Popup) Payment integration with SSLCommerz.

+
+ +
+
+

+ Your cart + 3 +

+
    +
  • +
    +
    Product name
    + Brief description +
    + 1000 +
  • +
  • +
    +
    Second product
    + Brief description +
    + 50 +
  • +
  • +
    +
    Third item
    + Brief description +
    + 150 +
  • +
  • + Total (BDT) + 1200 TK +
  • +
+
+
+

Billing address

+
+
+
+ + +
+ Valid customer name is required. +
+
+
+ +
+ +
+
+ +88 +
+ +
+ Your Mobile number is required. +
+
+
+ +
+ + +
+ Please enter a valid email address for shipping updates. +
+
+ +
+ + +
+ Please enter your shipping address. +
+
+ +
+ + +
+ +
+
+ + +
+ Please select a valid country. +
+
+
+ + +
+ Please provide a valid state. +
+
+
+ + +
+ Zip code required. +
+
+
+
+
+ + + +
+
+ + +
+
+ +
+
+
+ + +
+ + + + + + + + diff --git a/src/resources/views/exampleHosted.blade.php b/src/resources/views/exampleHosted.blade.php new file mode 100644 index 0000000..79c5373 --- /dev/null +++ b/src/resources/views/exampleHosted.blade.php @@ -0,0 +1,188 @@ + + + + + + + + Example - Hosted Checkout | SSLCommerz + + + + + + + +
+
+

Hosted Payment - SSLCommerz

+

Below is an example form built entirely with Bootstrap’s form controls. We have provided this sample form for understanding Hosted Checkout Payment with SSLCommerz.

+
+ +
+
+

+ Your cart + 3 +

+
    +
  • +
    +
    Product name
    + Brief description +
    + 1000 +
  • +
  • +
    +
    Second product
    + Brief description +
    + 50 +
  • +
  • +
    +
    Third item
    + Brief description +
    + 150 +
  • +
  • + Total (BDT) + 1200 TK +
  • +
+
+
+

Billing address

+
+ +
+
+ + +
+ Valid customer name is required. +
+
+
+ +
+ +
+
+ +88 +
+ +
+ Your Mobile number is required. +
+
+
+ +
+ + +
+ Please enter a valid email address for shipping updates. +
+
+ +
+ + +
+ Please enter your shipping address. +
+
+ +
+ + +
+ +
+
+ + +
+ Please select a valid country. +
+
+
+ + +
+ Please provide a valid state. +
+
+
+ + +
+ Zip code required. +
+
+
+
+
+ + + +
+
+ + +
+
+ +
+
+
+ + +
+ + + + From a1044e5c37158f1b38c396c016935812932895e9 Mon Sep 17 00:00:00 2001 From: AfzalSabbir Date: Sun, 11 Sep 2022 21:12:22 +0600 Subject: [PATCH 06/26] Update SslCommerzPaymentController.php --- src/Http/Controllers/SslCommerzPaymentController.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Http/Controllers/SslCommerzPaymentController.php b/src/Http/Controllers/SslCommerzPaymentController.php index e712fa0..56ee264 100644 --- a/src/Http/Controllers/SslCommerzPaymentController.php +++ b/src/Http/Controllers/SslCommerzPaymentController.php @@ -9,15 +9,14 @@ class SslCommerzPaymentController extends Controller { - public function exampleEasyCheckout() { - return view('exampleEasycheckout'); + return view('SSLaraCommerz::exampleEasycheckout'); } public function exampleHostedCheckout() { - return view('exampleHosted'); + return view('SSLaraCommerz::exampleHosted'); } public function index(Request $request) @@ -91,7 +90,6 @@ public function index(Request $request) public function payViaAjax(Request $request) { - # Here you have to receive all the order data to initate the payment. # Lets your oder trnsaction informations are saving in a table called "orders" # In orders table order uniq identity is "transaction_id","status" field contain status of the transaction, "amount" is the order amount to be paid and "currency" is for storing Site Currency which will be checked with paid currency. @@ -309,5 +307,4 @@ public function ipn(Request $request) echo "Invalid Data"; } } - } From bd41e3c5419811be564a4950c7b1f511cf7d86e9 Mon Sep 17 00:00:00 2001 From: AfzalSabbir Date: Sun, 11 Sep 2022 21:30:32 +0600 Subject: [PATCH 07/26] Updated getFacadeAccessor return Changed mergeConfigFrom --- src/SSLaraCommerzFacade.php | 2 +- src/SSLaraCommerzServiceProvider.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SSLaraCommerzFacade.php b/src/SSLaraCommerzFacade.php index d391a5f..bd0e462 100644 --- a/src/SSLaraCommerzFacade.php +++ b/src/SSLaraCommerzFacade.php @@ -13,6 +13,6 @@ class SSLaraCommerzFacade extends Facade */ protected static function getFacadeAccessor() { - return 'sslaracommerz'; + return 'SSLaraCommerz'; } } diff --git a/src/SSLaraCommerzServiceProvider.php b/src/SSLaraCommerzServiceProvider.php index 006c5e6..d6f45f1 100644 --- a/src/SSLaraCommerzServiceProvider.php +++ b/src/SSLaraCommerzServiceProvider.php @@ -14,7 +14,7 @@ class SSLaraCommerzServiceProvider extends ServiceProvider */ public function boot() { - $this->mergeConfigFrom(__DIR__ . '/../config/SSLaraCommerz.php', 'sslaracommerz'); + $this->mergeConfigFrom(__DIR__ . '/../config/sslcommerz.php', 'sslaracommerz'); $this->publishConfig(); From e3a2c0b642ca8c4ae43a45d6699bb50676d78e66 Mon Sep 17 00:00:00 2001 From: AfzalSabbir Date: Sun, 11 Sep 2022 21:40:38 +0600 Subject: [PATCH 08/26] publishViews & publishMigrations --- .../SslCommerzPaymentController.php | 4 +-- src/SSLaraCommerzServiceProvider.php | 34 +++++++++++++++++-- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/Http/Controllers/SslCommerzPaymentController.php b/src/Http/Controllers/SslCommerzPaymentController.php index 56ee264..f2528af 100644 --- a/src/Http/Controllers/SslCommerzPaymentController.php +++ b/src/Http/Controllers/SslCommerzPaymentController.php @@ -11,12 +11,12 @@ class SslCommerzPaymentController extends Controller { public function exampleEasyCheckout() { - return view('SSLaraCommerz::exampleEasycheckout'); + return view('sslaracommerz::exampleEasycheckout'); } public function exampleHostedCheckout() { - return view('SSLaraCommerz::exampleHosted'); + return view('sslaracommerz::exampleHosted'); } public function index(Request $request) diff --git a/src/SSLaraCommerzServiceProvider.php b/src/SSLaraCommerzServiceProvider.php index d6f45f1..067be4b 100644 --- a/src/SSLaraCommerzServiceProvider.php +++ b/src/SSLaraCommerzServiceProvider.php @@ -17,9 +17,11 @@ public function boot() $this->mergeConfigFrom(__DIR__ . '/../config/sslcommerz.php', 'sslaracommerz'); $this->publishConfig(); + $this->publishViews(); + $this->publishMigrations(); - $this->loadViewsFrom(__DIR__.'/resources/views', 'SSLaraCommerz'); - $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); + $this->loadViewsFrom(__DIR__ . '/resources/views', 'sslaracommerz'); + $this->loadMigrationsFrom(__DIR__ . '/../database/migrations'); $this->registerRoutes(); } @@ -75,4 +77,32 @@ public function publishConfig() ], 'config'); } } + + /** + * Publish Views + * + * @return void + */ + public function publishViews() + { + if ($this->app->runningInConsole()) { + $this->publishes([ + __DIR__ . '/resources/views' => resource_path('views'), + ]); + } + } + + /** + * Publish Migrations + * + * @return void + */ + public function publishMigrations() + { + if ($this->app->runningInConsole()) { + $this->publishes([ + __DIR__ . '/../database/migrations' => database_path('migrations'), + ]); + } + } } From 22899f9f7fb156d16aa896eba6fcc83722edae7d Mon Sep 17 00:00:00 2001 From: AfzalSabbir Date: Sun, 11 Sep 2022 21:51:51 +0600 Subject: [PATCH 09/26] Update routes.php --- src/Http/routes.php | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/Http/routes.php b/src/Http/routes.php index 961f0ac..8bfd43c 100644 --- a/src/Http/routes.php +++ b/src/Http/routes.php @@ -1,20 +1,17 @@ group(function () { - Route::get('/example1', 'exampleEasyCheckout'); - Route::get('/example2', 'exampleHostedCheckout'); +Route::get('/example1', 'SslCommerzPaymentController@exampleEasyCheckout'); +Route::get('/example2', 'SslCommerzPaymentController@exampleHostedCheckout'); - Route::post('/pay', 'index'); - Route::post('/pay-via-ajax', 'payViaAjax'); +Route::post('/pay', 'SslCommerzPaymentController@index'); +Route::post('/pay-via-ajax', 'SslCommerzPaymentController@payViaAjax'); - Route::post('/success', 'success'); - Route::post('/fail', 'fail'); - Route::post('/cancel', 'cancel'); +Route::post('/success', 'SslCommerzPaymentController@success'); +Route::post('/fail', 'SslCommerzPaymentController@fail'); +Route::post('/cancel', 'SslCommerzPaymentController@cancel'); - Route::post('/ipn', 'ipn'); -}); +Route::post('/ipn', 'SslCommerzPaymentController@ipn'); //SSLCOMMERZ END From 55628f762bca7aa0c5617fa258c32aa7a3af756c Mon Sep 17 00:00:00 2001 From: AfzalSabbir Date: Sun, 11 Sep 2022 22:06:07 +0600 Subject: [PATCH 10/26] tags added --- src/Models/Order.php | 11 ++++++++ src/SSLaraCommerzServiceProvider.php | 40 ++++++++++++++++++++++++---- 2 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 src/Models/Order.php diff --git a/src/Models/Order.php b/src/Models/Order.php new file mode 100644 index 0000000..cdd25fa --- /dev/null +++ b/src/Models/Order.php @@ -0,0 +1,11 @@ +publishConfig(); $this->publishViews(); $this->publishMigrations(); + //$this->publishModel(); + $this->publishAssets(); $this->loadViewsFrom(__DIR__ . '/resources/views', 'sslaracommerz'); $this->loadMigrationsFrom(__DIR__ . '/../database/migrations'); @@ -69,7 +71,7 @@ public function register() * * @return void */ - public function publishConfig() + public function publishConfig(): void { if ($this->app->runningInConsole()) { $this->publishes([ @@ -83,12 +85,12 @@ public function publishConfig() * * @return void */ - public function publishViews() + public function publishViews(): void { if ($this->app->runningInConsole()) { $this->publishes([ __DIR__ . '/resources/views' => resource_path('views'), - ]); + ], 'views'); } } @@ -97,12 +99,40 @@ public function publishViews() * * @return void */ - public function publishMigrations() + public function publishMigrations(): void { if ($this->app->runningInConsole()) { $this->publishes([ __DIR__ . '/../database/migrations' => database_path('migrations'), - ]); + ], 'migrations'); + } + } + + /** + * Publish Model + * + * @return void + */ + public function publishModel(): void + { + if ($this->app->runningInConsole()) { + $this->publishes([ + __DIR__ . '/Models/Order.php' => app_path('Models/Order.php'), + ], 'model'); + } + } + + /** + * Publish Assets + * + * @return void + */ + public function publishAssets(): void + { + if ($this->app->runningInConsole()) { + $this->publishes([ + __DIR__ . '/../public/assets' => public_path('assets'), + ], 'public-assets'); } } } From b1a7d9372b77bf397e505c8f23e3f528ae8790b9 Mon Sep 17 00:00:00 2001 From: AfzalSabbir Date: Sun, 11 Sep 2022 22:13:02 +0600 Subject: [PATCH 11/26] Live and Sandbox js added --- public/assets/js/live.js | 9 +++++++++ public/assets/js/sandbox.js | 9 +++++++++ src/Http/routes.php | 4 ++-- 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 public/assets/js/live.js create mode 100644 public/assets/js/sandbox.js diff --git a/public/assets/js/live.js b/public/assets/js/live.js new file mode 100644 index 0000000..d73c206 --- /dev/null +++ b/public/assets/js/live.js @@ -0,0 +1,9 @@ +(function (window, document) { + var loader = function () { + var script = document.createElement("script"), tag = document.getElementsByTagName("script")[0]; + script.src = "https://seamless-epay.sslcommerz.com/embed.min.js?" + Math.random().toString(36).substring(7); + tag.parentNode.insertBefore(script, tag); + }; + + window.addEventListener ? window.addEventListener("load", loader, false) : window.attachEvent("onload", loader); +})(window, document); diff --git a/public/assets/js/sandbox.js b/public/assets/js/sandbox.js new file mode 100644 index 0000000..49393a7 --- /dev/null +++ b/public/assets/js/sandbox.js @@ -0,0 +1,9 @@ +(function (window, document) { + var loader = function () { + var script = document.createElement("script"), tag = document.getElementsByTagName("script")[0]; + script.src = "https://sandbox.sslcommerz.com/embed.min.js?" + Math.random().toString(36).substring(7); + tag.parentNode.insertBefore(script, tag); + }; + + window.addEventListener ? window.addEventListener("load", loader, false) : window.attachEvent("onload", loader); +})(window, document); diff --git a/src/Http/routes.php b/src/Http/routes.php index 8bfd43c..b1a6223 100644 --- a/src/Http/routes.php +++ b/src/Http/routes.php @@ -2,7 +2,7 @@ use Illuminate\Support\Facades\Route; -// SSLCOMMERZ Start +// SSLaraCommerz Start Route::get('/example1', 'SslCommerzPaymentController@exampleEasyCheckout'); Route::get('/example2', 'SslCommerzPaymentController@exampleHostedCheckout'); @@ -14,4 +14,4 @@ Route::post('/cancel', 'SslCommerzPaymentController@cancel'); Route::post('/ipn', 'SslCommerzPaymentController@ipn'); -//SSLCOMMERZ END +//SSLaraCommerz End From 6ec0340dfe712ff96e385d25b4752504765a3681 Mon Sep 17 00:00:00 2001 From: AfzalSabbir Date: Sun, 11 Sep 2022 22:30:13 +0600 Subject: [PATCH 12/26] Update SSLaraCommerzServiceProvider.php --- src/SSLaraCommerzServiceProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SSLaraCommerzServiceProvider.php b/src/SSLaraCommerzServiceProvider.php index 602b994..0702605 100644 --- a/src/SSLaraCommerzServiceProvider.php +++ b/src/SSLaraCommerzServiceProvider.php @@ -14,7 +14,7 @@ class SSLaraCommerzServiceProvider extends ServiceProvider */ public function boot() { - $this->mergeConfigFrom(__DIR__ . '/../config/sslcommerz.php', 'sslaracommerz'); + $this->mergeConfigFrom(__DIR__ . '/../config/sslcommerz.php', 'sslcommerz'); $this->publishConfig(); $this->publishViews(); From e5de321a26a8990a515e078177ec13a8242bc068 Mon Sep 17 00:00:00 2001 From: AfzalSabbir Date: Sun, 11 Sep 2022 23:19:34 +0600 Subject: [PATCH 13/26] Update README.md --- README.md | 159 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 153 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 685980f..f868d4b 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,23 @@ -# SSLaraCommerz +# SSLaraCommerz - Laravel Package + +> A package for SSLCommerz Payment Gateway + +[![Latest Version on Packagist](https://img.shields.io/packagist/v/hasib32/sslaracommerz.svg?style=flat-square)](https://packagist.org/packages/hasib32/sslaracommerz) +[![Build Status](https://img.shields.io/travis/hasib32/sslaracommerz/master.svg?style=flat-square)](https://travis-ci.org/hasib32/sslaracommerz) +[![Quality Score](https://img.shields.io/scrutinizer/g/hasib32/sslaracommerz.svg?style=flat-square)](https://scrutinizer-ci.com/g/hasib32/sslaracommerz) +[![Total Downloads](https://img.shields.io/packagist/dt/hasib32/sslaracommerz.svg?style=flat-square)](https://packagist.org/packages/hasib32/sslaracommerz) +[![Latest Version on Packagist](https://img.shields.io/packagist/v/hasib32/sslaracommerz.svg?style=flat-square)](https://packagist.org/packages/hasib32/sslaracommerz) +[![Total Downloads](https://img.shields.io/packagist/dt/hasib32/sslaracommerz.svg?style=flat-square)](https://packagist.org/packages/hasib32/sslaracommerz) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md) [![Travis](https://img.shields.io/travis/afzalsabbir/sslaracommerz.svg?style=flat-square)]() [![Total Downloads](https://img.shields.io/packagist/dt/afzalsabbir/sslaracommerz.svg?style=flat-square)](https://packagist.org/packages/afzalsabbir/sslaracommerz) +__Tags:__ Payment Gateway, SSLCommerz, IPN, Laravel, SSLaraCommerz + +__Requires:__ Laravel >= 5.6 and MySQL + +__License:__ MIT License ## Install @@ -11,11 +25,147 @@ composer require afzalsabbir/sslaracommerz ``` - ## Usage Write a few lines about the usage of this package. +## Vendor Publish + +### Required + + + +```bash +# Public Assets +php artisan vendor:publish --provider="AfzalSabbir\SSLaraCommerz\SSLaraCommerzServiceProvider" --tag="public-assets" +``` + + + +### Optional + + + +```bash +# Config +php artisan vendor:publish --provider="AfzalSabbir\SSLaraCommerz\SSLaraCommerzServiceProvider" --tag="config" + +# Views +## Namespace: sslaracommerz +php artisan vendor:publish --provider="AfzalSabbir\SSLaraCommerz\SSLaraCommerzServiceProvider" --tag="views" + +# Migrations +php artisan vendor:publish --provider="AfzalSabbir\SSLaraCommerz\SSLaraCommerzServiceProvider" --tag="migrations" +``` + + + +## Instructions + +* __Step 1:__ Install the package using composer command. _(i.e. `composer require afzalsabbir/sslaracommerz`)_ + +[//]: # (* __Step 2:__ Copy the `Library` folder and put it in the laravel project's `app/` directory. If needed, then run `composer dump -o`.) + +* __Step 3:__ Copy the `config/sslcommerz.php` file into your project's `config/` folder. + +Now, we have already copied the core library files. Let's do copy some other helpers files that is provided to +understand the integration process. The other files are not related to core library. + +* __Optional:__ If you later encounter issues with session destroying after redirect, you can + set ```'same_site' => null,``` in your `config/session.php` file. + +* __Step 4:__ Add `STORE_ID` and `STORE_PASSWORD` values on your project's `.env` file. You can register for a store + at [https://developer.sslcommerz.com/registration/](https://developer.sslcommerz.com/registration/) + +[//]: # (* __Step 5:__ Copy the `SslCommerzPaymentController` into your project's `Controllers` folder.) + +* __Step 6:__ Copy the defined routes from `routes/web.php` into your project's route file. + +* __Step 7:__ Add the below routes into the `$excepts` array of `VerifyCsrfToken` middleware. + +```php +protected $except = [ + '/pay-via-ajax', '/success','/cancel','/fail','/ipn' +]; +``` + +* __Step 8:__ Copy the `resources/views/*.blade.php` files into your project's `resources/views/` folder. + +Now, let's go to the main integration part. + +* __Step 9:__ To integrate popup checkout, use the below script before the end of body tag. + +##### For Sandbox + +```html + +``` + +> or, Publish the [Public Assets](#public-assets) and use the below `sandbox` script + +```html + + +``` + +--- + +##### For Live + +```html + +``` + +> or, Publish the [Public Assets](#public-assets) and use the below `live` script + +```html + +``` + +* __Step 10:__ Use the below button where you want to show the **"Pay Now"** button: + +```html + + +``` + +* __Step 11:__ For EasyCheckout (Popup) integration, you can update the `checkout_ajax.php` or use a different file + according to your need. We have provided a basic sample page from where you can kickstart the payment gateway + integration. + +* __Step 12:__ For Hosted Checkout integration, you can update the `checkout_hosted.php` or use a different file + according to your need. We have provided a basic sample page from where you can kickstart the payment gateway + integration. + +* __Step 13:__ For redirecting action from SSLCommerz Payment gateway, we have also provided sample `success.php` + , `cancel.php`, `fail.php`files. You can update those files according to your need. ## Testing @@ -25,17 +175,14 @@ Run the tests with: vendor/bin/phpunit ``` - ## Contributing Please see [CONTRIBUTING](CONTRIBUTING.md) for details. - ## Security If you discover any security-related issues, please email afzalbd1@gmail.com instead of using the issue tracker. - ## License -The MIT License (MIT). Please see [License File](/LICENSE.md) for more information. +The MIT License (MIT). Please see [License File](LICENSE.md) for more information. From ee61e5be5125c57c7ab487b32b7338337fad7d54 Mon Sep 17 00:00:00 2001 From: Afzalur Rahman Sabbir <39697431+AfzalSabbir@users.noreply.github.com> Date: Sun, 11 Sep 2022 23:24:34 +0600 Subject: [PATCH 14/26] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f868d4b..546d894 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # SSLaraCommerz - Laravel Package -> A package for SSLCommerz Payment Gateway +> A package for SSLCommerz Payment Gateway \ +Inspired by [SSLCommerz](https://github.com/sslcommerz/SSLCommerz-Laravel) [![Latest Version on Packagist](https://img.shields.io/packagist/v/hasib32/sslaracommerz.svg?style=flat-square)](https://packagist.org/packages/hasib32/sslaracommerz) [![Build Status](https://img.shields.io/travis/hasib32/sslaracommerz/master.svg?style=flat-square)](https://travis-ci.org/hasib32/sslaracommerz) From 7967ba8bb0fb807249085abc51abe95660d9bb7f Mon Sep 17 00:00:00 2001 From: AfzalSabbir Date: Sun, 11 Sep 2022 23:24:51 +0600 Subject: [PATCH 15/26] Update README.md --- README.md | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 546d894..7b22cf7 100644 --- a/README.md +++ b/README.md @@ -3,15 +3,10 @@ > A package for SSLCommerz Payment Gateway \ Inspired by [SSLCommerz](https://github.com/sslcommerz/SSLCommerz-Laravel) -[![Latest Version on Packagist](https://img.shields.io/packagist/v/hasib32/sslaracommerz.svg?style=flat-square)](https://packagist.org/packages/hasib32/sslaracommerz) -[![Build Status](https://img.shields.io/travis/hasib32/sslaracommerz/master.svg?style=flat-square)](https://travis-ci.org/hasib32/sslaracommerz) -[![Quality Score](https://img.shields.io/scrutinizer/g/hasib32/sslaracommerz.svg?style=flat-square)](https://scrutinizer-ci.com/g/hasib32/sslaracommerz) -[![Total Downloads](https://img.shields.io/packagist/dt/hasib32/sslaracommerz.svg?style=flat-square)](https://packagist.org/packages/hasib32/sslaracommerz) -[![Latest Version on Packagist](https://img.shields.io/packagist/v/hasib32/sslaracommerz.svg?style=flat-square)](https://packagist.org/packages/hasib32/sslaracommerz) -[![Total Downloads](https://img.shields.io/packagist/dt/hasib32/sslaracommerz.svg?style=flat-square)](https://packagist.org/packages/hasib32/sslaracommerz) - [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md) -[![Travis](https://img.shields.io/travis/afzalsabbir/sslaracommerz.svg?style=flat-square)]() +[![Latest Version on Packagist](https://img.shields.io/packagist/v/afzalsabbir/sslaracommerz.svg?style=flat-square)](https://packagist.org/packages/afzalsabbir/sslaracommerz) +[![Build Status](https://img.shields.io/travis/afzalsabbir/sslaracommerz/master.svg?style=flat-square)](https://travis-ci.org/afzalsabbir/sslaracommerz) +[![Quality Score](https://img.shields.io/scrutinizer/g/afzalsabbir/sslaracommerz.svg?style=flat-square)](https://scrutinizer-ci.com/g/afzalsabbir/sslaracommerz) [![Total Downloads](https://img.shields.io/packagist/dt/afzalsabbir/sslaracommerz.svg?style=flat-square)](https://packagist.org/packages/afzalsabbir/sslaracommerz) __Tags:__ Payment Gateway, SSLCommerz, IPN, Laravel, SSLaraCommerz From 87517ea2788e09511a5a6c986219bc86fd40b2c7 Mon Sep 17 00:00:00 2001 From: AfzalSabbir Date: Sun, 11 Sep 2022 23:26:04 +0600 Subject: [PATCH 16/26] Update README.md --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index 7b22cf7..9bb0e69 100644 --- a/README.md +++ b/README.md @@ -21,10 +21,6 @@ __License:__ MIT License composer require afzalsabbir/sslaracommerz ``` -## Usage - -Write a few lines about the usage of this package. - ## Vendor Publish ### Required From 903da33a3ea9232725852ed4c5a485e9027a79c4 Mon Sep 17 00:00:00 2001 From: AfzalSabbir Date: Sun, 11 Sep 2022 23:41:42 +0600 Subject: [PATCH 17/26] Update README.md --- README.md | 62 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 9bb0e69..b142418 100644 --- a/README.md +++ b/README.md @@ -54,26 +54,46 @@ php artisan vendor:publish --provider="AfzalSabbir\SSLaraCommerz\SSLaraCommerzSe ## Instructions -* __Step 1:__ Install the package using composer command. _(i.e. `composer require afzalsabbir/sslaracommerz`)_ +* __Step 1:__ Install the package using composer command. _(i.e. `composer require afzalsabbir/sslaracommerz`)_. [//]: # (* __Step 2:__ Copy the `Library` folder and put it in the laravel project's `app/` directory. If needed, then run `composer dump -o`.) -* __Step 3:__ Copy the `config/sslcommerz.php` file into your project's `config/` folder. +[//]: # (* __Step 3:__ Copy the `config/sslcommerz.php` file into your project's `config/` folder.) -Now, we have already copied the core library files. Let's do copy some other helpers files that is provided to -understand the integration process. The other files are not related to core library. +* __Step 2:__ Can publish [config](#config-views-migrations) and custom the package as per your need. * __Optional:__ If you later encounter issues with session destroying after redirect, you can set ```'same_site' => null,``` in your `config/session.php` file. -* __Step 4:__ Add `STORE_ID` and `STORE_PASSWORD` values on your project's `.env` file. You can register for a store +[//]: # (* __Step 4:__ Add `STORE_ID` and `STORE_PASSWORD` values on your project's `.env` file. You can register for a store at [https://developer.sslcommerz.com/registration/](https://developer.sslcommerz.com/registration/)) + +* __Step 3:__ Add `STORE_ID` and `STORE_PASSWORD` values on your project's `.env` file. You can register for a store at [https://developer.sslcommerz.com/registration/](https://developer.sslcommerz.com/registration/) [//]: # (* __Step 5:__ Copy the `SslCommerzPaymentController` into your project's `Controllers` folder.) -* __Step 6:__ Copy the defined routes from `routes/web.php` into your project's route file. +* __Step 4:__ Package routes are like below. You can use them as per your need. + +```php +use Illuminate\Support\Facades\Route; + +// Controller namespace: "AfzalSabbir\SSLaraCommerz\Http\Controllers" +Route::get('/example1', 'SslCommerzPaymentController@exampleEasyCheckout'); +Route::get('/example2', 'SslCommerzPaymentController@exampleHostedCheckout'); + +Route::post('/pay', 'SslCommerzPaymentController@index'); +Route::post('/pay-via-ajax', 'SslCommerzPaymentController@payViaAjax'); + +Route::post('/success', 'SslCommerzPaymentController@success'); +Route::post('/fail', 'SslCommerzPaymentController@fail'); +Route::post('/cancel', 'SslCommerzPaymentController@cancel'); + +Route::post('/ipn', 'SslCommerzPaymentController@ipn'); +``` + +[//]: # (* __Step 7:__ Add the below routes into the `$excepts` array of `VerifyCsrfToken` middleware.) -* __Step 7:__ Add the below routes into the `$excepts` array of `VerifyCsrfToken` middleware. +* __Step 5:__ Add the below routes into the `$excepts` array of `VerifyCsrfToken` middleware. ```php protected $except = [ @@ -81,15 +101,20 @@ protected $except = [ ]; ``` -* __Step 8:__ Copy the `resources/views/*.blade.php` files into your project's `resources/views/` folder. +[//]: # (* __Step 8:__ Copy the `resources/views/*.blade.php` files into your project's `resources/views/` folder.) + +* __Step 6:__ Can publish [views](#config-views-migrations) and custom the views as per your need. Now, let's go to the main integration part. -* __Step 9:__ To integrate popup checkout, use the below script before the end of body tag. +[//]: # (* __Step 9:__ To integrate popup checkout, use the below script before the end of body tag.) + +* __Step 7:__ To integrate popup checkout, use the below script before the end of body tag. ##### For Sandbox ```html + ``` -* __Step 10:__ Use the below button where you want to show the **"Pay Now"** button: +[//]: # (* __Step 10:__ Use the below button where you want to show the **"Pay Now"** button:) +* __Step 8:__ Use the below button where you want to show the **"Pay Now"** button: ```html @@ -148,16 +176,14 @@ Now, let's go to the main integration part. ``` -* __Step 11:__ For EasyCheckout (Popup) integration, you can update the `checkout_ajax.php` or use a different file - according to your need. We have provided a basic sample page from where you can kickstart the payment gateway - integration. +[//]: # (* __Step 11:__ For EasyCheckout (Popup) integration, you can update the `checkout_ajax.php` or use a different file according to your need. We have provided a basic sample page from where you can kickstart the payment gateway integration.) +* __Step 9:__ For EasyCheckout (Popup) integration, you can update the `checkout_ajax.php` or use a different file according to your need. We have provided a basic sample page from where you can kickstart the payment gateway integration. -* __Step 12:__ For Hosted Checkout integration, you can update the `checkout_hosted.php` or use a different file - according to your need. We have provided a basic sample page from where you can kickstart the payment gateway - integration. +[//]: # (* __Step 12:__ For Hosted Checkout integration, you can update the `checkout_hosted.php` or use a different file according to your need. We have provided a basic sample page from where you can kickstart the payment gateway integration.) +* __Step 10:__ For Hosted Checkout integration, you can update the `checkout_hosted.php` or use a different file according to your need. We have provided a basic sample page from where you can kickstart the payment gateway integration. -* __Step 13:__ For redirecting action from SSLCommerz Payment gateway, we have also provided sample `success.php` - , `cancel.php`, `fail.php`files. You can update those files according to your need. +[//]: # (* __Step 13:__ For redirecting action from SSLCommerz Payment gateway, we have also provided sample `success.php`, `cancel.php`, `fail.php`files. You can update those files according to your need.) +* __Step 11:__ For redirecting action from SSLCommerz Payment gateway, we have also provided sample `success.php`, `cancel.php`, `fail.php`files. You can update those files according to your need. ## Testing From 933d3c05af82a71b0f7356692d1e7e0a9a4953d1 Mon Sep 17 00:00:00 2001 From: AfzalSabbir Date: Mon, 12 Sep 2022 00:09:34 +0600 Subject: [PATCH 18/26] controller & routes are publishable --- .../PublishSslCommerzPaymentController.php | 309 ++++++++++++++++++ src/Http/publish-routes.php | 17 + src/SSLaraCommerzServiceProvider.php | 16 + 3 files changed, 342 insertions(+) create mode 100644 src/Http/Controllers/PublishSslCommerzPaymentController.php create mode 100644 src/Http/publish-routes.php diff --git a/src/Http/Controllers/PublishSslCommerzPaymentController.php b/src/Http/Controllers/PublishSslCommerzPaymentController.php new file mode 100644 index 0000000..1483e9e --- /dev/null +++ b/src/Http/Controllers/PublishSslCommerzPaymentController.php @@ -0,0 +1,309 @@ +where('transaction_id', $post_data['tran_id']) + ->updateOrInsert([ + 'name' => $post_data['cus_name'], + 'email' => $post_data['cus_email'], + 'phone' => $post_data['cus_phone'], + 'amount' => $post_data['total_amount'], + 'status' => 'Pending', + 'address' => $post_data['cus_add1'], + 'transaction_id' => $post_data['tran_id'], + 'currency' => $post_data['currency'] + ]); + + $sslc = new SslCommerzNotification(); + # initiate(Transaction Data , false: Redirect to SSLCOMMERZ gateway/ true: Show all the Payement gateway here ) + $payment_options = $sslc->makePayment($post_data, 'hosted'); + + if (!is_array($payment_options)) { + print_r($payment_options); + $payment_options = array(); + } + + } + + public function payViaAjax(Request $request) + { + # Here you have to receive all the order data to initate the payment. + # Lets your oder trnsaction informations are saving in a table called "orders" + # In orders table order uniq identity is "transaction_id","status" field contain status of the transaction, "amount" is the order amount to be paid and "currency" is for storing Site Currency which will be checked with paid currency. + + $post_data = array(); + $post_data['total_amount'] = '10'; # You cant not pay less than 10 + $post_data['currency'] = "BDT"; + $post_data['tran_id'] = uniqid(); // tran_id must be unique + + # CUSTOMER INFORMATION + $post_data['cus_name'] = 'Customer Name'; + $post_data['cus_email'] = 'customer@mail.com'; + $post_data['cus_add1'] = 'Customer Address'; + $post_data['cus_add2'] = ""; + $post_data['cus_city'] = ""; + $post_data['cus_state'] = ""; + $post_data['cus_postcode'] = ""; + $post_data['cus_country'] = "Bangladesh"; + $post_data['cus_phone'] = '8801XXXXXXXXX'; + $post_data['cus_fax'] = ""; + + # SHIPMENT INFORMATION + $post_data['ship_name'] = "Store Test"; + $post_data['ship_add1'] = "Dhaka"; + $post_data['ship_add2'] = "Dhaka"; + $post_data['ship_city'] = "Dhaka"; + $post_data['ship_state'] = "Dhaka"; + $post_data['ship_postcode'] = "1000"; + $post_data['ship_phone'] = ""; + $post_data['ship_country'] = "Bangladesh"; + + $post_data['shipping_method'] = "NO"; + $post_data['product_name'] = "Computer"; + $post_data['product_category'] = "Goods"; + $post_data['product_profile'] = "physical-goods"; + + # OPTIONAL PARAMETERS + $post_data['value_a'] = "ref001"; + $post_data['value_b'] = "ref002"; + $post_data['value_c'] = "ref003"; + $post_data['value_d'] = "ref004"; + + + #Before going to initiate the payment order status need to update as Pending. + $update_product = DB::table('orders') + ->where('transaction_id', $post_data['tran_id']) + ->updateOrInsert([ + 'name' => $post_data['cus_name'], + 'email' => $post_data['cus_email'], + 'phone' => $post_data['cus_phone'], + 'amount' => $post_data['total_amount'], + 'status' => 'Pending', + 'address' => $post_data['cus_add1'], + 'transaction_id' => $post_data['tran_id'], + 'currency' => $post_data['currency'] + ]); + + $sslc = new SslCommerzNotification(); + # initiate(Transaction Data , false: Redirect to SSLCOMMERZ gateway/ true: Show all the Payement gateway here ) + $payment_options = $sslc->makePayment($post_data, 'checkout', 'json'); + + if (!is_array($payment_options)) { + print_r($payment_options); + $payment_options = array(); + } + + } + + public function success(Request $request) + { + echo "Transaction is Successful"; + + $tran_id = $request->input('tran_id'); + $amount = $request->input('amount'); + $currency = $request->input('currency'); + + $sslc = new SslCommerzNotification(); + + #Check order status in order tabel against the transaction id or order id. + $order_detials = DB::table('orders') + ->where('transaction_id', $tran_id) + ->select('transaction_id', 'status', 'currency', 'amount')->first(); + + if ($order_detials->status == 'Pending') { + $validation = $sslc->orderValidate($tran_id, $amount, $currency, $request->all()); + + if ($validation == TRUE) { + /* + That means IPN did not work or IPN URL was not set in your merchant panel. Here you need to update order status + in order table as Processing or Complete. + Here you can also sent sms or email for successfull transaction to customer + */ + $update_product = DB::table('orders') + ->where('transaction_id', $tran_id) + ->update(['status' => 'Processing']); + + echo "
Transaction is successfully Completed"; + } else { + /* + That means IPN did not work or IPN URL was not set in your merchant panel and Transation validation failed. + Here you need to update order status as Failed in order table. + */ + $update_product = DB::table('orders') + ->where('transaction_id', $tran_id) + ->update(['status' => 'Failed']); + echo "validation Fail"; + } + } else if ($order_detials->status == 'Processing' || $order_detials->status == 'Complete') { + /* + That means through IPN Order status already updated. Now you can just show the customer that transaction is completed. No need to udate database. + */ + echo "Transaction is successfully Completed"; + } else { + #That means something wrong happened. You can redirect customer to your product page. + echo "Invalid Transaction"; + } + + + } + + public function fail(Request $request) + { + $tran_id = $request->input('tran_id'); + + $order_detials = DB::table('orders') + ->where('transaction_id', $tran_id) + ->select('transaction_id', 'status', 'currency', 'amount')->first(); + + if ($order_detials->status == 'Pending') { + $update_product = DB::table('orders') + ->where('transaction_id', $tran_id) + ->update(['status' => 'Failed']); + echo "Transaction is Falied"; + } else if ($order_detials->status == 'Processing' || $order_detials->status == 'Complete') { + echo "Transaction is already Successful"; + } else { + echo "Transaction is Invalid"; + } + + } + + public function cancel(Request $request) + { + $tran_id = $request->input('tran_id'); + + $order_detials = DB::table('orders') + ->where('transaction_id', $tran_id) + ->select('transaction_id', 'status', 'currency', 'amount')->first(); + + if ($order_detials->status == 'Pending') { + $update_product = DB::table('orders') + ->where('transaction_id', $tran_id) + ->update(['status' => 'Canceled']); + echo "Transaction is Cancel"; + } else if ($order_detials->status == 'Processing' || $order_detials->status == 'Complete') { + echo "Transaction is already Successful"; + } else { + echo "Transaction is Invalid"; + } + + + } + + public function ipn(Request $request) + { + #Received all the payement information from the gateway + if ($request->input('tran_id')) #Check transation id is posted or not. + { + + $tran_id = $request->input('tran_id'); + + #Check order status in order tabel against the transaction id or order id. + $order_details = DB::table('orders') + ->where('transaction_id', $tran_id) + ->select('transaction_id', 'status', 'currency', 'amount')->first(); + + if ($order_details->status == 'Pending') { + $sslc = new SslCommerzNotification(); + $validation = + $sslc->orderValidate($tran_id, $order_details->amount, $order_details->currency, $request->all()); + if ($validation == TRUE) { + /* + That means IPN worked. Here you need to update order status + in order table as Processing or Complete. + Here you can also sent sms or email for successful transaction to customer + */ + $update_product = DB::table('orders') + ->where('transaction_id', $tran_id) + ->update(['status' => 'Processing']); + + echo "Transaction is successfully Completed"; + } else { + /* + That means IPN worked, but Transation validation failed. + Here you need to update order status as Failed in order table. + */ + $update_product = DB::table('orders') + ->where('transaction_id', $tran_id) + ->update(['status' => 'Failed']); + + echo "validation Fail"; + } + + } else if ($order_details->status == 'Processing' || $order_details->status == 'Complete') { + + #That means Order status already updated. No need to udate database. + + echo "Transaction is already successfully Completed"; + } else { + #That means something wrong happened. You can redirect customer to your product page. + + echo "Invalid Transaction"; + } + } else { + echo "Invalid Data"; + } + } +} diff --git a/src/Http/publish-routes.php b/src/Http/publish-routes.php new file mode 100644 index 0000000..5f6fb49 --- /dev/null +++ b/src/Http/publish-routes.php @@ -0,0 +1,17 @@ +publishMigrations(); //$this->publishModel(); $this->publishAssets(); + $this->publishRoutesAndController(); $this->loadViewsFrom(__DIR__ . '/resources/views', 'sslaracommerz'); $this->loadMigrationsFrom(__DIR__ . '/../database/migrations'); @@ -135,4 +136,19 @@ public function publishAssets(): void ], 'public-assets'); } } + + /** + * Publish Routes And Controller + * + * @return void + */ + public function publishRoutesAndController(): void + { + if ($this->app->runningInConsole()) { + $this->publishes([ + __DIR__ . '/Http/publish-routes.php' => base_path('routes/sslcommerz.php'), + __DIR__ . '/Http/Controllers/PublishSslCommerzPaymentController.php' => app_path('Http/Controllers/SslCommerzPaymentController.php'), + ], 'routes-controller'); + } + } } From 16efc389b4f5d6bbd7bba772c49852cc03fd831a Mon Sep 17 00:00:00 2001 From: AfzalSabbir Date: Mon, 12 Sep 2022 01:05:41 +0600 Subject: [PATCH 19/26] publishable routes created --- README.md | 230 +++++++++++++++++------------------- src/Http/publish-routes.php | 18 +-- 2 files changed, 118 insertions(+), 130 deletions(-) diff --git a/README.md b/README.md index b142418..54c8f4a 100644 --- a/README.md +++ b/README.md @@ -21,9 +21,9 @@ __License:__ MIT License composer require afzalsabbir/sslaracommerz ``` -## Vendor Publish +## Instructions -### Required +### Vendor Publish - _Required_ @@ -34,7 +34,84 @@ php artisan vendor:publish --provider="AfzalSabbir\SSLaraCommerz\SSLaraCommerzSe -### Optional +#### **Public Assets**: _To integrate popup checkout, use the below script before the end of body tag._ + +- For Sandbox + + ```html + + ``` + + > or, Publish the [Public Assets](#public-assets) and use the below `sandbox` script + + ```html + + ``` + +- For Live + + ```html + + ``` + + > or, Publish the [Public Assets](#public-assets) and use the below `live` script + + ```html + + ``` + + + +```bash +# Routes and Controller +php artisan vendor:publish --provider="AfzalSabbir\SSLaraCommerz\SSLaraCommerzServiceProvider" --tag="routes-controller" +``` + + + +- Publish the [Routes and Controller](#routes-controller) + and add `$this->loadRoutesFrom(base_path('routes/sslcommerz.php'));` in `app/Providers/RouteServiceProvider.php` + + ```php + namespace App\Providers; + + // ... + + class RouteServiceProvider extends ServiceProvider + { + // ... + public function boot() + { + // ... + $this->loadRoutesFrom(base_path('routes/sslcommerz.php')); + } + // ... + } + ``` + +### Vendor Publish - _Optional_ @@ -49,141 +126,50 @@ php artisan vendor:publish --provider="AfzalSabbir\SSLaraCommerz\SSLaraCommerzSe # Migrations php artisan vendor:publish --provider="AfzalSabbir\SSLaraCommerz\SSLaraCommerzServiceProvider" --tag="migrations" ``` - -## Instructions - -* __Step 1:__ Install the package using composer command. _(i.e. `composer require afzalsabbir/sslaracommerz`)_. - -[//]: # (* __Step 2:__ Copy the `Library` folder and put it in the laravel project's `app/` directory. If needed, then run `composer dump -o`.) - -[//]: # (* __Step 3:__ Copy the `config/sslcommerz.php` file into your project's `config/` folder.) - -* __Step 2:__ Can publish [config](#config-views-migrations) and custom the package as per your need. - -* __Optional:__ If you later encounter issues with session destroying after redirect, you can +> __Note:__ If you later encounter issues with session destroying after redirect, you can set ```'same_site' => null,``` in your `config/session.php` file. -[//]: # (* __Step 4:__ Add `STORE_ID` and `STORE_PASSWORD` values on your project's `.env` file. You can register for a store at [https://developer.sslcommerz.com/registration/](https://developer.sslcommerz.com/registration/)) -* __Step 3:__ Add `STORE_ID` and `STORE_PASSWORD` values on your project's `.env` file. You can register for a store +* __Step 1:__ Add `STORE_ID` and `STORE_PASSWORD` values on your project's `.env` file. You can register for a store at [https://developer.sslcommerz.com/registration/](https://developer.sslcommerz.com/registration/) -[//]: # (* __Step 5:__ Copy the `SslCommerzPaymentController` into your project's `Controllers` folder.) - -* __Step 4:__ Package routes are like below. You can use them as per your need. - -```php -use Illuminate\Support\Facades\Route; - -// Controller namespace: "AfzalSabbir\SSLaraCommerz\Http\Controllers" -Route::get('/example1', 'SslCommerzPaymentController@exampleEasyCheckout'); -Route::get('/example2', 'SslCommerzPaymentController@exampleHostedCheckout'); - -Route::post('/pay', 'SslCommerzPaymentController@index'); -Route::post('/pay-via-ajax', 'SslCommerzPaymentController@payViaAjax'); - -Route::post('/success', 'SslCommerzPaymentController@success'); -Route::post('/fail', 'SslCommerzPaymentController@fail'); -Route::post('/cancel', 'SslCommerzPaymentController@cancel'); - -Route::post('/ipn', 'SslCommerzPaymentController@ipn'); -``` - -[//]: # (* __Step 7:__ Add the below routes into the `$excepts` array of `VerifyCsrfToken` middleware.) - -* __Step 5:__ Add the below routes into the `$excepts` array of `VerifyCsrfToken` middleware. - -```php -protected $except = [ - '/pay-via-ajax', '/success','/cancel','/fail','/ipn' -]; -``` - -[//]: # (* __Step 8:__ Copy the `resources/views/*.blade.php` files into your project's `resources/views/` folder.) +* __Step 2:__ Add the below routes into the `$excepts` array of `VerifyCsrfToken` middleware. -* __Step 6:__ Can publish [views](#config-views-migrations) and custom the views as per your need. + ```php + protected $except = [ + '/pay-via-ajax', '/success','/cancel','/fail','/ipn' + ]; + ``` Now, let's go to the main integration part. -[//]: # (* __Step 9:__ To integrate popup checkout, use the below script before the end of body tag.) - -* __Step 7:__ To integrate popup checkout, use the below script before the end of body tag. - -##### For Sandbox - -```html - - -``` - -> or, Publish the [Public Assets](#public-assets) and use the below `sandbox` script - -```html - - -``` - ---- - -##### For Live - -```html - - -``` - -> or, Publish the [Public Assets](#public-assets) and use the below `live` script - -```html - - -``` - -[//]: # (* __Step 10:__ Use the below button where you want to show the **"Pay Now"** button:) -* __Step 8:__ Use the below button where you want to show the **"Pay Now"** button: +* __Step 3:__ Use the below button where you want to show the **"Pay Now"** button: -```html + ```html + + ``` +* __Step 4:__ For EasyCheckout (Popup) integration, you can update the `checkout_ajax.php` or use a different file + according to your need. We have provided a basic sample page from where you can kickstart the payment gateway + integration. - -``` +* __Step 5:__ For Hosted Checkout integration, you can update the `checkout_hosted.php` or use a different file + according to your need. We have provided a basic sample page from where you can kickstart the payment gateway + integration. -[//]: # (* __Step 11:__ For EasyCheckout (Popup) integration, you can update the `checkout_ajax.php` or use a different file according to your need. We have provided a basic sample page from where you can kickstart the payment gateway integration.) -* __Step 9:__ For EasyCheckout (Popup) integration, you can update the `checkout_ajax.php` or use a different file according to your need. We have provided a basic sample page from where you can kickstart the payment gateway integration. +* __Step 6:__ For redirecting action from SSLCommerz Payment gateway, we have also provided sample `success.php` + , `cancel.php`, `fail.php`files. You can update those files according to your need. -[//]: # (* __Step 12:__ For Hosted Checkout integration, you can update the `checkout_hosted.php` or use a different file according to your need. We have provided a basic sample page from where you can kickstart the payment gateway integration.) -* __Step 10:__ For Hosted Checkout integration, you can update the `checkout_hosted.php` or use a different file according to your need. We have provided a basic sample page from where you can kickstart the payment gateway integration. +## Original Documentation -[//]: # (* __Step 13:__ For redirecting action from SSLCommerz Payment gateway, we have also provided sample `success.php`, `cancel.php`, `fail.php`files. You can update those files according to your need.) -* __Step 11:__ For redirecting action from SSLCommerz Payment gateway, we have also provided sample `success.php`, `cancel.php`, `fail.php`files. You can update those files according to your need. +For more clear concept +read: [SSLCommerz README.md](https://github.com/sslcommerz/SSLCommerz-Laravel/blob/master/README.md) ## Testing diff --git a/src/Http/publish-routes.php b/src/Http/publish-routes.php index 5f6fb49..71c67d6 100644 --- a/src/Http/publish-routes.php +++ b/src/Http/publish-routes.php @@ -3,15 +3,17 @@ use Illuminate\Support\Facades\Route; // SSLaraCommerz Start -Route::get('/example1', 'App\Http\Controllers\SslCommerzPaymentController@exampleEasyCheckout'); -Route::get('/example2', 'App\Http\Controllers\SslCommerzPaymentController@exampleHostedCheckout'); +Route::group(['namespace' => 'App\Http\Controllers'], function () { + Route::get('/example1', 'SslCommerzPaymentController@exampleEasyCheckout'); + Route::get('/example2', 'SslCommerzPaymentController@exampleHostedCheckout'); -Route::post('/pay', 'App\Http\Controllers\SslCommerzPaymentController@index'); -Route::post('/pay-via-ajax', 'App\Http\Controllers\SslCommerzPaymentController@payViaAjax'); + Route::post('/pay', 'SslCommerzPaymentController@index'); + Route::post('/pay-via-ajax', 'SslCommerzPaymentController@payViaAjax'); -Route::post('/success', 'App\Http\Controllers\SslCommerzPaymentController@success'); -Route::post('/fail', 'App\Http\Controllers\SslCommerzPaymentController@fail'); -Route::post('/cancel', 'App\Http\Controllers\SslCommerzPaymentController@cancel'); + Route::post('/success', 'SslCommerzPaymentController@success'); + Route::post('/fail', 'SslCommerzPaymentController@fail'); + Route::post('/cancel', 'SslCommerzPaymentController@cancel'); -Route::post('/ipn', 'App\Http\Controllers\SslCommerzPaymentController@ipn'); + Route::post('/ipn', 'SslCommerzPaymentController@ipn'); +}); //SSLaraCommerz End From d1b71f1615c17fbe1eea3bf8c40875dcf2bf125a Mon Sep 17 00:00:00 2001 From: AfzalSabbir Date: Mon, 12 Sep 2022 01:06:48 +0600 Subject: [PATCH 20/26] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 54c8f4a..1b4c168 100644 --- a/README.md +++ b/README.md @@ -110,6 +110,8 @@ php artisan vendor:publish --provider="AfzalSabbir\SSLaraCommerz\SSLaraCommerzSe // ... } ``` + + --- ### Vendor Publish - _Optional_ From e4aad30d93462fe8ff84d9b48e322112103f6f17 Mon Sep 17 00:00:00 2001 From: AfzalSabbir Date: Mon, 12 Sep 2022 01:07:02 +0600 Subject: [PATCH 21/26] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1b4c168..f6d106e 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,7 @@ php artisan vendor:publish --provider="AfzalSabbir\SSLaraCommerz\SSLaraCommerzSe } ``` - --- +--- ### Vendor Publish - _Optional_ From 173dd93edf04a05a37eb03f33d95190cb4fe4f7a Mon Sep 17 00:00:00 2001 From: AfzalSabbir Date: Mon, 12 Sep 2022 01:11:18 +0600 Subject: [PATCH 22/26] Update README.md --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f6d106e..5907445 100644 --- a/README.md +++ b/README.md @@ -91,9 +91,8 @@ php artisan vendor:publish --provider="AfzalSabbir\SSLaraCommerz\SSLaraCommerzSe -- Publish the [Routes and Controller](#routes-controller) - and add `$this->loadRoutesFrom(base_path('routes/sslcommerz.php'));` in `app/Providers/RouteServiceProvider.php` - +#### **Routes and Controller**: _To customize the routes and controller, use the below command._ +- Add `$this->loadRoutesFrom(base_path('routes/sslcommerz.php'));` in `app/Providers/RouteServiceProvider.php` ```php namespace App\Providers; From 0f15c9f71546fd1d85b932012fcf61e2e165b091 Mon Sep 17 00:00:00 2001 From: AfzalSabbir Date: Mon, 12 Sep 2022 01:16:02 +0600 Subject: [PATCH 23/26] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5907445..fd8d9ff 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # SSLaraCommerz - Laravel Package > A package for SSLCommerz Payment Gateway \ -Inspired by [SSLCommerz](https://github.com/sslcommerz/SSLCommerz-Laravel) +Inspired by [SSLCommerz](https://github.com/sslcommerz/SSLCommerz-Laravel) \ +[SSLCommerz](https://www.sslcommerz.com) Payment gateway library for Laravel framework. Official documentation is [here](https://developer.sslcommerz.com/docs.html). [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md) [![Latest Version on Packagist](https://img.shields.io/packagist/v/afzalsabbir/sslaracommerz.svg?style=flat-square)](https://packagist.org/packages/afzalsabbir/sslaracommerz) From c11dc7e986cf58765a5a029934985aff3ae0c979 Mon Sep 17 00:00:00 2001 From: AfzalSabbir Date: Mon, 12 Sep 2022 01:22:50 +0600 Subject: [PATCH 24/26] Update composer.json laravel and php requirements --- composer.json | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index bc3c56b..e636f83 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "afzalsabbir/sslaracommerz", - "description": "Your Package Description here", + "description": "A package for SSLCommerz Payment Gateway. Inspired by https://github.com/sslcommerz/SSLCommerz-Laravel", "type": "library", "license": "MIT", "keywords": [ @@ -16,7 +16,11 @@ ], "minimum-stability": "dev", "prefer-stable":true, - "require": {}, + "require": { + "php": "^7.1.3", + "laravel/framework": "^5.6|^6.0|^7.0|^8.0|^9.0", + "guzzlehttp/guzzle": "^6.3|^7.0" + }, "require-dev": { "symfony/thanks": "^1.0", "phpunit/phpunit": "^7.4@dev", From 0b13a4d7156d7b93a021d3ee479a0c9c37497e4a Mon Sep 17 00:00:00 2001 From: AfzalSabbir Date: Mon, 12 Sep 2022 01:25:14 +0600 Subject: [PATCH 25/26] Update composer.json php v8 support --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e636f83..acedf88 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "minimum-stability": "dev", "prefer-stable":true, "require": { - "php": "^7.1.3", + "php": "^7.1.3|^8.0", "laravel/framework": "^5.6|^6.0|^7.0|^8.0|^9.0", "guzzlehttp/guzzle": "^6.3|^7.0" }, From bc24d7fa6d48443bbd952e695ac2eec5ac1b010b Mon Sep 17 00:00:00 2001 From: AfzalSabbir Date: Mon, 12 Sep 2022 01:32:40 +0600 Subject: [PATCH 26/26] Update README.md --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fd8d9ff..8a713f4 100644 --- a/README.md +++ b/README.md @@ -18,10 +18,16 @@ __License:__ MIT License ## Install -```bash +```php composer require afzalsabbir/sslaracommerz ``` +## Migration + +```php +php artisan migrate +``` + ## Instructions ### Vendor Publish - _Required_