Skip to content

Commit

Permalink
partial migration guide
Browse files Browse the repository at this point in the history
  • Loading branch information
charliecruzan-stripe committed Oct 18, 2022
1 parent 8a71c3e commit b74891e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
30 changes: 30 additions & 0 deletions docs/Native-Pay-Migration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# `isApplePaySupported` and `isGooglePaySupported`

`isApplePaySupported` and `isGooglePaySupported` have both been replaced by `isNativePaySupported`.

`isNativePaySupported` requires no parameters, but you _can_ optionally pass in the same parameter you passed in to `isGooglePaySupported`. However, this now belongs under the `googlePay` field. So the change would look like:

```diff
- isGooglePaySupported(myParams);
+ isNativePaySupported({googlePay: myParams});
```

# `presentApplePay`, `confirmApplePayPayment`, `initGooglePay`, `presentGooglePay`, and `createGooglePayPaymentMethod`

`presentApplePay`, `confirmApplePayPayment`, `isGooglePaySupported`, `presentGooglePay`, and `createGooglePayPaymentMethod` have been replaced with:

- `confirmNativePaySetupIntent` if you were using them to confirm a setup intent
- `confirmNativePayPayment` if you were using them to confirm a payment intent
- `createNativePayPaymentMethod` if you were using them to create a payment method (this was impossible previously with Apple Pay, so it was only possible on Android). This method also now creates and returns the Stripe token object.

# `updateApplePaySummaryItems`

`updateApplePaySummaryItems` has been replaced with `updateApplePaySheet`.

`updateApplePaySheet` accepts the same first parameter: your cart items. The second parameter allows you to set new shipping methods, and the third parameter allows you to set specific errors in the Apple Pay sheet so your customer can take action during checkout.

# `useGooglePay` and `useApplePay`

`useGooglePay` and `useApplePay` have both been replaced by the `useNativePay` hook.

`useNativePay` allows you to take action when a customer inputs a coupon code (via the `onApplePayCouponCodeEntered` prop).
7 changes: 4 additions & 3 deletions src/hooks/useNativePay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export type Props = {
* Pass this callback function to update the Apple Pay sheet after the customer selects a shipping method.
* @example
* ```ts
* const { presentApplePay } = useNativePay({
* const { ... } = useNativePay({
* onApplePayShippingMethodSelected: (shippingMethod, handler) => {
* handler(newCartItems, shippingMethods, anyErrors);
* }
Expand All @@ -35,7 +35,7 @@ export type Props = {
* Pass this callback function to update the Apple Pay sheet after the customer edits their contact.
* @example
* ```ts
* const { presentApplePay } = useNativePay({
* const { ... } = useNativePay({
* onApplePayShippingContactSelected: (contact, handler) => {
* handler(newCartItems, shippingMethods, anyErrors);
* }
Expand All @@ -56,7 +56,7 @@ export type Props = {
* Pass this callback function to update the Apple Pay sheet (including pricing) after the customer inputs a coupon code.
* @example
* ```ts
* const { presentApplePay } = useNativePay({
* const { ... } = useNativePay({
* onApplePayCouponCodeEntered: (couponCode, handler) => {
* if (isValid(couponCode)) {
* handler(newCartItems, shippingMethods, []);
Expand Down Expand Up @@ -291,6 +291,7 @@ export function useNativePay({
);

return {
/** Use this boolean to present a spinner or other similar loading screen. `true` if the SDK is currently processing, `false` if it is not. */
loading,
/**
* Check if the relevant native wallet (Apple Pay on iOS, Google Pay on Android) is supported.
Expand Down

0 comments on commit b74891e

Please sign in to comment.