Our Latest Blog Posts

latest-post

In our previous blog, we had seen how to integrate stripe connect. Now we are going to see how we can split payments to the application and vendor using stripe checkout.

Let's take a simple example :

The platform is "Shopify", Merchant (Who is selling products on Shopify) & Customer who is going to register with Shopify.

Now When a customer purchases a product with $1000, Now $10 will be considered as an application fee, which is going to transfer to the Platform Account and the rest amount $90 will be transferred to Merchant.

Create Session using Stripe Checkout

public function generationSession($data)
{
    $session = \Stripe\Checkout\Session::create([
        'payment_method_types' => ['card'],
        'customer_email'       => $data['email'],
        'line_items'           => [
            [
                'name'     => "item name here",
                'amount'   => floatval($data['amount']) * 100,
                'currency' => 'usd',
                'quantity' => '1',
            ],
        ],
        'client_reference_id'  => $data['reference_id'],
        'success_url'          => url('payment-success').'?session_id={CHECKOUT_SESSION_ID}',
        'cancel_url'           => url('failed-payment?error=payment_cancelled'),
        'payment_intent_data'  => [
            'application_fee_amount' => $data['application_fees'] * 100,
            'transfer_data'          => [
                'destination' => $data['user']->stripe_connect_id,
            ],
        ],
    ]);

    return $session;
}

It will return the session object return, later you can use the session id to redirect to stripe checkout.

Redirect to checkout using StripeJS

        fetch('/generate-sesssion', {
            method: 'POST',
        })
        .then(function(session) {
            return stripe.redirectToCheckout({ sessionId: session.id });
        });

Check the transaction from your Stripe Dashboard

Once you do the transaction successfully, you can verify whether the application fee is applied or not from your stripe dashboard.

Hope this tutorial helps you.

July 13, 20231 minuteuserVishal Ribdiya

Posts

How to Improve Website Performance

Improving the performance of your website can have a significant impact on its success. A fast-loading website not only provides a better user experience but can also improve your search engine rankings and increase conversions. Here are some tips for improving the performance of your website:

Use a content delivery network (CDN)

A CDN stores copies of your website's static assets (such as images and CSS files) on servers located around the world. When a user accesses your website, the CDN will serve the content from the server closest to their location, which can significantly reduce loading times.

Optimize images

Large images can significantly slow down your website. Make sure to optimize your images by compressing them and using the appropriate file format (such as JPEG for photographs and PNG for graphics with transparent backgrounds).

Enable browser caching

Browser caching allows a user's browser to store some aspects of your website locally, so they don't have to be downloaded every time they visit your site. This can significantly reduce loading times for repeat visitors.

Minimize HTTP requests

Each time a user's browser requests a resource (such as an image or stylesheet) from your website, it creates an HTTP request. Minimizing the number of HTTP requests can improve your website's performance.

Use a lightweight theme

If you're using a content management system (CMS) like WordPress, choose a lightweight theme that is optimized for performance.

Optimize your website's code

Make sure your website's code is clean and well-organized. This can help reduce the size of your HTML, CSS, and JavaScript files, which can improve your website's loading times.

By following these tips, you can significantly improve the performance of your website and provide a better experience for your users.

January 06, 20231 minuteauthorAnkit Kalathiya
Alpha Vs Beta Testing: What’s the Difference?

Alpha Vs Beta Testing: What’s the Difference?

Before we start alpha vs beta testing, We should know what is alpha testing and what is beta testing.

What is Alpha Testing?

Alpha testing is conducted to determine defects before releasing the final product to end users or to the public. Then the main goal of alpha is to identify the tasks that a typical user might perform and test them.

What is Beta Testing?

Beta testing is a type of software testing which is performed by real users of the software in a real environment. Beta testing is also one type of user acceptance testing. This testing helps the tester to test products in the customer’s environment.

Difference: Alpha Vs Beta Testing

The difference between alpha vs beta testing is as below:

Alpha Testing Beta Testing
Alpha testing needs a testing atmosphere or a lab for testing. Beta testing doesn’t need a testing atmosphere or lab for testing.
Alpha testing may need a lengthy execution cycle. Beta testing needs only a few weeks of execution.
In alpha testing, developers can directly address critical bugs or fixes. Most of the bugs or feedback collected from the beta testing will be executed in future versions of the product.

