src/core/stripe/stripe.service.ts
Properties |
|
Methods |
|
Async confirmPaymentIntents | ||||||
confirmPaymentIntents(id: string)
|
||||||
Defined in src/core/stripe/stripe.service.ts:48
|
||||||
Parameters :
Returns :
Promise<Stripe.paymentIntents.IPaymentIntent>
|
Async createPaymentIntents | |||||||||||||||
createPaymentIntents(amount: number, paymentMethodID: string, statementDescriptor, returnUrl: string)
|
|||||||||||||||
Defined in src/core/stripe/stripe.service.ts:8
|
|||||||||||||||
Parameters :
Returns :
Promise<Stripe.paymentIntents.IPaymentIntent>
|
Async createPaymentMethods | |||||||||||||||
createPaymentMethods(cardNumber: string, expMonth: number, expYear: number, cvc: string)
|
|||||||||||||||
Defined in src/core/stripe/stripe.service.ts:25
|
|||||||||||||||
Parameters :
Returns :
Promise<Stripe.paymentMethods.IPaymentMethod>
|
Async retrievePaymentIntents | ||||||
retrievePaymentIntents(id: string)
|
||||||
Defined in src/core/stripe/stripe.service.ts:42
|
||||||
Parameters :
Returns :
Promise<Stripe.paymentIntents.IPaymentIntent>
|
Private Readonly stripe |
Default value : new Stripe(process.env.STRIPE_OG_TEST)
|
Defined in src/core/stripe/stripe.service.ts:6
|
import { Injectable } from '@nestjs/common';
import * as Stripe from 'stripe';
@Injectable()
export class StripeService {
private readonly stripe = new Stripe(process.env.STRIPE_OG_TEST);
async createPaymentIntents(
amount: number,
paymentMethodID: string,
statementDescriptor,
returnUrl: string
): Promise<Stripe.paymentIntents.IPaymentIntent> {
return this.stripe.paymentIntents.create({
amount,
currency: 'gbp',
statement_descriptor: statementDescriptor,
payment_method: paymentMethodID,
confirmation_method: 'manual',
confirm: true,
return_url: returnUrl,
});
}
async createPaymentMethods(
cardNumber: string,
expMonth: number,
expYear: number,
cvc: string
): Promise<Stripe.paymentMethods.IPaymentMethod> {
return this.stripe.paymentMethods.create({
type: 'card',
card: {
cvc,
number: cardNumber,
exp_month: expMonth,
exp_year: expYear,
},
});
}
async retrievePaymentIntents(
id: string
): Promise<Stripe.paymentIntents.IPaymentIntent> {
return this.stripe.paymentIntents.retrieve(id);
}
async confirmPaymentIntents(
id: string
): Promise<Stripe.paymentIntents.IPaymentIntent> {
return this.stripe.paymentIntents.confirm(id);
}
}