Posts
How to do payments with stripe checkoutLaravel

How to do payments with stripe checkoutLaravel
Stripe Configuration with Laravel
composer require stripe/stripe-php
STRIPE_KEY=your-stripe-key
STRIPE_SECRET=your-stripe-secret
Publish Migrations Files From Stripe
php artisan vendor:publish --tag="cashier-migrations"
php artisan migrate
Setup Stripe Controller
php artisan make:controller StripeController
namespace App\Http\Controllers;
use Illuminate\Contracts\View\Factory;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Stripe\Checkout\Session;
use Stripe\Exception\ApiErrorException;
/**
* Class FeaturedCompanySubscriptionController
*/
class StripeControlle extends AppBaseController
{
public function createSession(Request $request)
{
setStripeApiKey();
$session = Session::create([
'payment_method_types' => ['card'],
'customer_email' => $userEmail,
'line_items' => [
[
'price_data' => [
'product_data' => [
'name' => 'Make '.$company->user->first_name.' as featured Company',
],
'unit_amount' => 100 * 100,
'currency' => 'USD',
],
'quantity' => 1,
'description' => '',
],
],
'client_reference_id' => '1234',
'mode' => 'payment',
'success_url' => url('payment-success').'?session_id={CHECKOUT_SESSION_ID}',
'cancel_url' => url('failed-payment?error=payment_cancelled'),
]);
$result = [
'sessionId' => $session['id'],
];
return $this->sendResponse($result, 'Session created successfully.');
}
public function paymentSuccess(Request $request)
{
$sessionId = $request->get('session_id');
//
}
public function handleFailedPayment()
{
//
}
}
Define Routes
Route::post('stripe-charge', 'StripeController@createSession');
Route::get('payment-success', 'StripeController@paymentSuccess');
Route::get('failed-payment', 'StripeController@handleFailedPayment');
Setup From View file
$(document).on('click', '#makePayment', function () {
$(this).addClass('disabled');
$.post(makePaymentURL, payloadData).done((result) => {
let sessionId = result.data.sessionId;
stripe.redirectToCheckout({
sessionId: sessionId,
}).then(function (result) {
$(this).html('Make Featured').removeClass('disabled');
manageAjaxErrors(result);
});
}).catch(error => {
$(this).html('Make Featured').removeClass('disabled');
manageAjaxErrors(error);
});
});
Stisla Templates with JQuery DatatablesLaravel

Stisla Templates with JQuery DatatablesLaravel
Today we are going to see how we can generate a data table with one of the most popular a stisla theme.
We can actually do that in minutes with the package that we Recently developed called stisla-templates.
Our team made a great effort into this package and developed it with a new feature. this template package has Jquery Datatable support. So, anyone can easily generate CRUD(scaffold) with a Data table.
Let's see step by step, how we can do that.
Install Packages
Follow the installation steps given in our official documentation of Laravel InfyOm generator and stisla-templates if not installed.
Now, you have to perform the following steps.
composer require yajra/laravel-datatables-oracle:"~9.0"
this package handles the query and frontend stuff.
Register provider and facade on your `config/app.php` file.
Now clear your cache and regenerate it using the following command,
php artisan config:cache
We are done with installation and configuration.
Use Generate Scaffold with Datatable
Now I going to add an option jqueryDT
, at last, to use JQuery Datatables while generating scaffold. the command looks like
php artisan infyom:scaffold Post --jqueryDT
Enter all required inputs and generate scaffold of Post.
All views are created inside the posts directory in the resource. also, the `post.js` file created inside the js directory in assets that are located inside the resource.
Fire the following command for compile and publish the `post.js`
npm run dev
Now, datable is ready for use. you can watch the video tutorial here
How to load dynamic blog in Gatsby SiteGatsby