Test Goals

Alpha Testing Beta Testing
The goal of alpha testing is to estimate the quality of the product. The goal of beta testing is to estimate customer satisfaction.
To confirm Beta eagerness To confirm release eagerness
Concentrate on finding defects or errors Concentrate on gathering recommendations/feedback and consider them effectively
Confirm that, does the product works properly without any bugs. Confirm that, do clients like the released product.

Test Duration

Alpha Testing Beta Testing
Multiple test cycles performed Only performed 1 or 2 test cycles
Separately each test cycle stays for 1 – 2 weeks Separately each test cycle stays for 4 – 6 weeks
The duration of the cycle also depends on how many bugs are found and how many new features are added during alpha testing. The duration of the cycle may expand based on the end user’s feedback/recommendation.

Expectations

Alpha Testing Beta Testing
An acceptable number of bugs were missed in earlier testing activities. Major finished product with very a much smaller number of defects and crashes.
Incomplete components and documentation. Almost finished components and documentation.
December 28, 20222 minutesauthorVirendra Harkhani
Some Laravel tips that we must need to know

1) Null safe operator

From PHP 8 you can use Null Safe Operator

How we are doing null checking code in PHP < 8.0

 $country =  null;

 if ($session !== null) {
     $user = $session->user;

     if ($user !== null) {
         $address = $user->getAddress();

         if ($address !== null) {
             $country = $address->country;
         }
     }
 }

PHP 8 allows you to write this:

 $country = $session?->user?->getAddress()?->country;

2) Ternary condition

We have used this ternary condition for checking null value

 isset($user->image) ? $user->image : null

We can short above condition like this

 $user->image ?? null

3) Clone a model

You can clone a model using replicate(). It will create a copy of the model into a new, non-existing instance.

 $user = App\User::find(1);
 $newUser = $user->replicate();
 $newUser->save();

4) Default Relationship Models

Laravel provides a handy withDefault() method on the belongsTo relationship that will return a model object even when the relationship doesn't actually exist.

 class Post extends Model
 {
     public function user()
     {
         return $this->belongsTo(User::class)->withDefault();
     }
 }

Now, if we try to access the $post->user relationship, we'll still get a User object even when it does exist in the database. This is known as the "null object" pattern and helps eliminate some of those if ($post->user) conditional statements.

For more information read Laravel withDefault() doc.

5) Save models and relationships

You can save a model and its corresponding relationships using the push() method.

 class User extends Model
 {
     public function phone()
     {
         return $this->hasOne('App\Phone');
     }
 }
 $user = User::first();
 $user->name = "Peter";
 $user->phone->number = '1234567890';
 $user->push(); // This will update both user and phone record in DB

Hope it will be helpful.

Thanks

December 30, 20221 minuteauthorMitesh Makwana
Human Resources Functions: 8 Areas to Focus on

When it comes to the human resources department, there are many different functions that need to be carried out in order to ensure the success of the organization. There are eight key areas that all HR departments should focus on in order to create a successful workforce.

1. Employee Screening

It is important to screen employees carefully before hiring them. This includes checking their references and performing background checks.

2. Recruiting

The process of finding and attracting qualified candidates to fill job openings within an organization is called recruiting. It is important to have a well-defined recruiting process in place in order to attract the best candidates possible.

3. Hiring

The process of formally inviting a candidate to become an employee is called hiring. It is important to have a clear and concise job description in order for candidates to understand what the job entails.

4. Orientation

New employees should be given a comprehensive orientation upon starting their new job. This includes introducing them to the company culture, explaining their duties and responsibilities, and providing training on how to do their job correctly.

5. Training

It is important for employees to be properly trained on the company's policies and procedures, as well as their specific job duties. This will help them to be more productive and effective on the job.

6. Performance Management

Performance management involves setting expectations for employee performance, communicating these expectations, and providing feedback on employee performance.

Performance management is a process that helps ensure that employees are meeting the expectations of their organization. The process begins by setting expectations for employee performance. These expectations can be based on job descriptions, organizational goals, or other standards. Once expectations are set, the next step is to communicate these expectations to employees. This can be done through job descriptions, performance goals, or other means.

The final step is providing feedback on employee performance. This feedback can be positive or negative and can be given formally or informally. The goal of performance management is to help employees meet the expectations of their organization.

