Git Product home page Git Product logo

sslcommerz-laravel's Introduction

SSLCommerz - Laravel Library

For any technical support, please email at [email protected]

Compatibility

Supports Laravel v5.6 to v10.

License

GPLv2 or later

Instructions:

  • Step 1: Download and extract the library files.

  • 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 4: Copy and put 3 key-value pairs from env_example to your .env file.

For development purposes, you can obtain sandbox 'Store ID' and 'Store Password' by registering at https://developer.sslcommerz.com/registration/

  • Step 5: Add exceptions for VerifyCsrfToken middleware accordingly (this is for our example code, use your actual routes).
protected $except = [
    '/success',
    '/cancel',
    '/fail',
    '/ipn',
    '/pay-via-ajax', // only required to run example codes. Please see bellow.
];
  • Optional: We have also provided some example codes which can help you understand the process. Developer's discretion is needed. Following steps are not mandatory.

Copy SslCommerzPaymentController into your project's Controllers folder.

Copy defined routes from routes/web.php into your project's route file.

Copy views from resources/views/*.blade.php.

To Show sslcommerz gateway page inside a popup (optional)

  • If you use blade templates, we provide a simple solution to show sslcommerz gateway page inside popup. To integrate it, You need to have a <button> with following properties in your blade file -

    • id="sslczPayBtn"
    • endpoint=[your ajax route]
    • postdata= [you need to populate a js object with required form fields]
<button id="sslczPayBtn"
        token="if you have any token validation"
        postdata=""
        order="If you already have the transaction generated for current order"
        endpoint="/pay-via-ajax"> Pay Now
</button>
  • Populate postdata obj as required -
<script>
    var obj = {};
    obj.cus_name = $('#customer_name').val();
    obj.cus_phone = $('#mobile').val();
    obj.cus_email = $('#email').val();
    obj.cus_addr1 = $('#address').val();
    obj.amount = $('#total_amount').val();
    
    $('#sslczPayBtn').prop('postdata', obj);
</script>
  • Add following script -
For Sandbox
<script>
    (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);
</script>
For Live
<script>
    (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);
</script>

FAQ

  • Session is destroyed after redirecting to success/cancel/fail URL

This is a general Laravel issue, unrelated to SSLCommerz. You can try setting 'same_site' => 'none' in your config/session.php file.

  • I am getting an error saying "Store Credential Error Or Store is Deactive"

You have incorrect (or missing) configuration values in .env file. Check step 4.

  • I am not getting IPN in localhost / development machine.

You can't. IPN requires a publicly accessible webserver.

Contributors

Md. Rakibul Islam

Prabal Mallick

sslcommerz-laravel's People

Contributors

jmredwan avatar nayemsayed avatar prabalsslw avatar rkbi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

sslcommerz-laravel's Issues

ErrorException Required parameter $post_data follows optional parameter $trx_id

This problem is generated from the SslCommerzNotification.php file. You need to pass the required parameter (here $post_data) before passing the optional parameters like $trx_id, $amount etc.
It should be something like this....

public function orderValidate($post_data, $trx_id = '', $amount = 0, $currency = "BDT") {
    // 
}

OR

public function orderValidate($trx_id, $amount, $currency, $post_data) {
    // 
}

This problem only occurs in PHP 8, it worked fine in PHP 7.

Order Validation Problem

You should use pass parameter in order validation like..
$validation = $sslc->orderValidate($request->all(), $tran_id, $amount, $currency);

but you use
$validation = $sslc->orderValidate($tran_id, $amount, $currency, $request->all());

Submit Data Not Sent In postdata

Hello
I want to update sslcommerz api from v3 to v4. I did exactly that is written in the documentation but it Shows error that my submitted data such as reserve_name, reserve_email is not sent in post data. I also Tried your code for Laravel 5.6 but return without success.
Here is my code

var obj = {};
obj.reserve_firstname = reserve_firstname;
obj.reserve_lastname = reserve_lastname;
obj.reserve_phone = reserve_phone;
obj.reserve_email = reserve_email;
$('#sslczPayBtn').prop('postdata', obj);

Could you check this code ? Thank You

Error in Communication

I have all ready integration complete by documentation, but I have got an error message. "Error in Communication"
Class 'App\Library\SslCommerz\SslCommerzNotification' not found
https://prnt.sc/tx321e

Cannot use isset() on the result of an expression (you can use "null !== expression" instead)

I found this error

Cannot use isset() on the result of an expression (you can use "null !== expression" instead)

in app/Library/SslCommerz/AbstractSslCommerz.php:97

 if(isset($this->getApiUrl()) && $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']]);
                }

If replace this by
$response = json_encode(['status' => 'SUCCESS', 'data' => $sslcz['GatewayPageURL'], 'logo' => $sslcz['storeLogo']]);

It work

what url should i use for HTTP Listener in localhost

I'm trying to integrate sslcommerz in my website. I'm using laravel 5.5. In the first step of initiating payment, where it said i need to open an sandbox account and enable http listener. So what url should i use for local project?

No redirect URL found!

Hi i am edit a laravel sslCommerz project. I have set .env test api key and app/sslcommerz.php to test credential.

'connect_from_localhost' => env("IS_LOCALHOST", true), // For Sandbox, use "true", 'apiDomain' => env("API_DOMAIN_URL", "https://sandbox.sslcommerz.com"),

returning from SSL to my project, destroyong the session

Hi,
Thank you for you code.
I was trying to implement the code into my laravel project, i have been able to successfull payment.
but the problem is when i redirect back to my success/fail route i found no session remains.

i had tried to sent the cookies through header . but that didnt worked either.
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Cookie: laravel_session={$_COOKIE['laravel_session']}"));

any suggestion?
thank you

Sometimes Validate function does not return anything

I have set everything accordingly like success, fail, cancel, ipn function.
In my few transaction I am not getting validate true. Even in my IPN function did not get validate true. But transaction was successful. I have to confirmed payment status manually from SSL Commerz Merchant Admin Panel.

Basically, I am confused because some transaction is successful and some are not.
Can you tell me approximately how much time SSLCommez take to make a transaction successful?
Is there anything that I have missed?

Session expires.

After click on success button the session expires. How to keep the session?

ipn doesn't work in sanbox.

I have been trying to integrate sslcommerz project in laravel using your github codes. Everything works fine except OPT code isn't sent to the mobile number provide duing post request.
custPhone = 01558121408
It always bypass the the IPN function. It never hits this function.

Screenshot from 2019-10-31 12-30-21

In the OTP page, If I pass any number It loads success and never hits IPN method.

Session data destroyed after Redirect

i set 'same_site' => null, in config/session.php according to the documentation. but my session data destroyed when i checked sandbox success url. even i get logged out. is there have any solution for this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.