Skip to content

Commit

Permalink
feat(service): add support for identity
Browse files Browse the repository at this point in the history
  • Loading branch information
richnologies committed Jun 30, 2021
1 parent cb13b41 commit cfee7c4
Show file tree
Hide file tree
Showing 6 changed files with 166 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 12.3.0 - 2021-06-30

- Add support for Stripe Identity

## 12.2.1 - 2021-06-25

- Update README.md with new Logo
Expand Down
2 changes: 1 addition & 1 deletion projects/ngx-stripe/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-stripe",
"version": "12.2.1",
"version": "12.3.0",
"repository": {
"type": "git",
"url": "https://github.com/richnologies/ngx-stripe"
Expand Down
148 changes: 147 additions & 1 deletion projects/ngx-stripe/src/lib/interfaces/stripe-instance.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,71 @@ import {
StripeIbanElement,
Source,
Token,
TokenCreateParams
TokenCreateParams,
ConfirmAcssDebitPaymentData,
ConfirmAcssDebitPaymentOptions,
ConfirmAfterpayClearpayPaymentData,
ConfirmAfterpayClearpayPaymentOptions,
ConfirmAlipayPaymentData,
ConfirmGrabPayPaymentData,
ConfirmGrabPayPaymentOptions,
ConfirmKlarnaPaymentData,
ConfirmKlarnaPaymentOptions,
ConfirmOxxoPaymentData,
ConfirmOxxoPaymentOptions,
ConfirmSofortPaymentData,
ConfirmWechatPayPaymentData,
ConfirmWechatPayPaymentOptions,
VerifyMicrodepositsForPaymentData,
ConfirmAcssDebitSetupData,
ConfirmAcssDebitSetupOptions,
ConfirmBacsDebitSetupData,
ConfirmBancontactSetupData,
ConfirmIdealSetupData,
ConfirmSofortSetupData,
VerifyMicrodepositsForSetupData,
ConfirmAlipayPaymentOptions
} from '@stripe/stripe-js';

// TEMPORARY WORKAROUND UNTIL OFFICIAL SUPPORT IS RELEASED
export interface VerificationSession {
id: string;
}

export type VerificationSessionResult =
| { verificationSession: VerificationSession; error?: undefined }
| { verificationSession?: undefined; error: StripeError };

export interface StripeServiceInterface {
getInstance(): Stripe | undefined;
elements(options?: StripeElementsOptions): Observable<StripeElements>;
redirectToCheckout(
options?: RedirectToCheckoutOptions
): Observable<never | { error: StripeError }>;
confirmAcssDebitPayment(
clientSecret: string,
data?: ConfirmAcssDebitPaymentData,
options?: ConfirmAcssDebitPaymentOptions
): Observable<{
paymentIntent?: PaymentIntent;
error?: StripeError;
}>;
confirmAfterpayClearpayPayment(
clientSecret: string,
data?: ConfirmAfterpayClearpayPaymentData,
options?: ConfirmAfterpayClearpayPaymentOptions
): Observable<{
paymentIntent?: PaymentIntent;
error?: StripeError;
}>;
confirmAlipayPayment(
clientSecret: string,
data?: ConfirmAlipayPaymentData,
options?: ConfirmAlipayPaymentOptions
): Observable<{
paymentIntent?: PaymentIntent;
error?: StripeError;
}>;
confirmAuBecsDebitPayment(
clientSecret: string,
data?: ConfirmAuBecsDebitPaymentData
Expand Down Expand Up @@ -101,6 +157,14 @@ export interface StripeServiceInterface {
paymentIntent?: PaymentIntent;
error?: StripeError;
}>;
confirmGrabPayPayment(
clientSecret: string,
data?: ConfirmGrabPayPaymentData,
options?: ConfirmGrabPayPaymentOptions
): Observable<{
paymentIntent?: PaymentIntent;
error?: StripeError;
}>;
confirmIdealPayment(
clientSecret: string,
data?: ConfirmIdealPaymentData,
Expand All @@ -109,6 +173,22 @@ export interface StripeServiceInterface {
paymentIntent?: PaymentIntent;
error?: StripeError;
}>;
confirmKlarnaPayment(
clientSecret: string,
data?: ConfirmKlarnaPaymentData,
options?: ConfirmKlarnaPaymentOptions
): Observable<{
paymentIntent?: PaymentIntent;
error?: StripeError;
}>;
confirmOxxoPayment(
clientSecret: string,
data?: ConfirmOxxoPaymentData,
options?: ConfirmOxxoPaymentOptions
): Observable<{
paymentIntent?: PaymentIntent;
error?: StripeError;
}>;
confirmP24Payment(
clientSecret: string,
data?: ConfirmP24PaymentData,
Expand All @@ -124,12 +204,34 @@ export interface StripeServiceInterface {
paymentIntent?: PaymentIntent;
error?: StripeError;
}>;
confirmSofortPayment(
clientSecret: string,
data?: ConfirmSofortPaymentData
): Observable<{
paymentIntent?: PaymentIntent;
error?: StripeError;
}>;
confirmWechatPayPayment(
clientSecret: string,
data?: ConfirmWechatPayPaymentData,
options?: ConfirmWechatPayPaymentOptions
): Observable<{
paymentIntent?: PaymentIntent;
error?: StripeError;
}>;
handleCardAction(
clientSecret: string
): Observable<{
paymentIntent?: PaymentIntent;
error?: StripeError;
}>;
verifyMicrodepositsForPayment(
clientSecret: string,
data?: VerifyMicrodepositsForPaymentData
): Observable<{
paymentIntent?: PaymentIntent;
error?: StripeError;
}>;
createPaymentMethod(
paymentMethodData: CreatePaymentMethodData
): Observable<{
Expand All @@ -142,13 +244,35 @@ export interface StripeServiceInterface {
paymentIntent?: PaymentIntent;
error?: StripeError;
}>;
confirmAcssDebitSetup(
clientSecret: string,
data?: ConfirmAcssDebitSetupData,
options?: ConfirmAcssDebitSetupOptions
): Observable<{
setupIntent?: SetupIntent;
error?: StripeError;
}>;
confirmAuBecsDebitSetup(
clientSecret: string,
data?: ConfirmAuBecsDebitSetupData
): Observable<{
setupIntent?: SetupIntent;
error?: StripeError;
}>;
confirmBacsDebitSetup(
clientSecret: string,
data?: ConfirmBacsDebitSetupData
): Observable<{
setupIntent?: SetupIntent;
error?: StripeError;
}>;
confirmBancontactSetup(
clientSecret: string,
data?: ConfirmBancontactSetupData
): Observable<{
setupIntent?: SetupIntent;
error?: StripeError;
}>;
confirmCardSetup(
clientSecret: string,
data?: ConfirmCardSetupData,
Expand All @@ -157,13 +281,34 @@ export interface StripeServiceInterface {
setupIntent?: SetupIntent;
error?: StripeError;
}>;
confirmIdealSetup(
clientSecret: string,
data?: ConfirmIdealSetupData
): Observable<{
setupIntent?: SetupIntent;
error?: StripeError;
}>;
confirmSepaDebitSetup(
clientSecret: string,
data?: ConfirmSepaDebitSetupData
): Observable<{
setupIntent?: SetupIntent;
error?: StripeError;
}>;
confirmSofortSetup(
clientSecret: string,
data?: ConfirmSofortSetupData
): Observable<{
setupIntent?: SetupIntent;
error?: StripeError;
}>;
verifyMicrodepositsForSetup(
clientSecret: string,
data?: VerifyMicrodepositsForSetupData
): Observable<{
setupIntent?: SetupIntent;
error?: StripeError;
}>;
retrieveSetupIntent(
clientSecret: string
): Observable<{
Expand Down Expand Up @@ -209,6 +354,7 @@ export interface StripeServiceInterface {
retrieveSource(
source: RetrieveSourceParam
): Observable<{ source?: Source; error?: StripeError }>;
verifyIdentity(clientSecret: string): Observable<VerificationSessionResult>;
/**
* @deprecated
*/
Expand Down
2 changes: 1 addition & 1 deletion projects/ngx-stripe/src/lib/ngx-stripe.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const components = [

const directives = [StripeCardGroupDirective];

const currentVersion = '12.2.1';
const currentVersion = '12.3.0';

@NgModule({
declarations: [...components, ...directives],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ import {
WrapperLibrary
} from '@stripe/stripe-js';

import { StripeServiceInterface } from '../interfaces/stripe-instance.interface';
import { StripeServiceInterface, VerificationSessionResult } from '../interfaces/stripe-instance.interface';

import { WindowRef } from './window-ref.service';
import {
Expand Down Expand Up @@ -668,6 +668,13 @@ export class StripeInstance implements StripeServiceInterface {
);
}

verifyIdentity(clientSecret: string): Observable<VerificationSessionResult> {
return this.stripe.pipe(
switchMap((stripe) => from((stripe as any).verifyIdentity(clientSecret) as Promise<VerificationSessionResult>)),
first()
);
}

/**
* @deprecated
*/
Expand Down
6 changes: 5 additions & 1 deletion projects/ngx-stripe/src/lib/services/stripe.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ import {
STRIPE_OPTIONS,
NGX_STRIPE_VERSION
} from '../interfaces/ngx-stripe.interface';
import { StripeServiceInterface } from '../interfaces/stripe-instance.interface';
import { StripeServiceInterface, VerificationSessionResult } from '../interfaces/stripe-instance.interface';

import { WindowRef } from './window-ref.service';
import {
Expand Down Expand Up @@ -511,6 +511,10 @@ export class StripeService implements StripeServiceInterface {
return this.stripe.retrieveSource(source);
}

verifyIdentity(clientSecret: string): Observable<VerificationSessionResult> {
return this.stripe.verifyIdentity(clientSecret);
}

/**
* @deprecated
*/
Expand Down

0 comments on commit cfee7c4

Please sign in to comment.