7. Compensation and Benefits

The HR department is responsible for ensuring that employees are compensated fairly and receive appropriate benefits. This can help to attract and retain top talent.

8. Employee retention

The HR department should work to create a positive work environment that encourages employees to stay with the company long-term. This can include implementing retention strategies such as employee recognition programs and good benefits packages.

December 26, 20222 minutesauthorDarshika Kyada
The Elements of the Ideal Logo

While logos are essential to the success of your company, creating one may be challenging. The perfect logo should describe who you are and what you do. It is the best investment a company could make to grow its customer base since it gives customers their first, and maybe best, impression of the firm. It is the first thing that clients will notice about the business and its brand. Here are some pointers to assist you in creating the ideal logo.

1. Maintain a Simple Design

The finest logos are simple, despite the fact that simplicity is sometimes linked with being dull. You should avoid overcomplicating your logo with fancy fonts or complex imagery since you want it to be instantly recognisable. So that it may be shown in all sizes and forms, keep your logo basic. You should be allowed to use your logo on stationary such as letterheads and envelopes, business cards and banners, and social media postings. Do not forget that some of the most recognisable brand logos are straightforward and simple enough to be recognised among rivals.

2. Suitable Color Palette

Colors have an attraction on people, but it's crucial to choose the proper palette. It takes a great deal of understanding of color theory and the color combinations that would go well with each other. Your choice of colour should express not just your thoughts but also a clear message. Potential clients may be drawn to or turned off by the hue of your logo design. Learn about various colours, their use, and how they affect your brand by conducting research.

Here are some colors you can include in your logo and what they represent:

  • Black: Represents authority, mystery and sophistication.
  • Red: Represents excitement, love and anger.
  • Yellow: Represents happiness, warmth, innovation and caution.
  • Blue: Represents professionalism, trust and loyalty.
  • Green: Represents harmony, natural and healthy.
  • Orange: Represents playful, artistic and energetic.
  • White: Represents pure, peaceful and clean.

3. Out-of-the-box

Almost all great logos have an eye-catching symbol that separates them from competitors. Use your imagination and take as much inspiration as you want before creating the right logo and make sure the symbol you select is appropriate for your brand. A wonderful work of art is ruined by restrictions and limitations, while creating a logo designers need to be creative and conceive in ways that no one else could. Most well-known logos have really difficult and original looks that no one could have imagined.

4. High Quality Typography

Think on each element of the logo design, such as the typeface or font. Customers may learn a lot about your brand from the typeface you use. Depending on your choice of logo design, this section changes. For instance, if you are creating an icon symbol or brand mark logo, pick a typeface or logo during the preliminary design phases. Doing so helps you avoid having a weird combination or losing the complex work you will have invested in your logo.

5. Timelessness

By timeless, we mean that an excellent logo may last a very long time. Avoid using fashionable pictures, typefaces, and colour schemes in your logo if you want it to survive the test of time. By doing this, you can be sure that your logo keeps serving a function and working well even when trends change. Designers must be foresighted and innovative when establishing a logo since something that is striking today may lose its essence afterwards, and if this happens with the logo, the reputation of your organisation will suffer. If you look at long-standing businesses, you'll see that many of them have utilised the same logo for many years or even decades.

December 24, 20223 minutesauthorNency Dobariya
How to Increase Sales from Upwork

Upwork is a platform that connects freelancers and clients for a wide range of services including sales. If you're looking to increase your sales on Upwork, here are some tips that can help:

  • Build a strong profile

  • Improve your proposal

  • Be Responsive and Professional

  • Offer added value

  • Use Upwork's tools and resources

Build a strong profile

Your Upwork profile is essentially your online resume. Make sure it accurately reflects your skills, experience, and qualifications. Use a clear, professional profile picture and highlight any relevant certifications or achievements.

Improve your proposal

When you apply for a job on Upwork, you will need to write a proposal explaining why you are the best candidate for the job. Read the job posting carefully and tailor your submission to the client's specific needs. Emphasize your relevant experience and skills and provide examples of your work.

Be Responsive and Professional

Once you've landed a job on Upwork, it's important to communicate effectively with your clients and meet deadlines. Respond to messages promptly and be respectful and professional in your interactions. This will help you build a positive reputation on the platform and increase your chances of getting repeat business or referrals.

