Skip to content

c0ldfront/stripe-vendure-plugin

Repository files navigation

NOT MAINTAINED goto https://github.com/gaiusmathew/stripe-payment-plugin

Stripe VendureIO plugin

This plugin enables payments to be processed by Stripe.

Requirements

  • ngx-stripe

Setup

<div [formGroup]="stripeTest">
    <ngx-stripe-card
        [options]="cardOptions"
        [elementsOptions]="elementsOptions"
    ></ngx-stripe-card>
    <button type="submit" (click)="pay()">
        PAY
    </button>
</div>
pay() {
    if (this.stripeTest.valid) {
        this.stateService.select(state => state.activeOrderId).pipe(
            filter(notNullOrUndefined),
            switchMap(data => this.stripeService.createPaymentMethod({
                type: 'card',
                card: this.card.element,
            })),
            filter(notNullOrUndefined),
            switchMap(data => {
                return this.dataService.mutate<AddPayment.Mutation, AddPayment.Variables>(ADD_PAYMENT, {
                    input: {
                        method: 'stripe',
                        metadata: data,
                    },
                });
            }),
            map(data => {
                return data;
            }),
        ).subscribe(async data => {
            const order = data.addPaymentToOrder;
            if (order && (order.state === 'PaymentSettled' || order.state === 'PaymentAuthorized')) {
                await new Promise(resolve => setTimeout(() => {
                    this.stateService.setState('activeOrderId', null);
                    resolve();
                }, 500));
                await this.router.navigate(['../confirmation', order.code], {relativeTo: this.route});
            }
        });

    }
}

Usage

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages