Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(iOS): Recurring Transactions and order tracking APIs #1248

Merged
merged 15 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@

## Unreleased

### Breaking changes

- [#1248](https://github.com/stripe/stripe-react-native/pull/1248) Renamed the `paymentSummaryItems` field in `initPaymentSheet()`'s `applePay` params to `cartItems`. So your change will look like this:

```diff
initPaymentSheet({
...
applePay: {
- paymentSummaryItems: [
+ cartItems: [
}
...
})
```

## New Features

- Added the `setOrderTracking` property to the `PlatformPayButton` component and the `initPaymentSheet` method. Use this callback for setting the order details to give users the ability to track and manage their purchases in Wallet. To learn more about order tracking, see [Apple’s Wallet Orders documentation](https://developer.apple.com/documentation/walletorders). [#1248](https://github.com/stripe/stripe-react-native/pull/1248)
- Added the `buttonType` field to `initPaymentSheet()`'s `applePay` params. Use this to set the text displayed by the call to action button in the Apple Pay sheet.[#1248](https://github.com/stripe/stripe-react-native/pull/1248)
- Added the `request` field to `initPaymentSheet()`'s, `confirmPlatformPayPayment()`'s, and `confirmPlatformPaySetupIntent`'s `applePay` params. Use this to support different types of payment requests, like `RecurringPaymentRequest`, `AutomaticReloadPaymentRequest`, and `MultiMerchantRequest`.[#1248](https://github.com/stripe/stripe-react-native/pull/1248)

## 0.23.3 - 2023-02-07

## Fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ appId: ${APP_ID}
- tapOn:
text: "Collect bank account"
retryTapIfNoChange: false
- scrollUntilVisible:
element:
text: "Manually verify instead"
direction: DOWN
- tapOn: "Manually verify instead"
- tapOn:
id: "manualEntry_routingNumber"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ appId: ${APP_ID}
- tapOn:
text: "Collect bank account"
retryTapIfNoChange: false
- scrollUntilVisible:
element:
text: "Manually verify instead"
direction: DOWN
- tapOn: "Manually verify instead"
- tapOn:
id: "manualEntry_routingNumber"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ appId: ${APP_ID}
- tapOn:
text: "Collect session"
retryTapIfNoChange: false
- scrollUntilVisible:
element:
text: "Enter account details manually instead"
direction: DOWN
- tapOn: "Enter account details manually instead"
- tapOn:
id: "manualEntry_routingNumber"
Expand All @@ -24,4 +28,7 @@ appId: ${APP_ID}
- tapOn: "Continue"
- assertVisible:
text: "Success"
- tapOn: "OK"
optional: true
- tapOn:
text: "OK"
optional: true
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,27 @@ appId: ${APP_ID}
- tapOn:
text: "Collect token"
retryTapIfNoChange: false
- scrollUntilVisible:
element:
text: "Enter account details manually instead"
direction: DOWN
- tapOn: "Enter account details manually instead"
- tapOn: "123456789"
- tapOn:
id: "manualEntry_routingNumber"
- inputText: "110000000"
- hideKeyboard
- tapOn:
text: "000123456789"
index: 0
id: "manualEntry_accountNumber"
- inputText: "000123456789"
- hideKeyboard
- tapOn:
text: "000123456789"
index: 1
id: "manualEntry_confirmAccountNumber"
- inputText: "000123456789"
- hideKeyboard
- tapOn: "Continue"
- assertVisible:
text: "Success"
- tapOn: "OK"
optional: true
- tapOn:
text: "OK"
optional: true
File renamed without changes.
3 changes: 3 additions & 0 deletions e2e-tests/ios-only/ach-payment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ appId: ${APP_ID}
- tapOn: "Manually verify instead"
- tapOn: "123456789"
- inputText: "110000000"
- hideKeyboard
- tapOn:
text: "000123456789"
index: 0
- inputText: "000123456789"
- hideKeyboard
- tapOn:
text: "000123456789"
index: 1
- inputText: "000123456789"
- hideKeyboard
- tapOn: "Continue"
- tapOn: "Done"
- assertVisible:
Expand Down
3 changes: 3 additions & 0 deletions e2e-tests/ios-only/ach-setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@ appId: ${APP_ID}
- tapOn: "Manually verify instead"
- tapOn: "123456789"
- inputText: "110000000"
- hideKeyboard
- tapOn:
text: "000123456789"
index: 0
- inputText: "000123456789"
- hideKeyboard
- tapOn:
text: "000123456789"
index: 1
- inputText: "000123456789"
- hideKeyboard
- tapOn: "Continue"
- tapOn: "Done"
- assertVisible:
Expand Down
20 changes: 20 additions & 0 deletions e2e-tests/ios-only/applepay-cancel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
appId: ${APP_ID}
---
- launchApp
- tapOn: "Wallets"
- tapOn: "Apple Pay"
- tapOn: "Buy with Apple\_Pay"
- tapOn: "close"
- assertVisible:
text: "Canceled"
- tapOn: "OK"
- tapOn: "Continue with Apple\_Pay"
- tapOn: "close"
- assertVisible:
text: "Canceled"
- tapOn: "OK"
- tapOn: "Set up Apple\_Pay"
- tapOn: "close"
- assertVisible:
text: "Canceled"
- tapOn: "OK"
3 changes: 3 additions & 0 deletions e2e-tests/ios-only/financial-connections-session.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ appId: ${APP_ID}
- tapOn: "Enter account details manually instead"
- tapOn: "123456789"
- inputText: "110000000"
- hideKeyboard
- tapOn:
text: "000123456789"
index: 0
- inputText: "000123456789"
- hideKeyboard
- tapOn:
text: "000123456789"
index: 1
- inputText: "000123456789"
- hideKeyboard
- tapOn: "Continue"
- assertVisible:
text: "Success"
Expand Down
3 changes: 3 additions & 0 deletions e2e-tests/ios-only/financial-connections-token.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ appId: ${APP_ID}
- tapOn: "Enter account details manually instead"
- tapOn: "123456789"
- inputText: "110000000"
- hideKeyboard
- tapOn:
text: "000123456789"
index: 0
- inputText: "000123456789"
- hideKeyboard
- tapOn:
text: "000123456789"
index: 1
- inputText: "000123456789"
- hideKeyboard
- tapOn: "Continue"
- assertVisible:
text: "Success"
Expand Down
14 changes: 14 additions & 0 deletions e2e-tests/ios-only/local-only/applepay-basic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
appId: ${APP_ID}
---
- launchApp
- tapOn: "Wallets"
- tapOn: "Apple Pay"
- tapOn: "Buy with Apple\_Pay"
- tapOn: .*Simulated Card.*
- tapOn:
text: "Simulated Card - AmEx, ‪•••• 1234‬"
index: 0
- tapOn: "Pay with Passcode"
- assertVisible:
text: "Success"
- tapOn: "OK"
14 changes: 14 additions & 0 deletions e2e-tests/ios-only/local-only/applepay-paymentmethod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
appId: ${APP_ID}
---
- launchApp
- tapOn: "Wallets"
- tapOn: "Apple Pay"
- tapOn: "Continue with Apple\_Pay"
- tapOn:
text: "Forward"
index: 1
- tapOn: "Done"
- tapOn: "Pay with Passcode"
- assertVisible:
text: "Success"
- tapOn: "OK"
16 changes: 16 additions & 0 deletions e2e-tests/ios-only/local-only/applepay-token.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
appId: ${APP_ID}
---
- launchApp
- tapOn: "Wallets"
- tapOn: "Apple Pay"
- tapOn: "Set up Apple\_Pay"
- tapOn:
text: "Forward"
index: 3
- tapOn:
text: "Standard Shipping, US$3,21, 8 – 10 Dec 2022"
index: 0
- tapOn: "Pay with Passcode"
- assertVisible:
text: "Success"
- tapOn: "OK"
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ appId: ${APP_ID}
- tapOn:
text: "Pay"
retryTapIfNoChange: false
- waitForAnimationToEnd:
timeout: 2000
- tapOn:
text: "Public Bank"
- tapOn: "AUTHORIZE TEST PAYMENT"
Expand Down
25 changes: 25 additions & 0 deletions e2e-tests/ios-only/local-only/klarna.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
appId: ${APP_ID}
---
- launchApp
- tapOn: "Buy now pay later"
- tapOn: "Klarna"
- assertVisible:
text: "E-mail"
- tapOn:
text: "E-mail"
- inputText: "[email protected]"
- tapOn:
text: "Pay"
retryTapIfNoChange: false
- extendedWaitUntil:
visible: "Let's do a quick verification"
timeout: 30000
- tapOn:
id: "${APP_ID}:id/action_close"
optional: true
- tapOn:
text: "Close"
optional: true
- assertVisible:
text: "Error code: Canceled"
- tapOn: "OK"
34 changes: 21 additions & 13 deletions example/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -625,12 +625,16 @@ app.post('/ephemeral-key', async (req, res) => {
typescript: true,
});

let key = await stripe.ephemeralKeys.create(
{ issuing_card: req.body.issuingCardId },
{ apiVersion: req.body.apiVersion }
);

return res.send(key);
try {
let key = await stripe.ephemeralKeys.create(
{ issuing_card: req.body.issuingCardId },
{ apiVersion: req.body.apiVersion }
);
return res.send(key);
} catch (e) {
console.log(e);
return res.send({ error: e });
}
});

