What's your question?

Question Bump Latest Questions

Bellarmine901
  • -1
  • -1

I had some friends come over today and I want to entertain the guys with games. I have the installation package for FIFA19 on my system, but what is stopping me from whopping their a** is installation instruction… Any links, Video or ...Read more

I had some friends come over today and I want to entertain the guys with games.

I have the installation package for FIFA19 on my system, but what is stopping me from whopping their a** is installation instruction…

Any links, Video or guideline will be appreciated since I have the installation package.

Read less
Jhero23
  • 0
  • 0

I inherited a project recently written in laravel 5.8 to be precise, at this time, laravel has moved on to version 7, but my main issue here is how to setup flutterwave webhook (A very efficient ...Read more

I inherited a project recently written in laravel 5.8 to be precise, at this time, laravel has moved on to version 7, but my main issue here is how to setup flutterwave webhook (A very efficient Nigerian payment gateway) to work in this project, the previous developer had started work on it. After many attempts and reaching out to the rave team.

I’ll be sharing a step-by-step process of how to do that successfully, from the A-Z. Before now a laravel package had been created for this purpose, its called kingflamez/laravelrave or check the official docs. Follow the steps to get the rave package into your laravel project.

First, create a controller in laravel and call it RaveController with this command

php artisan make:controller RaveController

If you correctly setup your flutterwave composer package, you should have the file rave.php in your config folder in laravel i.e. config/rave.php. Also your environment variables ( .env file) need to be setup correctly too as this

RAVE_PUBLIC_KEY=FLWPUBK_TEST-xxxxxxx
RAVE_SECRET_KEY=FLWSECK_TEST-XXXXXXX
RAVE_TITLE="Name of your Company"
RAVE_ENVIRONMENT="test/live --(choose anyone)"
RAVE_LOGO="link to the rave logo"
RAVE_PREFIX="rave"
RAVE_SECRET_HASH='your secret hash string'

Once all these are setup properly, let’s proceed to the rave controller that you have created. Assume that you have a TransactionHistory model and thus a table in your database names transactionhistory.

First, rave looks for the initialize method, therefore, you should generate your transaction reference in this method before sending to the webhook. Generate a prefix, this is provided by the rave package, and save all the created objects to the database like the code below

<?php

namespace App\Http\Controllers;

use App\TransactionHistory;
use App\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Rave;

class RaveController extends Controller
{

/**
* Initialize Rave payment process
* @return void
*/
public function initialize()
{
request()->validate([
'phone' => 'sometimes|required|min:11|starts_with:0',
'category' => 'sometimes|required|string',
'product_id' => 'sometimes|required|integer',
'amount' => 'sometimes|required|integer',
], ['phone.starts_with' => ' :attribute number must begin with 0. e.g 070123456789', 'amount.integer' => ' :attribute number must be a number']);

$prefix = config()->get('rave.prefix');
$transactionPrefix = $prefix . '_';
request()->request->add(['user_id' => auth()->user()->id]);
request()->request->add(['ref' => uniqid($transactionPrefix)]);

TransactionHistory::create(request()->all());

Rave::initialize(route('callback'));
}

/**
* Obtain Rave callback information
* @return void
*/

public function callback()
{
$res_json = json_decode(request()->request->get('resp'));
$txref = $res_json->data->data->txRef;
$data = Rave::verifyTransaction($txref);
$chargeResponsecode = $data->data->chargecode;
$transaction = TransactionHistory::where('ref', $txref)->first();
if (($chargeResponsecode == "00" || $chargeResponsecode == "0")) {
$user = User::whereId($transaction->user_id)->first();
$referred_by = '';
$transaction->update([
'status' => 'paid',
]);
return redirect()->route('home')->withSuccess('Wallet top-up successful.');
} else {
return redirect()->route('home')->withErrors(['Something went wrong.']);
}
}
}

You can write the webhook function just before the callback function. The web-hook automatically runs as a background service, you don’t get to see how it happens except you use a logger which is also provided by laravel.

Also, for the webhook to work, your RAVE_SECRET_HASH=’your secret hash string’ in your .env file must be the same as on your rave dashboard — (go to settings on your dashboard, and click the webhooks tab.

Your url should look like this; https://yourdomainname/rave/receive

webhook image from flutterwave dashboard
public function webhook(){
$data = Rave::receiveWebhook();
$txref = $data['txRef'];
if ($data['status'] == 'successful') {
   $transaction = TransactionHistory::where('ref', $txref)-     >first();
   $user = User::whereId($transaction->user_id)->first();
   //give your user value here
   $transaction->update([
     'flwref' => $data['flwRef'],
     'type' => $data['event.type'],
   ]);
 }
}

Bypassing csrf

Also, we need to update the VerifyCsrfToken.php file to exempt the POST call of the webhook from using the CSRF which is the custom behaviour of all POST method calls in laravel. Head on to app/Http/VerifyCsrfToken.php and add the following code

protected $except = [ 'rave/callback', 'rave/receive', ];

Routes

Finally, we need to create a route of this to work. In the routes/web.php file , add this

Route::post(‘/pay’, ‘RaveController@initialize’)->name(‘pay’); Route::get(‘/rave/callback’, ‘RaveController@callback’)->name(‘callback’);

And that’s all….., you’re done.

Let’s talk about the errors you might encounter.

I had an issue first with the package, because my project is version 5.8, all I needed to do was:

php artisan vendor:publish --provider="KingFlamez\Rave\RaveServiceProvider"

but it didn’t work as expected. (well, after solving this, it will make you a senior developer)When this happens to you, try to clear cache, OR delete the vendor folder and re-install OR use these commands

php artisan cache:clear
php artisan config:clear

These two commands are very important. Lastly check the function called receiveWebhook in the Rave.php file inside the kingflamez/laravelrave/src located in your vendor folder to see if it is the same with the one the official docs on event-webhook has. GOODLUCK

If you need a developer to help you integrate flutterwave to receive payment on your site, you can reach out to Pianistprogrammer on whatsapp +2347030507502 or jeremiahabimbola0@gmail.com

Read less
Oreoluwa
  • 3
  • 3

How would you feel if your partner suddenly acts out a public display of affection (PDA) on you, especially in this part of the world, (taking Nigeria as a case study)? Many couples in Nigeria don’t do this often because ...Read more

How would you feel if your partner suddenly acts out a public display of affection (PDA) on you, especially in this part of the world, (taking Nigeria as a case study)?
Many couples in Nigeria don’t do this often because of reasons i’m not so sure about. If you have better views on this, please leave a comment

Read less
Adv
Tosin Olayinka
  • -1
  • -1

Business ethics refers to the system of ethical principles and rules applicable to business. As a social subject, business activities will not be carried out in a way that harms the interests of society and the business sector itself. Each ...Read more

Business ethics refers to the system of ethical principles and rules applicable to business. As a social subject, business activities will not be carried out in a way that harms the interests of society and the business sector itself. Each profession or group has formulated the rules for its members.

Business ethics is important to all businesses, they ensure worker’s safety, help companies maintain honesty and fairness in trade and interactions, and generally provide better goods and services. Distinguishing what a company will represent and what it does not represent is not always the same for all organizations, but understanding basic ethical principles is a key part of business management.

Importance of BUSINESS ETHICS

1: Business ethics help ensure the good reputation of your company. Not only does it feel good to be a member of a prestigious company, it is also good for business. When you have a reputation for consistently complying with ethics in the way you purchase and manufacture products and treat employees, customers, and communities, more people will be willing to do business with you.

2: Companies that practice good business ethics face less risk of fines and other legal issues. Of course, laws and regulations are complicated, but as long as you do some morally correct things, you can avoid many problems. By making business decisions with this in mind, you can avoid the pressure of having to defend your business due to litigation and fines.

3: Business ethics guarantees the development of the company. As long as an entrepreneur strictly abides by the code of ethics, a specific business sector will definitely develop. The company cannot be managed in a way that isn’t conducive to the interests of the society or the company itself. Therefore, the development of a company should have certain business ethics.

4: It’ll make employees to be more motivated to work because they feel that doing so will make the world a better place. Therefore, if you want normal profits to continue to rise until you make a lot of money, you must make your business fully ethical.

5: A reputation based on good ethics helps to establish a positive image in the market. This in turn makes customers trust your products and services. They also pass on information to your friends and family, thus creating more customers for you.

If you want your business to thrive for a long time, running an ethical business is essential. Business ethics and profits are mutually reinforcing. A company that is ethically oriented and wants to dominate its market segments can reap many benefits. However, unethical businesses are doomed to fail even if they start out with a record of high profits. Morality is making relationships better and stronger.

Read less
Dee20
  • -4
  • -4

I woke up this morning, and found that my urine is yellow and I was a bit scared, I then had to find out from a Pharmacist, and this is what he had to say; there are many reasons why ...Read more

I woke up this morning, and found that my urine is yellow and I was a bit scared, I then had to find out from a Pharmacist, and this is what he had to say; there are many reasons why one’s urine can be yellow, in my case, it was lack of enough water, but i will list out other reasons why this could happen.

CAUSES OF YELLOW URINE

  • Jaundice: Jaundice is a condition in which the skin, whites of the eyes and mucous membranes turn yellow because of a high level of bilirubin, a yellow-orange bile pigment. Jaundice has many causes, including hepatitis, gallstones and tumors. In adults, jaundice usually doesn’t need to be treated
  • Lack of water: Water is an essential daily need of the body, this article says that Water carries nutrients to all cells in our body and oxygen to our brain. Water allows the body to absorb and assimilate minerals, vitamins, amino acids, glucose and other substances. Water flushes out toxins and waste. Water helps to regulate body temperature.
  • Malaria: Did you believe when you saw this? that malaria can cause you to have yellow urine. early recognition of warning signs in malarial patients allows timely identification of the patient at risk of severe malaria and provides opportune treatment. Jaundice and dark urine are frequent signs that can alert to the occurrence of severe malaria.
  • Drug: Excess drug in your body system can also cause your urine to be yellow. A number of drugs can darken urine, including the antimalarial drugs chloroquine and primaquine, the antibiotics metronidazole (Flagyl) and nitrofurantoin (Furadantin), laxatives containing cascara or senna, and methocarbamol — a muscle relaxant. it is important to be in health and stay away from drugs as mush as possible
  • Vitamin B-complex: This is a common cause that many people are unaware about, but it is easy to spot being that the tablet itself is yellow. Bright yellow urine is common when taking a vitamin B complex, specifically due to the B2 vitamin, also known as riboflavin. In fact, “flavin” comes from the Latin “flavus” which means yellow. So don’t ditch your daily vitamins yet—they’re actually a vital part of maintaining your overall health

Read less
Adv
Jhero23
  • 1
  • 1

There are good or poor public display of affection among women. PDA is a hot theme in relationships , particularly between new couples, where they might have had a relationship earlier when something was somewhere and they are now in ...Read more

There are good or poor public display of affection among women. PDA is a hot theme in relationships , particularly between new couples, where they might have had a relationship earlier when something was somewhere and they are now in this new relationship and maybe public affection shows display more than the other person wants or maybe you don’t display enough for them maybe. PDA is sometimes referred to or public affection shows. This is a conversation to have with your significant other so they don’t feel unpleasant and when you’re out in public, kiss or hold your hands, or whatever.

It’s going to depend on the experience of an individual, the culture, and even on religion. Here we talk about the person with whom you are with, not the people around you. The way in which a person has been treated in terms of public display of affection will probably affect his or her ideas on public affairs.

Public showings of affection are therefore inherently good or inherently bad, depending on the preference of the two people. If a couple think that holding their hands in public is not appropriate, then it’s not only for them, but in many parts of the globe, public displays of affection are not only appropriate, but admired.

Why Do many Women like Public Display of Affection

  1. They are not afraid to display your love to everybody out there and that’s not to say you should take it far and do inappropriate things.
  2. It gives them a sense of full belonging of their men
  3. It gives them the confidence that you are not ashamed to be seen with them in the public cuddling around
  4. They use it to make a statement to their fellow friends that they are taken and every other woman or lady should back off

As I’ve said, there’s no inherently good or bad thing, it’s up to what you both think is right, but you’re always going to get people who get offended by your public displays of affection when you’re out and about in the world , for example, when you’re walking through the park and someone is looking at you and you’re kissing your significant other if they don’t want to see it, considering it should be b.

It might be inappropriate especially for kids, you don’t want to do all kinds of wild things out in public that you really should do behind closed doors like sexual acts.

Read less
Jhero23
  • 0
  • 0

The purpose of web form validation is to make sure that every user MUST fill the form before submitting, not only that, but also that the values entered are in the correct format as expected to perform a specific task. ...Read more

The purpose of web form validation is to make sure that every user MUST fill the form before submitting, not only that, but also that the values entered are in the correct format as expected to perform a specific task. In this tutorial, we will learn how to create a responsive contact-us form using the BootstrapVue front-end CSS library to validate the form using the Template-Driven approach that VeeValidate Form Validation Framework provides

I am making this tutorial because I found it difficult to use the form validation provided by BootstrapVue using veeValidate. Apparently I discovered that there’s been a lot of changes since that docs was written. I got this idea from a blog post of Positronx and decided to extend it since some codes were already deprecated. Without saying too much, lets gooooooo.

In this contact form, every field will be a required field, also we need to validate the users enter email in the right format (example@domain.com). In this case, three input fields; email, subject and comment

To add the styling, we used a bootstrap-vue package, which is an alternative to Bootstrap 4 for the Vue environment.

Assumptions

  • You have a Vue project already scaffolded, if not you need to install and create a Vue project. I won’t walk through that here because that is not the purpose of this post.
  • You know how to use Vuejs and BootstrapVue package and if not I’ll show you how quickly

Install BootsrapVue

npm i bootstrap-vue

Open your main.js file and add the reference to BootstrapVue after the import of Vue

import { BootstrapVue } from 'bootstrap-vue'
import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'

// Make BootstrapVue available throughout your project
Vue.use(BootstrapVue)

Now that you have BootstrapVue installed and ready to use, Let’s design our contact-us form using this framework

<b-form class="mt-5">
              <p class="font-weight-bold h3 mb-3">
                Email Us
              </p>
                <b-form-group id="input-group-1">
                  <label class="font-weight-500" for="input-1">EMAIL <span style="color: red;">*</span></label>
                  <b-form-input id="input-1" v-model="form.email"
                    type="email" placeholder="Enter Your Email"></b-form-input>
                </b-form-group>

                <b-form-group id="input-group-2">
                  <label class="font-weight-500" for="input-2">SUBJECT <span style="color: red;">*</span></label>
                  <b-form-input id="input-2" v-model="form.subject"
                    type="text" placeholder="Enter subject"></b-form-input>
                </b-form-group>
             
                <b-form-group id="input-group-3">
                  <label class="font-weight-500" for="input-3">COMMENT <span style="color: red;">*</span></label>
                  <b-form-textarea id="textarea" name="comment"
                    v-model="form.comment" placeholder="Write your comment..." rows="5" max-rows="6">
                  </b-form-textarea>
                </b-form-group>
              
              <div class="text-center ">
                <b-button class="custom-button" pill type="submit">SEND</b-button>
              </div>
            </b-form>
Conact Form validation with BootstrapVue
If you did it correctly, you should obtain this result. Only one class has been added – font-weight-500. it is to increase the font-weight of the label.

Having done that, validate this form. All we need to do is add some references to the main.js again. This time we need to add the ValidationObserver and ValidationProvider required by vee-validate to make the validation. But before that we need to install our vee-validate package

NPM

npm install vee-validate --save

Yarn

yarn add vee-validate

Now add these lines to the main.js file we talked about earlier

import { ValidationObserver, ValidationProvider, extend } from 'vee-validate';
import * as rules from 'vee-validate/dist/rules';

Vue.prototype.$http = Axios;
// install rules
Object.keys(rules).forEach(rule => {
  extend(rule, rules[rule]);
});

Vue.component('ValidationObserver', ValidationObserver);
Vue.component('ValidationProvider', ValidationProvider);

Next, we should follow the instructions given to us by vee-validate V3 by wrapping our form in a validationProvider so that each input will have one as shown below

 <ValidationProvider rules="required|email" name="Email" v-slot="{ valid, errors }">
   <b-form-group id="input-group-1">
     <label class="font-weight-500" for="input-1">EMAIL <span style="color: red;">*</span></label>
     <b-form-input :state="errors[0] ? false : (valid ? true : null)" id="input-1" v-model="form.email" type="email" placeholder="Enter Your Email"></b-form-input>
           <span class="er">{{ errors[0] }}</span>
  </b-form-group>
 </ValidationProvider>

Notice that ValidationProvider has attribute called rules which specifies many things. For example, this ensures that the input for email is required and validated for email format. You can see the rest of the rules from vee-validate. Also notice :state (a prop provided by BootstrapVue ); this is what checks if the state of the input is valid for the entire form to be valid. The corresponding error shows up in the span below with {{ errors[0] }}.

We are almost done.

Vee-validate also states that we wrap the entire form into a ValidationObserver that checks constantly as the user types if the form is valid or not. Eventually, we have this;

<ValidationObserver v-slot="{ handleSubmit }">
            <b-form class="mt-5" @submit.prevent="handleSubmit(onSubmit)">
              <p class="font-weight-bold h3 mb-3">
                Email Us
              </p>
              <ValidationProvider rules="required|email" name="Email" v-slot="{ valid, errors }">
                <b-form-group id="input-group-1">
                  <label class="font-weight-500" for="input-1">EMAIL <span style="color: red;">*</span></label>
                  <b-form-input :state="errors[0] ? false : (valid ? true : null)" id="input-1" v-model="form.email"
                    type="email" placeholder="Enter Your Email"></b-form-input>
                  <span class="er">{{ errors[0] }}</span>
                </b-form-group>
              </ValidationProvider>

              <ValidationProvider rules="required" name="Subject" v-slot="{valid, errors }">
                <b-form-group id="input-group-2">
                  <label class="font-weight-500" for="input-2">SUBJECT <span style="color: red;">*</span></label>
                  <b-form-input :state="errors[0] ? false : (valid ? true : null)" id="input-2" v-model="form.subject"
                    type="text" placeholder="Enter subject"></b-form-input>
                  <span class="er">{{ errors[0] }}</span>
                </b-form-group>
              </ValidationProvider>

              <ValidationProvider rules="required" name="Comment" v-slot="{ valid, errors }">
                <b-form-group id="input-group-3">
                  <label class="font-weight-500" for="input-3">COMMENT <span style="color: red;">*</span></label>
                  <b-form-textarea :state="errors[0] ? false : (valid ? true : null)" id="textarea" name="comment"
                    v-model="form.comment" placeholder="Write your comment..." rows="5" max-rows="6">
                  </b-form-textarea>
                  <span class="er">{{ errors[0] }}</span>
                </b-form-group>
              </ValidationProvider>
              <div class="text-center ">
                <b-button class="custom-button" pill type="submit">SEND</b-button>
              </div>
            </b-form>
          </ValidationObserver>

The handleSubmit will validate the form and when the form is valid, it will fire the function onSubmit() like so. We can also extend the rules to return our custom message – in this case , I decided it will be "This value is required"

<script>
  import { ValidationObserver, ValidationProvider, extend } from 'vee-validate';
  import { required } from 'vee-validate/dist/rules';

  extend('required', {
    ...required,
    message: 'This value is required'
  });
  export default {
    name: "App",
    data() {
      return {
        form: {
          email: '',
          subject: '',
          comment: '',
        },
      }
    },
    components: {
      ValidationObserver,
      ValidationProvider
    },
    methods: {
      onSubmit() {
        alert('form submitted'); 
      }
    }
  }
</script>
Form validation with BootstrapVue when field are required
Form validation with BootstrapVue when required filed are validated successfully
When form is validated, it will look like this

This brings us to the conclusion. Finally, when you hit send and the form is valid you get the alert “Form subbmitted”.

What have we learnt in summary?

We just learned to create Forms in Vue using a css framework BootstrapVue and also looked at how to add validation using vee-validate plugin. It makes validating HTML inputs and Vue components super easy.

You can check other tutorials on this site on flutterwave payment webhook
Read less