Stripe Payment Integration With Laravel | StackCoder

In this article lets discuss how to integrate Stripe with Laravel.

https://stackcoder.in/posts/stripe-payment-integration-with-laravel

#laravel #stripe #paymentgateway

What is GEEK

Buddha Community

Stripe Payment Integration With Laravel | StackCoder

Stripe Payment Gateway Integration Example In Laravel 8

In this post i will share you stripe payment gateway integration example in laravel 8, stripe payment gateway is integrated in many website for payment collection from client, In this time many e-commerce website and other shopping websites are use stripe payment gateway.

So, here we will learn stripe payment gateway integration in laravel 8.

Read More : Stripe Payment Gateway Integration Example In Laravel 8

https://websolutionstuff.com/post/stripe-payment-gateway-integration-example-in-laravel-8


Read Also : How To Integrate Paypal Payment Gateway In Laravel

https://websolutionstuff.com/post/how-to-integrate-paypal-payment-gateway-in-laravel

#stripe payment gateway integration example in laravel 8 #laravel 8 stripe payment gateway integration example #stripe payment gateway integration in laravel 8 #stripe payment gateway #laravel8 #payment gateway

Seamus  Quitzon

Seamus Quitzon

1596410232

How to integrate paytm payment gateway in laravel example

As we know that paytm is fastest growing plateform to provies payment services. So here i will let you know how to integrate paytm payment gateway in laravel with an example.

Paytm provides digital payment methods and boomed after digital india movement. Most of the marchant accepts paytm payment.

Here, in this example we will use a laravel package (“anandsiddharth/laravel-paytm-wallet”) to integrate paytm payment gateway in our laravel application.

So let’s start paytm integration process in our laravel application from scratch. You will need to just follow the steps as mentioned in this tutorial.

Step 1: Install laravel

In this first step, we will create a fresh laravel application using the following command. If you don’t want to install new application you can also integrate into your existing application. You can jump directly to the next step otherwise just open your terminal and run the command as given below.

composer create-project --prefer-dist laravel/laravel test-app

Step 2: Install Package

For installing the desired package, you will just need to run the following composer command in your terminal. It will automatically dowload all the files required for this package in your application.

composer require anandsiddharth/laravel-paytm-wallet

After running the above command, you will need to setup some configurations for this package. So open config/app.php file and add provider and alias as given as under.

config/app.php

'providers' => [

  ....

  Anand\LaravelPaytmWallet\PaytmWalletServiceProvider::class,

],

'aliases' => [

  ....

  'PaytmWallet' => Anand\LaravelPaytmWallet\Facades\PaytmWallet::class,

],

Now we will need to add some other configuration like marchant id and key. So open config/services.php file and add the line of code as mentaioned below.

config/services.php

<?php

return [

    ......
    'paytm-wallet' => [
        'env' => 'local', // values : (local | production)
        'merchant_id' => env('YOUR_MERCHANT_ID'),
        'merchant_key' => env('YOUR_MERCHANT_KEY'),
        'merchant_website' => env('YOUR_WEBSITE'),
        'channel' => env('YOUR_CHANNEL'),
        'industry_type' => env('YOUR_INDUSTRY_TYPE'),
    ],

];

Now add these secret key date in the application’s environment file like below.

YOUR_MERCHANT_ID=DIY12XXXXXXXXXXXXXXXX
YOUR_MERCHANT_KEY=bKXXXXXXXXXXX

YOUR_WEBSITE=XXXXXXXXX

YOUR_CHANNEL=WEB

YOUR_INDUSTRY_TYPE=Retail

#laravel #integrate paytm in laravel #integration paytm gateway laravel example #laravel paytm integration #paytm gateway in laravel #paytm payment gateway

Seamus  Quitzon

Seamus Quitzon

1595201363

Php how to delete multiple rows through checkbox using ajax in laravel

First thing, we will need a table and i am creating products table for this example. So run the following query to create table.

