Skip to content

Commit 0c8d2be

Browse files
Merge branch 'next' into payments-api
2 parents 5a4c0c4 + 0b4f2f0 commit 0c8d2be

27 files changed

+320
-23
lines changed

firestore-stripe-payments/CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
## Version 0.2.4 - 2021-12-22
2+
3+
[feat] Add support to bring phone numbers saved on Firebase users into Stripe when creating a checkout session for a subscription. (#251)
4+
15
## Version 0.2.3 - 2021-11-29
26

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.
7+
[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. (#246)
48

59
## Version 0.2.2 - 2021-11-09
610

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.3
16+
version: 0.2.4
1717
specVersion: v1beta
1818

1919
displayName: Run Payments with Stripe

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

Lines changed: 20 additions & 7 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/src/index.ts

Lines changed: 15 additions & 4 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.3',
37+
version: '0.2.4',
3838
},
3939
});
4040

@@ -46,8 +46,10 @@ admin.initializeApp();
4646
const createCustomerRecord = async ({
4747
email,
4848
uid,
49+
phone,
4950
}: {
5051
email?: string;
52+
phone?: string;
5153
uid: string;
5254
}) => {
5355
try {
@@ -58,6 +60,7 @@ const createCustomerRecord = async ({
5860
},
5961
};
6062
if (email) customerData.email = email;
63+
if (phone) customerData.phone = phone;
6164
const customer = await stripe.customers.create(customerData);
6265
// Add a mapping record in Cloud Firestore.
6366
const customerRecord = {
@@ -67,6 +70,7 @@ const createCustomerRecord = async ({
6770
customer.livemode ? '' : '/test'
6871
}/customers/${customer.id}`,
6972
};
73+
if (phone) (customerRecord as any).phone = phone;
7074
await admin
7175
.firestore()
7276
.collection(config.customersCollectionPath)
@@ -84,8 +88,12 @@ exports.createCustomer = functions.auth
8488
.user()
8589
.onCreate(async (user): Promise<void> => {
8690
if (!config.syncUsersOnCreate) return;
87-
const { email, uid } = user;
88-
await createCustomerRecord({ email, uid });
91+
const { email, uid, phoneNumber } = user;
92+
await createCustomerRecord({
93+
email,
94+
uid,
95+
phone: phoneNumber,
96+
});
8997
});
9098

9199
/**
@@ -125,10 +133,13 @@ exports.createCheckoutSession = functions.firestore
125133
// Get stripe customer id
126134
let customerRecord = (await snap.ref.parent.parent.get()).data();
127135
if (!customerRecord?.stripeId) {
128-
const { email } = await admin.auth().getUser(context.params.uid);
136+
const { email, phoneNumber } = await admin
137+
.auth()
138+
.getUser(context.params.uid);
129139
customerRecord = await createCustomerRecord({
130140
uid: context.params.uid,
131141
email,
142+
phone: phoneNumber,
132143
});
133144
}
134145
const customer = customerRecord.stripeId;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export interface CustomerData {
2121
firebaseUID: string;
2222
};
2323
email?: string;
24+
phone?: string;
2425
}
2526

2627
export interface Price {

firestore-stripe-web-sdk/deploy.sh

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,37 @@ RED_BG=$(tput setab 1)
88
YELLOW=$(tput setaf 3)
99
RESET=$(tput sgr 0)
1010
BOLD=$(tput bold)
11+
FIREBASE_WEB_SDK_DIR="firestore-stripe-web-sdk"
12+
MIN_NODE_VERSION="12"
13+
14+
# verify we are in the correct directory for the script
15+
if [[ "${PWD##*/}" != "${FIREBASE_WEB_SDK_DIR}" ]]; then
16+
echo "${RED}ERROR:${RESET} Please run this script in the ${FIREBASE_WEB_SDK_DIR} directory"
17+
exit 1
18+
fi
1119

1220
# verify we meant to run this script
1321
read -r -n 1 -p "${YELLOW}WARNING:${RESET} running this script deploys changes publicly. Are you sure you want to continue? [y/n] "
1422
echo
1523
echo
1624
if [[ ! "${REPLY}" =~ ^[Yy]$ ]]; then exit 1; fi
1725

18-
# verify the user has required permissions
26+
# verify that we have updated the patch/release version
27+
public_sdk_version=$(npm view @stripe/firestore-stripe-payments version)
28+
local_sdk_version=$(npm version | sed -n '2'p | cut -d : -f 2 | cut -d , -f 1 | cut -d \' -f 2)
29+
if [[ "${public_sdk_version}" == "${local_sdk_version}" ]]; then
30+
echo "${RED}ERROR:${RESET} Your local web-sdk version matches the public web-sdk version. Please bump the version with ${BOLD}npm version patch${RESET} or a similar command"
31+
exit 1
32+
fi
33+
34+
echo "${GREEN}SUCCESS:${RESET} your local web-sdk version is different from the public web-sdk version"
35+
echo
36+
echo "local web-sdk version is ${YELLOW}${local_sdk_version}${RESET}"
37+
echo "public web-sdk version is ${GREEN}${public_sdk_version}${RESET}"
38+
echo
39+
echo
40+
41+
# verify the user has required npm permissions
1942
read -r -n 1 -p "Do you have a stripe npm account with 2FA? [y/n] "
2043
echo
2144
echo
@@ -25,14 +48,14 @@ if [[ ! "${REPLY}" =~ ^[Yy]$ ]]; then
2548
fi
2649

2750
version=$(nodenv version | cut -d . -f 1)
28-
if [ ! "${version}" -gt "12" ]; then
29-
echo "${RED}ERROR:${RESET} must have node version 12 or greater"
51+
if [ ! "${version}" -gt "${MIN_NODE_VERSION}" ]; then
52+
echo "${RED}ERROR:${RESET} must have node version ${MIN_NODE_VERSION} or greater"
3053
echo "current version is ${YELLOW}$(nodenv version | cut -d ' ' -f 1)${RESET}"
3154
echo
32-
echo "set new node version with ${BOLD}nodenv shell 14.7.0${RESET} or any other installed version 12 or greater to continue"
55+
echo "set new node version with ${BOLD}nodenv shell 14.7.0${RESET} or any other installed version ${MIN_NODE_VERSION} or greater to continue"
3356
exit 1
3457
fi
35-
echo "${GREEN}SUCCESS:${RESET} your current node version is 12 or greater (${GREEN}$(nodenv version | cut -d ' ' -f 1)${RESET})"
58+
echo "${GREEN}SUCCESS:${RESET} your current node version is ${MIN_NODE_VERSION} or greater (${GREEN}$(nodenv version | cut -d ' ' -f 1)${RESET})"
3659
echo
3760

3861
if ! npm team ls @stripe:developers &> /dev/null; then
@@ -76,10 +99,12 @@ echo
7699
echo "${GREEN}SUCCESS:${RESET} all tests have passed"
77100
echo
78101

79-
if ! rm stripe-firestore-stripe-payments-*.tgz; then
80-
echo
81-
echo "${RED}ERROR:${RESET} encountered an error removing old release artifacts"
82-
exit 1
102+
if [[ $(ls stripe-firestore-stripe-payments-*.tgz) ]]; then
103+
if ! rm stripe-firestore-stripe-payments-*.tgz; then
104+
echo
105+
echo "${RED}ERROR:${RESET} encountered an error removing old release artifacts"
106+
exit 1
107+
fi
83108
fi
84109

85110
if ! npm run build; then
@@ -98,6 +123,7 @@ echo
98123
echo "${GREEN}SUCCESS:${RESET} built the release artifact"
99124
echo
100125

126+
# verify one last time
101127
read -r -n 1 -p "Did you notify #developer-products and #developer-advocacy about this release? [y/n] "
102128
echo
103129
echo
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@stripe/firestore-stripe-payments](./firestore-stripe-payments.md) &gt; [CommonSessionCreateParams](./firestore-stripe-payments.commonsessioncreateparams.md) &gt; [allow\_promotion\_codes](./firestore-stripe-payments.commonsessioncreateparams.allow_promotion_codes.md)
4+
5+
## CommonSessionCreateParams.allow\_promotion\_codes property
6+
7+
Enables user redeemable promotion codes.
8+
9+
<b>Signature:</b>
10+
11+
```typescript
12+
allow_promotion_codes?: boolean;
13+
```
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@stripe/firestore-stripe-payments](./firestore-stripe-payments.md) &gt; [CommonSessionCreateParams](./firestore-stripe-payments.commonsessioncreateparams.md) &gt; [automatic\_tax](./firestore-stripe-payments.commonsessioncreateparams.automatic_tax.md)
4+
5+
## CommonSessionCreateParams.automatic\_tax property
6+
7+
Set to true to enable automatic taxes. Defaults to false.
8+
9+
<b>Signature:</b>
10+
11+
```typescript
12+
automatic_tax?: boolean;
13+
```
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@stripe/firestore-stripe-payments](./firestore-stripe-payments.md) &gt; [CommonSessionCreateParams](./firestore-stripe-payments.commonsessioncreateparams.md) &gt; [client\_reference\_id](./firestore-stripe-payments.commonsessioncreateparams.client_reference_id.md)
4+
5+
## CommonSessionCreateParams.client\_reference\_id property
6+
7+
A unique string to reference the Checkout Session. This can be a customer ID, a cart ID, or similar, and can be used to reconcile the session with your internal systems.
8+
9+
<b>Signature:</b>
10+
11+
```typescript
12+
client_reference_id?: string;
13+
```

0 commit comments

Comments
 (0)