Offer added value

In addition to getting the job done to the best of your ability, consider offering added value to your customers. This may be in the form of additional resources or advice or offering to complete additional tasks outside the scope of the original job. This can help you stand out from other freelancers and increase your chances of getting repeat business.

Use Upwork's tools and resources

Upwork offers a variety of tools and resources for freelancers, including the ability to track their time, create invoices, and manage their finances. Be sure to take advantage of these resources to streamline your work and make it easier for customers to do business with you.

Following these tips can increase your sales and build a successful freelance business on Upwork. Good luck!

December 22, 20222 minutesauthorAnkit Kalathiya
Laravel hasOneThough & Laravel hasManyThough Relationships

Laravel HasOneTHough & Laravel HasManyThough Relationships

We generally know about the 4 basics Laravel Relations ships that laravel provides:

Now we are going to see the major missing relationships that we are thinking are "Hard to use", but in real cases, it's needed while developing a project.

Even though I was thinking that HasOneThough and HasManyThough Relationships were will be hard to understand, I was wrong. it's really easy to understand.

Understanding HasOneThough

Let's say there is a Library that wants to know the book issuer's name directly, in this case, we generally do :

  • Fetch Books
  • Fetch its related issuer by using the HasOne Relation

What if I say I can directly access the issuer name into the Library model, yes we can achieve this by using the has one though.

Library
- id
- name

Book
- id
- name
- library_id

Issuer
- id
- name
- book_id
public function issuer() {
    return hasOneThough(App\Issuer, App\Book, library_id, book_id)
}

Understanding HasManyThough

Let's say in the same example that there are multiple issuers of the same books, we can achieve it as follow.

public function issuer() {
    return hasManyThough(App\Issuer, App\Book, library_id, book_id)
}

Hope it will be helpful.

Thanks

December 10, 20221 minuteauthorVishal Ribdiya
[Best-Practices] Securing NodeJS Express APIs with JWT Authentication and custom Authorization

Overview


A Node.js library for use as Express middleware to secure endpoints with JWTs. The implementation uses a JWT endpoint of an Authorization Server to get the keys required for verification of the token signature. There is also an example Express app that shows how to use the library.

Package: https://www.npmjs.com/package/jsonwebtoken

Using the JSON web token, we can simply authenticate each and every request on our server. As a standard / best practice, we can use JWT (JSON web token) middleware to validate all requests.

JWT Middleware


  const jwt = require('jsonwebtoken')

  module.exports = (expectedRole) => (req, res, next) => {

  const authHeader = req.get('Authorization')
  if (!authHeader) {
    const error = new Error('Not authenticated.')
    error.statusCode = 401
    throw error
  }

  const token = authHeader.split(' ')[1]
  if (!token) {
    const error = new Error('Not authenticated.')
    error.statusCode = 401
    throw error
  }

  let decodedToken
  try {
    decodedToken = jwt.verify(token, process.env.SECRET_KEY)
  } catch (error) {
    error.statusCode = 401
    throw error
  }

  if (!decodedToken) {
    const error = new Error('Not authenticated.')
    error.statusCode = 401
    throw error
  }

  const role = decodedToken.role

  const authorised = expectedRole.includes(role)
  if (!authorised) {
    const error = new Error('Not authorised.')
    error.statusCode = 401
    throw error
  }

  req.user = decodedToken
  next()
}

This middleware has been prepared and exported. Therefore, we need to include it in our routes file and pass it to the expected role, so in our JWT middleware, we will validate the request with the JWT token, then verify that the user has access to an expected role (this role saved in the database) to this endpoint.

Routes File


 const express = require('express')
 const router = express.Router()

 const auth = require('./auth/index')
 const admin = require('./admin/index')
 const common = require('./common/index')
 const authorize = require('../middleware/jwtAuth')

 router.use('/auth', auth)
 router.use('/admin', authorize(['admin']), admin)
 router.use('/common', authorize(['admin', 'user']), common)

 module.exports = router 

Now that we have set up our authentication and authorization middleware in our routes, we are passing the required role to access these routes. These roles will be checked against our user role.

Our middleware simply next() the request if the user has a valid JWT token and is authorized to access this route, otherwise, it will throw the global error that is caught by the express global error handler.

November 08, 20222 minutesauthorSmit Gajera