CREATE TABLE `products` (
 `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
 `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
 `description` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
 `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
 `updated_at` datetime DEFAULT NULL,
 PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci

Next, we will need to insert some dummy records in this table that will be deleted.

INSERT INTO `products` (`name`, `description`) VALUES

('Test product 1', 'Product description example1'),

('Test product 2', 'Product description example2'),

('Test product 3', 'Product description example3'),

('Test product 4', 'Product description example4'),

('Test product 5', 'Product description example5');

Now we are redy to create a model corresponding to this products table. Here we will create Product model. So let’s create a model file Product.php file under app directory and put the code below.

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Product extends Model
{
    protected $fillable = [
        'name','description'
    ];
}

Step 2: Create Route

Now, in this second step we will create some routes to handle the request for this example. So opeen routes/web.php file and copy the routes as given below.

routes/web.php

Route::get('product', 'ProductController@index');
Route::delete('product/{id}', ['as'=>'product.destroy','uses'=>'ProductController@destroy']);
Route::delete('delete-multiple-product', ['as'=>'product.multiple-delete','uses'=>'ProductController@deleteMultiple']);

#laravel #delete multiple rows in laravel using ajax #laravel ajax delete #laravel ajax multiple checkbox delete #laravel delete multiple rows #laravel delete records using ajax #laravel multiple checkbox delete rows #laravel multiple delete

August  Larson

August Larson

1661358540

How to Create Customer Balances for Spark Laravel & Stripe

Introduction

In the following documentation, we will discuss how to configure a Laravel Spark installation when using the Stripe (opens new window)payment provider. All of Spark's configuration options are housed in your application's config/spark.php configuration file.

#Stripe Configuration

Of course, to use Stripe as a payment provider for your Laravel Spark application you must have an active Stripe account (opens new window).

#Environment Variables

Next, you should configure the application environment variables that will be needed by Spark in order to access your Stripe account. These variables should be placed in your application's .env environment file.

Of course, you should adjust the variable's values to correspond to your own Stripe account's credentials. Your Stripe API credentials and public key are available in your Stripe account dashboard:

CASHIER_CURRENCY=USD
CASHIER_CURRENCY_LOCALE=en
STRIPE_KEY=pk_test_example
STRIPE_SECRET=sk_test_example
STRIPE_WEBHOOK_SECRET=sk_test_example

Configuring Locales

In order to use locales other than en, ensure the ext-intl PHP extension is installed and configured on your server.

#Stripe Webhooks

In addition, your Spark powered application will need to receive webhooks from Stripe in order to keep your application's billing and subscription data in sync with Stripe's. Within your Stripe dashboard's webhook management panel, you should configure Stripe to send webhook alerts to your application's /spark/webhook URI. You should enable webhook alerts for the following events:

  • customer.deleted
  • customer.subscription.created
  • customer.subscription.deleted
  • customer.subscription.updated
  • customer.updated
  • invoice.payment_action_required
  • invoice.payment_succeeded

#Webhooks & Local Development

For Stripe to be able to send your application webhooks during local development, you will need to expose your application via a site sharing service such as Ngrok (opens new window)or Expose (opens new window). If you are developing your application locally using Laravel Sail (opens new window), you may use Sail's site sharing command (opens new window).

#Configuring Billables

Spark allows you to define the types of billable models that your application will be managing. Most commonly, applications bill individual users for monthly and yearly subscription plans. However, your application may choose to bill some other type of model, such as a team, organization, band, etc. The Stripe edition of Spark currently only supports a single billable model entity (team, user, etc.) per application.

You may define your billable models within the billables array of your application's spark configuration file. By default, this array contains an entry for the App\Models\User model. If the billable model is something other than App\Models\User, you should invoke Cashier's useCustomerModel method in the boot method of your AppServiceProvider class in order to inform Cashier of your custom model:

use App\Entities\User;
use Laravel\Cashier\Cashier;
 
/**
 * Bootstrap any application services.
 *
 * @return void
 */
public function boot()
{
    Cashier::useCustomerModel(User::class);
}

Before continuing, you should ensure that the model class that corresponds to your billable model is using the Spark\Billable trait and that it casts the trial_ends_at attribute to datetime:

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Spark\Billable;

class User extends Authenticatable
{
    use Billable, HasFactory, Notifiable;

    protected $casts = [
        'trial_ends_at' => 'datetime',
    ];

}

#Billable Slugs

As you may have noticed, each entry in the billables configuration array is keyed by a "slug" that is a shortened form of the billable model class. This slug can be used when accessing the Spark customer billing portal, such as https://example.com/billing/user or https://example.com/billing/team.

#Billable Resolution

When you installed Laravel Spark, an App\Providers\SparkServiceProvider class was created for you. Within this service provider, you will find a callback that is used by Spark to resolve the billable model instance when accessing the Spark billing portal. By default, this callback simply returns the currently authenticated user, which is the desired behavior for most applications using Laravel Spark:

use App\Models\User;
use Illuminate\Http\Request;
use Spark\Spark;

Spark::billable(User::class)->resolve(function (Request $request) {
    return $request->user();
});

However, if your application is not billing individual users, you may need to adjust this callback. For example, if your application offers team billing instead of user billing, you might customize the callback like so:

use App\Models\Team;
use Illuminate\Http\Request;
use Spark\Spark;

Spark::billable(Team::class)->resolve(function (Request $request) {
    return $request->user()->currentTeam;
});

#Billable Authorization

Next, let's examine the authorization callbacks that Spark will use to determine if the currently authenticated user of your application is authorized to view the billing portal for a particular billable model.

When you installed Laravel Spark, an App\Providers\SparkServiceProvider class was created for you. Within this service provider, you will find the authorization callback definition used to determine if a given user is authorized to view the billing portal for the App\Models\User billable class. Of course, if your application is not billing users, you should update the billable class and authorization callback logic to fit your application's needs. By default, Spark will simply verify that the currently authenticated user can only manage its own billing settings:

use App\Models\User;
use Illuminate\Http\Request;
use Spark\Spark;

Spark::billable(User::class)->authorize(function (User $billable, Request $request) {
    return $request->user() &&
           $request->user()->id == $billable->id;
});

If the authorization callback returns true, the currently authenticated user will be authorized to view the billing portal and manage the billing settings for the given $billable model. If the callback returns false, the request to access the billing portal will be denied.

You are free to customize the authorize callback based on your own application's needs. For example, if your application bills teams instead of individual users, you might update the callback like so:

use App\Models\Team;
use Illuminate\Http\Request;
use Spark\Spark;

Spark::billable(Team::class)->authorize(function (Team $billable, Request $request) {
    return $request->user() &&
           $request->user()->ownsTeam($billable);
});

#Defining Subscription Plans

As we previously discussed, Spark allows you to define the types of billable models that your application will be managing. These billable models are defined within the billables array of your application's config/spark.php configuration file:

Each billable configuration within the billables array contains a plans array. Within this array you may configure each of the billing plans offered by your application to that particular billable type. The monthly_id and yearly_id identifiers should correspond to the price / plan identifiers configured within your Stripe account dashboard:

use App\Models\User;

'billables' => [
    'user' => [
        'model' => User::class,
        'trial_days' => 5,
        'plans' => [
            [
                'name' => 'Standard',
                'short_description' => 'This is a short, human friendly description of the plan.',
                'monthly_id' => 'price_id',
                'yearly_id' => 'price_id',
                'features' => [
                    'Feature 1',
                    'Feature 2',
                    'Feature 3',
                ],
            ],
        ],
    ],
]

If your subscription plan only offers a monthly billing cycle, you may omit the yearly_id identifier from your plan configuration. Likewise, if your plan only offers a yearly billing cycle, you may omit the monthly_id identifier.

In addition, you are free to supply a short description of the plan and a list of features relevant to the plan. This information will be displayed in the Spark billing portal.

#Accessing The Billing Portal

Once you have configured your Spark installation, you may access your application's billing portal at the /billing URI. So, if your application is being served on localhost, you may access your application's billing portal at http://localhost/billing.

Of course, you may link to the billing portal from your application's dashboard however you see fit:

<a href="/billing">
    Manage Subscription
</a>

#Showing A Link To The Terms And Conditions

Many applications display billing terms and conditions during checkout. Spark allows you to easily do the same within your application's billing portal. To get started, add a terms_url configuration value in your application's config/spark.php configuration file:

'terms_url' => '/terms'

Once added, Spark will display a link pointing to /terms in the billing portal.

#Customer Balance Top Ups

Spark Stripe allows your customers to "top up" their balance. This feature can prove useful if your customer's cards do not support recurring payments, such as customers under India's RBI regulations.

To get started, you will need to create a special product and price in your Stripe Dashboard. So, create a product called "Balance Top Up" and add a price to the product that utilizes the "Customer chooses price" Stripe pricing model. After creating the product and price, define the price ID as an environment variable in your application's .env file:

SPARK_TOP_UP_PRICE=price_xxx

After defining the environment variable, enable the top up feature using its corresponding feature flag in your application's config/spark.php configuration file:

'features' => [
    ...
    Features::topups(['price' => env('SPARK_TOPUP_PRICE')]),
    ...
],

Once this feature has been enabled, the balance top up button will be shown in the Spark billing portal. After clicking the balance top up button, the customer will be redirected to a Stripe Checkout session where they can choose the monetary amount they wish to add to their account. Once the customer has completed the Checkout session, the customer will be redirected back to the Spark billing portal and their balance will be updated. You should ensure that your Stripe webhooks are configured to dispatch the checkout.session.completed event.

Invoices are not generated for balance top ups, as invoicing only occurs when the billing cycle renews. Customers that need a refund for a balance top up will need to contact your application's customer support, and the charge can then be refunded manually from the Stripe dashboard.

Link: https://spark.laravel.com/docs/2.x/spark-stripe/configuration.html

#stripe #laravel #php

Einar  Hintz

Einar Hintz

1602564925

Razorpay Payment Gateway Integration in ASP.NET MVC

In this article, you will learn Razorpay Payment Gateway Integration in ASP.NET MVC web application or an eCommerce website using C#. With Razorpay, you have access to all payment modes, including credit and debit cards, UPI, and popular mobile wallets.

To check the Razorpay Payment Gateway demo, please click here:

How to integrate Razorpay Payment Gateway in ASP.NET

The Razorpay Payment Gateway enables you to accept payments via debit card, credit card, net banking (supports 3D Secure), UPI, or through any of our supported wallets. Refer to the Payment Methods section for a list of payment methods we support.

Find the below steps to integrate Razorpay in your website:-

#asp.net #how to #mvc #razorpay payment gateway #razorpay payment gateway demo #razorpay payment gateway documentation #razorpay payment gateway integration #razorpay payment gateway integration in asp.net c#