avored / laravel-ecommerce

AvoRed an Open Source Laravel Shopping Cart
https://avored.com
1.51k stars 549 forks source link

probleme in saving payement #153

Closed aryby closed 6 years ago

aryby commented 6 years ago

when I save a payment in the admin config http://localhost:8000/admin/configuration

{ "_token":"5pYFQAIASXFEHazJEBzeGmGrCMinSneDp0xxxxxx", "default_site_title":null,"general_site_description":"AvoRed is a free open-source e-commerce application development platform written in PHP based on Laravel. Its an ingenuous and modular e-commerce that is easily customizable according to your needs, with a modern responsive mobile friendly interface as default", "general_administrator_email":null, "general_term_condition_page":"2", "general_home_page":"1", "user_default_country":"1", "user_activation_required":"0", "shipping_free_shipping_enabled":"0", "shipping_fixed_rate_shipping_enabled":"0", "shipping_fixed_rate_cost":null, "payment_stripe_enabled":"0", "payment_stripe_publishable_key":"aze", "avored_stripe_secret_key":"aze", "payment_cash_on_delivery_enabled":"1", "payment_pickup_enabled":"1", "tax_enabled":"1", "tax_percentage":"15", "tax_default_country":"11" }

indpurvesh commented 6 years ago

Bug has been fixed on Master branch. If you want you just replace the code in modules/avored/ecommerce/src/Http/Controllers/ConfigurationController@store where store is a method. Replace the code with below:

 /**
 * Show the application dashboard.
 *
 * @return \Illuminate\Http\Response
 */
public function store(Request $request)
{
foreach ($request->except(['_token', '_method']) as $key => $value) {
        $configModel = Model::whereConfigurationKey($key)->first();

        if ($configModel->configuration_value == $value) {
            continue;
        }

        if (null === $configModel) {
            dd($configModel);
            $data['configuration_key'] = $key;
            $data['configuration_value'] = $value;

            Model::create($data);
        } else {
            $configModel->update(['configuration_value' => $value]);
        }
    }

    return redirect()->back()->with('notificationText', 'All Configuration saved!');
}
aryby commented 6 years ago

replace this line $configModel->configuration_value == $value) to $configModel !== null this $configModel->configuration_value return a objet

public function store(Request $request)
{
foreach ($request->except(['_token', '_method']) as $key => $value) {
        $configModel = Model::whereConfigurationKey($key)->first();

        if ($configModel !== null) {
            continue;
        }

        if (null === $configModel) {
            //dd($configModel);
            $data['configuration_key'] = $key;
            $data['configuration_value'] = $value;

            Model::create($data);
        } else {
            $configModel->update(['configuration_value' => $value]);
        }
    }

    return redirect()->back()->with('notificationText', 'All Configuration saved!');
}
indpurvesh commented 6 years ago

You are partially right code needs to be:

public function store(Request $request)
{
foreach ($request->except(['_token', '_method']) as $key => $value) {
    $configModel = Model::whereConfigurationKey($key)->first();

    if ($configModel !== null && $configModel->confuguration_value == $value) {
        continue;
    }

    if (null === $configModel) {
        //dd($configModel);
        $data['configuration_key'] = $key;
        $data['configuration_value'] = $value;

        Model::create($data);
    } else {
        $configModel->update(['configuration_value' => $value]);
    }
}

return redirect()->back()->with('notificationText', 'All Configuration saved!');

}

aryby commented 6 years ago

thank you so much for your help

in admin dashboard when i save a Shipping or an other things it dosn't save

and also payement value of "Payment Stripe Enabled"

indpurvesh commented 6 years ago

If you check the dev branch then i am implementing repository pattern all over the project. just to concentrate all DB transaction should happen from that Class. I know above code is not idea but just in the mean time i am doing this bug fixes on master branch only.

With new code i hope it should save the shipping and payment option config values. If it doesn't work let me know.

aryby commented 6 years ago

yes it fixed by your lase code

just a small probleme with last version of php

app\Http\Controllers\OrderController.php in private function _syncOrderProductData($order, $orderProducts)

if (count($orderProduct->attributes()) >= 0) {//"count(): Parameter must be an array or an object that implements Countable"

indpurvesh commented 6 years ago

seems like a php 7 bug. Don't worry i will fix it soon. Thanks again for showing me all those bugs and helps to improve the code base.

aryby commented 6 years ago

i replace this line private function _syncOrderProductData($order, $orderProducts) { $orderProductTableData = []; foreach ($orderProducts as $orderProduct) { if (count($orderProduct->attributes()) >= 0) {


by this private function _syncOrderProductData($order, $orderProducts) { $orderProductTableData = []; foreach ($orderProducts as $orderProduct) { if (!empty($orderProduct->attributes())) {

aryby commented 6 years ago

Order Place successfully but when I made a purchase I have not received any email or notification

indpurvesh commented 6 years ago

Reason why you haven't got an email notification is because i would guess you haven't setup smtp setting in your .env files.

MAIL_DRIVER=smtp 
MAIL_HOST=smtp.mailtrap.io(or any other provider) 
MAIL_PORT=2525 
MAIL_USERNAME=MAILTRAP_USER_NAME
MAIL_PASSWORD=MAILTRAP_PASSWORD

If you need more information on SMTP Setup please follow Laravel Docs

LARAVEL SMTP