-
Notifications
You must be signed in to change notification settings - Fork 266
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: ⚡ Update payment details after calling initPaymentSheet #1653
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -292,6 +292,29 @@ class PaymentSheetFragment( | |||||
flowController?.confirm() | ||||||
} | ||||||
|
||||||
fun updateIntentConfiguration(bundle: Bundle, promise: Promise){ | ||||||
val onFlowControllerConfigure = PaymentSheet.FlowController.ConfigCallback { _, _ -> | ||||||
val result = flowController?.getPaymentOption()?.let { | ||||||
val bitmap = getBitmapFromVectorDrawable(context, it.drawableResourceId) | ||||||
val imageString = getBase64FromBitmap(bitmap) | ||||||
val option: WritableMap = WritableNativeMap() | ||||||
option.putString("label", it.label) | ||||||
option.putString("image", imageString) | ||||||
createResult("paymentOption", option) | ||||||
} ?: run { | ||||||
WritableNativeMap() | ||||||
} | ||||||
promise.resolve(result) | ||||||
} | ||||||
|
||||||
this.intentConfiguration = buildIntentConfiguration(bundle); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
this.flowController?.configureWithIntentConfiguration( | ||||||
intentConfiguration = this.intentConfiguration!!, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||
configuration = paymentSheetConfiguration, | ||||||
callback = onFlowControllerConfigure | ||||||
); | ||||||
} | ||||||
|
||||||
private fun configureFlowController() { | ||||||
val onFlowControllerConfigure = PaymentSheet.FlowController.ConfigCallback { _, _ -> | ||||||
val result = flowController?.getPaymentOption()?.let { | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -710,14 +710,15 @@ app.post('/payment-intent-for-payment-sheet', async (req, res) => { | |
|
||
try { | ||
const paymentIntent = await stripe.paymentIntents.create({ | ||
amount: 5099, | ||
currency: 'usd', | ||
amount: req.body.amount || 5099, | ||
currency: req.body.currency || 'usd', | ||
payment_method: req.body.paymentMethodId, | ||
customer: req.body.customerId, | ||
}); | ||
|
||
return res.send({ clientSecret: paymentIntent.client_secret }); | ||
} catch (e) { | ||
console.log(e); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove |
||
return res.send({ error: e }); | ||
} | ||
}); | ||
|
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.
looks like this is copied from above, maybe we can extract this out to a helper function?