-
Notifications
You must be signed in to change notification settings - Fork 252
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: support for Bacs debit payments #1352
Open
khzouroussama
wants to merge
4
commits into
stripe:master
Choose a base branch
from
khzouroussama:feat/bacs
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
8a72e5c
chore: bacs ios implementation + working example
khzouroussama 4981399
chore: added android implementation for bacs payments
khzouroussama e6a6760
chore: added e2e tests
khzouroussama b74b691
Merge branch 'master' into feat/bacs
khzouroussama File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
appId: ${APP_ID} | ||
--- | ||
- launchApp | ||
- tapOn: 'Bank Debits' | ||
- tapOn: 'Bacs Direct Debit payment' | ||
- assertVisible: | ||
text: 'E-mail' | ||
- tapOn: | ||
text: 'E-mail' | ||
- inputText: 'test@stripe.com' | ||
- tapOn: | ||
text: 'sortCode' | ||
- inputText: '108800' | ||
- tapOn: | ||
text: 'accountNumber' | ||
- inputText: '90012345' | ||
- tapOn: | ||
text: 'Pay' | ||
retryTapIfNoChange: false | ||
- assertVisible: | ||
text: 'Processing' | ||
- tapOn: 'OK' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
import { PaymentIntent, BillingDetails } from '@stripe/stripe-react-native'; | ||
import React, { useState } from 'react'; | ||
import { Alert, StyleSheet, TextInput } from 'react-native'; | ||
import { useConfirmPayment } from '@stripe/stripe-react-native'; | ||
import Button from '../components/Button'; | ||
import PaymentScreen from '../components/PaymentScreen'; | ||
import { API_URL } from '../Config'; | ||
import { colors } from '../colors'; | ||
|
||
export default function BacsPaymentScreen() { | ||
const [email, setEmail] = useState(''); | ||
const { confirmPayment, loading } = useConfirmPayment(); | ||
const [sortCode, setSortCode] = useState(''); | ||
const [accountNumber, setAccountNumber] = useState(''); | ||
const [canPay, setCanPay] = useState(true); | ||
|
||
const fetchPaymentIntentClientSecret = async () => { | ||
const response = await fetch(`${API_URL}/create-payment-intent`, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify({ | ||
email, | ||
currency: 'gbp', | ||
items: ['id-1'], | ||
payment_method_types: ['bacs_debit'], | ||
}), | ||
}); | ||
const { clientSecret, error } = await response.json(); | ||
|
||
return { clientSecret, error }; | ||
}; | ||
|
||
const handlePayPress = async () => { | ||
const { clientSecret, error: clientSecretError } = | ||
await fetchPaymentIntentClientSecret(); | ||
|
||
if (clientSecretError) { | ||
Alert.alert(`Error`, clientSecretError); | ||
return; | ||
} | ||
|
||
const billingDetails: BillingDetails = { | ||
name: 'John Doe', | ||
email: email, | ||
address: { | ||
country: 'UK', | ||
line1: 'test', | ||
city: 'test', | ||
}, | ||
}; | ||
setCanPay(false); | ||
|
||
const { error, paymentIntent } = await confirmPayment(clientSecret, { | ||
paymentMethodType: 'BacsDebit', | ||
paymentMethodData: { billingDetails, sortCode, accountNumber }, | ||
}); | ||
|
||
if (error) { | ||
Alert.alert(`Error code: ${error.code}`, error.message); | ||
} else if (paymentIntent) { | ||
if (paymentIntent.status === PaymentIntent.Status.Processing) { | ||
Alert.alert( | ||
'Processing', | ||
`The debit has been successfully submitted and is now processing.` | ||
); | ||
} else if (paymentIntent.status === PaymentIntent.Status.Succeeded) { | ||
Alert.alert( | ||
'Success', | ||
`The payment was confirmed successfully! currency: ${paymentIntent.currency}` | ||
); | ||
} else { | ||
Alert.alert('Payment status:', paymentIntent.status); | ||
} | ||
} | ||
setCanPay(true); | ||
}; | ||
|
||
return ( | ||
<PaymentScreen paymentMethod="bacs_debit"> | ||
<TextInput | ||
autoCapitalize="none" | ||
placeholder="E-mail" | ||
keyboardType="email-address" | ||
onChange={(value) => setEmail(value.nativeEvent.text)} | ||
style={styles.input} | ||
/> | ||
<TextInput | ||
autoCapitalize="characters" | ||
placeholder="sortCode" | ||
onChange={(value) => setSortCode(value.nativeEvent.text.toLowerCase())} | ||
style={styles.input} | ||
/> | ||
|
||
<TextInput | ||
autoCapitalize="characters" | ||
placeholder="accountNumber" | ||
onChange={(value) => | ||
setAccountNumber(value.nativeEvent.text.toLowerCase()) | ||
} | ||
style={styles.input} | ||
/> | ||
<Button | ||
variant="primary" | ||
onPress={handlePayPress} | ||
title="Pay" | ||
disabled={!canPay} | ||
accessibilityLabel="Pay" | ||
loading={loading} | ||
/> | ||
</PaymentScreen> | ||
); | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
cardField: { | ||
width: '100%', | ||
height: 50, | ||
marginVertical: 30, | ||
}, | ||
row: { | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
marginVertical: 20, | ||
}, | ||
text: { | ||
marginLeft: 12, | ||
}, | ||
input: { | ||
height: 44, | ||
borderBottomColor: colors.slate, | ||
borderBottomWidth: 1.5, | ||
marginBottom: 20, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that, although not required, it would be best for us to encrypt this information before transferring it over the Bridge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@charliecruzan-stripe Could you please provide advice on what is the best way to do this? Also, does the new architecture remove the necessity for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new architecture would remove the necessity for this, so we should wait for that migration before working on this feature
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@charliecruzan-stripe Any idea the type of timeframes for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not at the moment, the new architecture is still very experimental
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@charliecruzan-stripe Is there anything I can do to help get this over the line? If the new architecture isn't ready I'm happy to try and add encryption to this PR if that helps.