How to load dynamic blog in Gatsby SiteGatsby
We have recently developed a site into the gatsby.
We have a blog site and hosted it on a different domain but now we want to move to one place at our main site. now, we have challenges for displaying dynamic blogs on the gatsby site.
Finally, I found that gatsby provides support to render dynamic blogs as a static page. when build created that time fetch the blogs from the server and create a static page for all the blogs.
Gatsby is a very good platform and manages such a kind of thing easily.
So, I will show you how to create static pages from the API response into the Gatsby site.
Here are the steps you need to follow correctly.
Steps 1
Create a one blog file where you want to load a blog in your design.
For an ex. I created a file `blog/index.js` inside the component directory and the code looks like this,
Steps 2
Open a file `gatsby-node.js`
Declare the const for the API URL at the beginning of the file.
const blogURL = 'http://blog-api.com/api/posts';We need to create an instance of the `node-fetch` for fetching a data from API server.
const fetch = require(`node-fetch`);
Import the path for a resolve the page while creating a static page.
const path = require('path');
See the example how to create a static page from APIs. code look's like,
exports.createPages = (async ({graphql, actions}) => { const blogs = await fetch(blogURL); blogs.data.forEach((blog) => { createPage({ path: 'blog/' + blog.slug, component: path.resolve(`./src/components/blog/index.js`), context: { // Data passed to context is available // in page queries as GraphQL variables. slug: blog.slug, blog: blog, }, }) })
Now we are done, and you can access blogpage via slug.
How to create custom validation rules in Laravel ?Laravel

How to create custom validation rules in Laravel ?Laravel
Generate Custom Validation Class
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
use Ramsey\Uuid\Uuid;
class UuidExists implements Rule
{
protected $table;
protected $column;
public function __construct($table, $column)
{
$this->table = $table;
$this->column = $column;
}
public function passes($attribute, $value)
{
$value = Uuid::fromString(strtolower($value))->getBytes();
return \DB::table($this->table)->where($this->column, $value)->exists();
}
public function message()
{
return 'The validation error message.';
}
}
Add Rule to AppService Provider
Add your rule to AppServiceProvider.php into boot() method. here I have to give the named uuid_exists to my custom rule. you can give your own name whatever you want.
\Validator::extend('uuid_exists', function ($attribute, $value, $parameters, $validator) {
list($table, $column) = $parameters;
return (new UuidExists($table, $column))->passes($attribute, $value);
});
How to use custom Rule ?
You can use your custom rule as follows. here we have using required and uuid_exists rule, where we are passing attribute and values to our custom rule, which will be used to passes($attribute, $value) function.
'tenant_id' => ['required', 'uuid_exists:tenant_id,uuid']
Keep connected to us for more interesting posts about Laravel.
Show saved annotations from database in document using PDFTronJavascript

Show saved annotations from database in document using PDFTronJavascript
Here we will learn, how to import annotations saved in the database using PDFTron.
In my last blog, we have learned how to save annotation in the database.
Events for import annotation
At the time of document load, we will get all annotations saved in the database using AJAX call and then we'll import that annotation. Now the question is if we import annotation than that will be drawn and again annotation changed event will fire and again annotation will be saved (as I say in my last blog), so this will become an infinite flow, but we can overcome this problem by checking if an annotation is imported or not. If an annotation is not imported then only we'll do save annotation in the database process otherwise we'll ignore it.\
When we draw any annotation "annotationChanged" event will be fired, and check if it is an imported annotation, then we can ignore it(eg, save annotation process).
Here is an example of how to import annotation from the database.
Example
WebViewer({
path: 'path_to_the_PDFTron_'lib'_folder_on_your_server',
css: 'webviewer_css',
licenseKey: 'YOUR_PDF_TRON_LICENSE_KEY',
initialDoc: 'YOUR_FILE URL' //url of a file to load
}, document.getElementById('viewer'))
.then(function (instance) {
let docViewer = instance.docViewer;
let annotManager = instance.annotManager;
annotManager.on('annotationChanged', (annots, action, e) => {
//if annotation is imported we'll return
if (e.imported) return;
//when document will loaded we'll get annotations fro db
docViewer.on('documentLoaded', function () {
$.ajax({
url: `URL_TO_SAVE_ANNOTATION`,
type: 'GET',
success: function (result) {
if (result.success) {
result.data.forEach(annotationObj => {
annotManager.importAnnotations(annotationObj.annotation);
});
}
},
error: function (result) {
console.log(result);
}
});
});
});
});
Send real time notification with Pusher using Laravel and JavascriptLaravel

Send real time notification with Pusher using Laravel and JavascriptLaravel
Here we will learn how to send real-time notifications using Pusher + Laravel.
First of all, you need to create an account in the Pusher and get API keys from there.
Setting up your Laravel application
Now we need to install Pusher SDK, you can install it by the composer using the below command,
composer require pusher/pusher-php-server
After the composer is done, we will need to configure Laravel to use Pusher as its broadcast driver, update the below variables in the .env file,
PUSHER_APP_ID=123456
BROADCAST_DRIVER=pusher
// Get the API Keys from your pusher dashboard
PUSHER_APP_ID=XXXXX
PUSHER_APP_KEY=XXXXXXX
PUSHER_APP_SECRET=XXXXXXX
Open config/app.phpand uncomment the "App\Providers\BroadcastServiceProvider::class".
Now we need an event that will broadcast to the pusher driver. Let's create a NotificationEvent.
php artisan make:event NotificationEvent
This command will create a below file
namespace App\Events;
use Illuminate\Queue\SerializesModels;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
class NotificationEvent implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $username;
public $message;
public function __construct($username)
{
$this->username = $username;
$this->message = "{$username} send you a notification";
}
public function broadcastOn()
{
//it is a broadcasting channel you need to add this route in channels.php file
return ['notification-send'];
}
}
Add broadcasting route in channels.php file
Broadcast::channel('notification-send', function ($user) {
return true;
});
Cache Event at Javascript Side
// Initiate the Pusher JS library
var pusher = new Pusher('YOUR_API_KEY', {
encrypted: true
});
// Subscribe to the channel we used in our Laravel Event
var channel = pusher.subscribe('notification-send');
channel.bind('App\\Events\\NotificationEvent', function(data) {
// this is called when the event notification is received...
});
Testing and Setup
Using the below route we can send a notification.
Route::get('test', function () {
event(new App\Events\NotificationEvent('Monika'));
return "Event has been sent!";
});
Balanced Scorecard : Strategic Management System-3Human Resource

Balanced Scorecard : Strategic Management System-3Human Resource
In the last blog- https://infyom.com/blog/balanced-scorecard-strategic-management-system-2 we have discussed two perspectives namely Financial Perspective and Internal Process perspective out of four perspectives of BSC. let's look at the remaining two perspectives.
Customer Perspective
We all know that the 'Customer is the king of market' and that's why we need to ensure that we have satisfied customer group in market.
Each organization serves a specific need in the market and this is done with a target group in mind. There are many points to focus like the Quality, Price, Service, and acceptable Margins on the products and/or services.
The organization always try to meet customers' expectation in the market and that's why any organization need to keep eyes on the market and ready to adapt changes quickly.
The existence of alternatives( competitors ) has a huge influence on customers' expectations and we need to focus on overall market trends to build satisfied buyers in the market.
This perspective answer the question:
"How attractive should we appear to our customers?"
In short we need to focus on three points-
- Target Group in Market
- Expectation of the Customers
- Our Competitors
after focusing on these points definitely, we will able to lure maximum potential customers in the market.
Learning and Growth Perspective
In today's comitative era, if we are not ready/capable to learn something new then it's next to impossible to survive in the market as 'nothing is constant only the change is constant '
Here the only knowledge is not important but advancing knowledge plays a vital role.
The organization's learning ability and innovation indicated whether an organization is capable of continuous improvement and growth in a dynamic environment or not. The dynamic environment subject to change on daily basis due to new laws, economical changes, technological changes, or even increasing competition.
This perspective answer the questions:
"How can we sustain our ability to achieve our chosen strategy ?"
To know more about the BSC please read my upcoming weekly Blog.
How to integration google ad in android app. Part - 1Android Development

How to integration google ad in android app. Part - 1Android Development
Dear, Friend in this blog we discussion google ad integration. Many companies work in client base & product base. Product base company in very very important ad integration in the app. Multiple types of AD available like a Facebook ad, start-up ad, google ad, etc. Today we learning google ad integration.
Type of Google AD:
- Banner AD
- Interstitial Ad
- Rewarded Video Ad
- Native Ad
1.Banner Ad
- Banner Ads occupy only a portion of the screen depending on the ad size that is created. It comes in multiple sizes Standard, Medium, Large, Full-Size, Leaderboard, and Smart Banner. Smart banners are very useful when you target multiple device sizes and fit the same ad depending on the screen size.
2.Interstitial Ads
- Interstitial ads occupy the full screen of the app. Basically, they will show on a timely basis, between screen transition or when the user is done with a task.
3.Rewarded Video Ad
4.Native Ad
Create a new project
- Create a new project in Android Studio from File ⇒ New Project.
AdMob
Interstitial
Welcome to Admob. Click on the below button to launch the Interstitial ad.
Show Interstitial Ad
Show Rewarded Video Ad
ca-app-pub-XXXXXXXX~XXXXXXXXXXX
ca-app-pub-XXXXXXXX~XXXXXXXXXXX
ca-app-pub-XXXXXXXX~XXXXXXXXXXX
ca-app-pub-XXXXXXXX~XXXXXXXXXXX
Create a class named MyApplication.java and extend the class from Application.In this application class, we have to globally initialize the AdMob App Id. Here we use MobileAds.initialize()
Open AndroidManifest.xml and add MyApplication to tag.
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544/6300978111"/>
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544/6300978111"/>