Skip to content

Commit 45df7bc

Browse files
Merge pull request #316 from stripe/next
November 29, 2021 Release
2 parents e077c06 + 206e5a8 commit 45df7bc

File tree

12 files changed

+265
-14
lines changed

12 files changed

+265
-14
lines changed

firestore-stripe-payments/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## Version 0.2.3 - 2021-11-29
2+
3+
[feat] Manage payment methods in the Dashboard: setting `payment_method_types` is now optional. By default, all payment methods enabled in your Stripe Dashboard will be presented on the Stripe Checkout page.
4+
15
## Version 0.2.2 - 2021-11-09
26

37
[RENAME] The extension has been renamed from `firestore-stripe-subscriptions` to `firestore-stripe-payments` to better reflect the support for both one time, and recurring payments.

firestore-stripe-payments/extension.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
name: firestore-stripe-payments
16-
version: 0.2.2
16+
version: 0.2.3
1717
specVersion: v1beta
1818

1919
displayName: Run Payments with Stripe

firestore-stripe-payments/functions/lib/index.js

Lines changed: 19 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

firestore-stripe-payments/functions/lib/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

firestore-stripe-payments/functions/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"dependencies": {
1414
"firebase-admin": "^9.9.0",
1515
"firebase-functions": "^3.14.1",
16-
"stripe": "8.170.0"
16+
"stripe": "8.191.0"
1717
},
1818
"devDependencies": {
1919
"@types/express": "^4.17.11",

firestore-stripe-payments/functions/src/index.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const stripe = new Stripe(config.stripeSecretKey, {
3434
// https://stripe.com/docs/building-plugins#setappinfo
3535
appInfo: {
3636
name: 'Firebase firestore-stripe-payments',
37-
version: '0.2.2',
37+
version: '0.2.3',
3838
},
3939
});
4040

@@ -103,9 +103,10 @@ exports.createCheckoutSession = functions.firestore
103103
success_url,
104104
cancel_url,
105105
quantity = 1,
106-
payment_method_types = ['card'],
106+
payment_method_types,
107107
shipping_rates = [],
108108
metadata = {},
109+
automatic_payment_methods = { enabled: true },
109110
automatic_tax = false,
110111
tax_rates = [],
111112
tax_id_collection = false,
@@ -150,7 +151,6 @@ exports.createCheckoutSession = functions.firestore
150151
billing_address_collection,
151152
shipping_address_collection: { allowed_countries: shippingCountries },
152153
shipping_rates,
153-
payment_method_types,
154154
customer,
155155
customer_update,
156156
line_items: line_items
@@ -166,6 +166,9 @@ exports.createCheckoutSession = functions.firestore
166166
cancel_url,
167167
locale,
168168
};
169+
if (payment_method_types) {
170+
sessionCreateParams.payment_method_types = payment_method_types;
171+
}
169172
if (mode === 'subscription') {
170173
sessionCreateParams.subscription_data = {
171174
trial_from_plan,
@@ -225,17 +228,28 @@ exports.createCheckoutSession = functions.firestore
225228
`When using 'client:mobile' and 'mode:payment' you must specify amount and currency!`
226229
);
227230
}
228-
const paymentIntent = await stripe.paymentIntents.create({
231+
const paymentIntentCreateParams: Stripe.PaymentIntentCreateParams = {
229232
amount,
230233
currency,
231234
customer,
232235
metadata,
233-
});
236+
};
237+
if (payment_method_types) {
238+
paymentIntentCreateParams.payment_method_types =
239+
payment_method_types;
240+
} else {
241+
paymentIntentCreateParams.automatic_payment_methods =
242+
automatic_payment_methods;
243+
}
244+
const paymentIntent = await stripe.paymentIntents.create(
245+
paymentIntentCreateParams
246+
);
234247
paymentIntentClientSecret = paymentIntent.client_secret;
235248
} else if (mode === 'setup') {
236249
const setupIntent = await stripe.setupIntents.create({
237250
customer,
238251
metadata,
252+
payment_method_types: payment_method_types ?? ['card'],
239253
});
240254
setupIntentClientSecret = setupIntent.client_secret;
241255
} else {
@@ -615,6 +629,8 @@ export const handleWebhookEvents = functions.handler.https.onRequest(
615629
'price.updated',
616630
'price.deleted',
617631
'checkout.session.completed',
632+
'checkout.session.async_payment_succeeded',
633+
'checkout.session.async_payment_failed',
618634
'customer.subscription.created',
619635
'customer.subscription.updated',
620636
'customer.subscription.deleted',
@@ -682,6 +698,8 @@ export const handleWebhookEvents = functions.handler.https.onRequest(
682698
);
683699
break;
684700
case 'checkout.session.completed':
701+
case 'checkout.session.async_payment_succeeded':
702+
case 'checkout.session.async_payment_failed':
685703
const checkoutSession = event.data
686704
.object as Stripe.Checkout.Session;
687705
if (checkoutSession.mode === 'subscription') {

firestore-stripe-web-sdk/etc/firestore-stripe-payments.api.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,19 @@ export interface CommonLineItemParams {
1515

1616
// @public
1717
export interface CommonSessionCreateParams {
18+
allow_promotion_codes?: boolean;
19+
automatic_tax?: boolean;
1820
cancel_url?: string;
21+
client_reference_id?: string;
22+
metadata?: {
23+
[key: string]: any;
24+
};
1925
mode?: "subscription" | "payment";
26+
payment_method_types?: PaymentMethodType[];
27+
promotion_code?: string;
2028
success_url?: string;
29+
tax_id_collection?: boolean;
30+
trial_from_plan?: boolean;
2131
}
2232

2333
// @public (undocumented)
@@ -92,6 +102,9 @@ export interface LineItemSessionCreateParams extends CommonSessionCreateParams {
92102
// @public
93103
export function onCurrentUserSubscriptionUpdate(payments: StripePayments, onUpdate: (snapshot: SubscriptionSnapshot) => void, onError?: (error: StripePaymentsError) => void): () => void;
94104

105+
// @public
106+
export type PaymentMethodType = "card" | "acss_debit" | "afterpay_clearpay" | "alipay" | "bacs_debit" | "bancontact" | "boleto" | "eps" | "fpx" | "giropay" | "grabpay" | "ideal" | "klarna" | "oxxo" | "p24" | "sepa_debit" | "sofort" | "wechat_pay";
107+
95108
// @public
96109
export interface Price {
97110
// (undocumented)
@@ -137,14 +150,24 @@ export interface Product {
137150

138151
// @public
139152
export interface Session {
153+
readonly allow_promotion_codes?: boolean;
154+
readonly automatic_tax?: boolean;
140155
readonly cancel_url: string;
156+
readonly client_reference_id?: string;
141157
readonly created_at: string;
142158
readonly id: string;
143159
readonly line_items?: LineItem[];
160+
readonly metadata?: {
161+
[key: string]: any;
162+
};
144163
readonly mode: "subscription" | "payment";
164+
readonly payment_method_types?: PaymentMethodType[];
145165
readonly price?: string;
166+
readonly promotion_code?: string;
146167
readonly quantity?: number;
147168
readonly success_url: string;
169+
readonly tax_id_collection?: boolean;
170+
readonly trial_from_plan?: boolean;
148171
readonly url: string;
149172
}
150173

firestore-stripe-web-sdk/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export {
3131
LineItem,
3232
LineItemParams,
3333
LineItemSessionCreateParams,
34+
PaymentMethodType,
3435
PriceIdLineItemParams,
3536
PriceIdSessionCreateParams,
3637
Session,

firestore-stripe-web-sdk/src/init.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import { FirebaseApp, registerVersion } from "@firebase/app";
1818

19-
registerVersion("@stripe/firestore-stripe-payments", "__VERSION__");
19+
registerVersion("firestore-stripe-payments", "__VERSION__");
2020

2121
/**
2222
* Serves as the main entry point to this library. Initializes the client SDK,

0 commit comments

Comments
 (0)