adonis-stripe icon indicating copy to clipboard operation
adonis-stripe copied to clipboard

AdonisJS 6

Open MichaelBelgium opened this issue 1 year ago • 5 comments
trafficstars

Adonis V6 got released on the 24th of january, it'd be great if you make this package compatible :)

There is a package migration guide

MichaelBelgium avatar Jan 25 '24 17:01 MichaelBelgium

Is the repository is dead? No sign of any activity...

lviardcretat avatar Feb 21 '24 08:02 lviardcretat

@IceCrew-Source Looks like it...

It's been a month now, I might have to make a fork and make it compatible myself

Unless there is another stripe package for adonis v6?

MichaelBelgium avatar Feb 24 '24 12:02 MichaelBelgium

I've been quite busy lately. This is currently been worked on. Expect a new version to be tagged in the coming week.

ammezie avatar Feb 24 '24 17:02 ammezie

Hey @ammezie, have you already gotten around to work on this? 🙌

CodingDive avatar May 26 '24 11:05 CodingDive

@CodingDive I found out you don't really need this package, you can achieve the same thing by installing the official stripe package and making a provider and service in your adonisjs app

stripe_provider.ts

import env from '#start/env';
import type { ApplicationService } from '@adonisjs/core/types'
import Stripe from 'stripe';

declare module '@adonisjs/core/types' {
    export interface ContainerBindings {
      'stripe.manager': Stripe
    }
}

export default class StripeProvider {
    constructor(protected app: ApplicationService) {}

    /**
     * Register bindings to the container
     */
    register() {
      this.app.container.singleton('stripe.manager', () => {
        return new Stripe(env.get('STRIPE_SECRET_KEY')!, {
            apiVersion: '2024-04-10',
        });
      });
    }
}

stripe_service.ts

import app from '@adonisjs/core/services/app';

const stripe = await app.container.make('stripe.manager');
export { stripe as default }

And then you can use it like normally, for example

import stripe from '#services/stripe_service';

//...

async foo()
{
    const activeSubs = await stripe.subscriptions.list({
        status: 'active'
    });

    return activeSubs;
}

MichaelBelgium avatar May 27 '24 08:05 MichaelBelgium