Code Monkey home page Code Monkey logo

Comments (6)

r-yeganeh avatar r-yeganeh commented on May 19, 2024 1

You're right! Thank you for your support! Actually there were 2 classes called Payment. And I had added the other one (by PHPStorm autocomplete), instead of Payment facade.

from payment.

khanzadimahdi avatar khanzadimahdi commented on May 19, 2024

as the name loadDefaultConfig says, this method loads the default config of the package.
if you publish the configs using php artisan vendor:publish then your configs will be loaded instead of defaults.

your config file should be exists in config/payment.php path.

from payment.

r-yeganeh avatar r-yeganeh commented on May 19, 2024

Yes, I've already used that artisan command and the file does exist at config/payment.php. But anything I configure in config/payment.php is not applied including merchantId.

from payment.

khanzadimahdi avatar khanzadimahdi commented on May 19, 2024

run your project outside of docker and publish vendors, then check if every thing goes correctly or not and let me know about it.

from payment.

r-yeganeh avatar r-yeganeh commented on May 19, 2024

Dear friend, I tried running the project outside docker on production environment. The problem still exists. Could you please determine where in your code that published vendor config file is read?
This is the code I'm using for payment:

// create invoice
$invoice->amount(1000)
    ->detail('detail1', 'your detail1 goes here')
    ->detail('detailName2', 'your detail2 goes here');
// dd($invoice);
$orderAuditNumber = 10406;
$payment = new Payment();
dd($payment);

return $payment->callbackUrl(route('verify-order-payment', $orderAuditNumber))
            ->purchase(
                $invoice,
                function ($driver, $transactionId)
                {
                    // dd('inside callback');
                }
            )
            ->pay()
            ->render();

So, getting those invoice and payment objects shows that my merchantId is empty string and other configs are not applied, too. Also, another issue I saw was when I tried to run static function calls as suggested in github document like:

return Payment::purchase(
    (new Invoice)->amount(1000), 
    function($driver, $transactionId) {
	    // Store transactionId in database.
        // We need the transactionId to verify payment in the future.
    }
)->pay()->render();

Purchase function seems to be declared as a non-static function in driver files (like Zarinpal.php).

public function purchase()

But called statically in github document like the above call.

from payment.

khanzadimahdi avatar khanzadimahdi commented on May 19, 2024

you have done a mistake in your codes.
the Payment constructor accepts configs, so if you wanna to instantiate it, you MUST pass configs to it by yourself.
you have not fellow the docs, you should use Payment facade instead, then the package will handle configs itself.

change the codes like the below:

// Create new invoice.
$invoice = (new Invoice)->amount(1000);
// Purchase and pay the given invoice.
// You should use return statement to redirect user to the bank page.
return Payment::purchase($invoice, function($driver, $transactionId) {
    // Store transactionId in database as we need it to verify payment in the future.
})->pay()->render();

and about non-static function in driver files , i could say that Payment class handles calling methods and its not related to Zarinpal , this is a kind of Proxy pattern.

from payment.

Related Issues (20)

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.