app.post('/issuing-card-details', async (req, res) => {
Expand All @@ -641,15 +645,19 @@ app.post('/issuing-card-details', async (req, res) => {
typescript: true,
});

let card = await stripe.issuing.cards.retrieve(req.body.id);
try {
let card = await stripe.issuing.cards.retrieve(req.body.id);

if (!card) {
return res.send({
error: 'No card with that ID exists.',
});
if (!card) {
console.log('No card with that ID exists.');
return res.send({ error: 'No card with that ID exists.' });
} else {
return res.send(card);
}
} catch (e) {
console.log(e);
return res.send({ error: e });
}

return res.send(card);
});

app.post('/financial-connections-sheet', async (_, res) => {
Expand Down
7 changes: 3 additions & 4 deletions example/src/screens/ApplePayScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,9 @@ export default function ApplePayScreen() {
};

useEffect(() => {
const checkCapability = async () => {
(async function () {
setIsApplePaySupported(await isPlatformPaySupported());
};
checkCapability();
})();
}, [isPlatformPaySupported]);

const checkIfCardInWallet = async () => {
Expand All @@ -120,7 +119,7 @@ export default function ApplePayScreen() {
});

if (error) {
Alert.alert(error.code, error.message);
console.log(error.code, error.message);
} else {
setShowAddToWalletButton(canAddCard ?? false);
if (details?.status) {
Expand Down
4 changes: 2 additions & 2 deletions example/src/screens/CollectBankAccountScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ export default function CollectBankAccountScreen() {
<Button
variant="primary"
onPress={handleCollectTokenPress}
title={loading || !clientSecret ? 'loading...' : 'Collect token'}
title={!clientSecret ? 'loading...' : 'Collect token'}
loading={loading}
disabled={!clientSecret}
/>
<Button
variant="primary"
onPress={handleCollectSessionPress}
title={loading || !clientSecret ? 'loading...' : 'Collect session'}
title={!clientSecret ? 'loading...' : 'Collect session'}
loading={loading}
disabled={!clientSecret}
/>
Expand Down
2 changes: 1 addition & 1 deletion example/src/screens/PaymentSheetWithSetupIntent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default function PaymentSheetWithSetupIntent() {
merchantDisplayName: 'Example Inc.',
applePay: {
merchantCountryCode: 'US',
paymentSummaryItems: [
cartItems: [
{
paymentType: 'Recurring',
label: 'This is a subscription',
Expand Down
1 change: 1 addition & 0 deletions ios/ApplePayButtonManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ @interface RCT_EXTERN_MODULE(ApplePayButtonManager, RCTViewManager)
RCT_EXPORT_VIEW_PROPERTY(onShippingMethodSelectedAction, RCTDirectEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onShippingContactSelectedAction, RCTDirectEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onCouponCodeEnteredAction, RCTDirectEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onOrderTrackingAction, RCTDirectEventBlock)

@end
2 changes: 2 additions & 0 deletions ios/ApplePayButtonView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class ApplePayButtonView: UIView {
@objc var onShippingMethodSelectedAction: RCTDirectEventBlock?
@objc var onShippingContactSelectedAction: RCTDirectEventBlock?
@objc var onCouponCodeEnteredAction: RCTDirectEventBlock?
@objc var onOrderTrackingAction: RCTDirectEventBlock?

@objc var type: NSNumber?
@objc var buttonStyle: NSNumber?
Expand All @@ -33,6 +34,7 @@ class ApplePayButtonView: UIView {
stripeSdk?.shippingMethodUpdateJSCallback = onShippingMethodSelectedAction
stripeSdk?.shippingContactUpdateJSCallback = onShippingContactSelectedAction
stripeSdk?.couponCodeEnteredJSCallback = onCouponCodeEnteredAction
stripeSdk?.platformPayOrderTrackingJSCallback = onOrderTrackingAction
}
}

Expand Down
Loading