#miriana
1 messages · Page 1 of 1 (latest)
Hi
For PaymentSheet, you need to pass a customerId when creating the PaymentIntent in order to display the save checkbox. There is no explicit option via the SDK
PaymentSheet.Configuration(
merchantDisplayName = "Ticketing",
customer = PaymentSheet.CustomerConfiguration(id=paymentInitResponse.value?.data?.paymentResponse?.customerReference?:"",
ephemeralKeySecret = paymentInitResponse.value?.data?.paymentResponse?.paymentToken?.id ?:""),
)
I am already passing it but the option is still not appearing
I mean when creating the PaymentIntent. can you share the PaymentIntent Id you are using?
https://stripe.com/docs/api/payment_intents/create#create_payment_intent-customer
yes
ah okay if this is a backend issue then I will need to communicate with the backend developer
thank you for your help
pi_3MayS9GmCT9nlFnw1rnLQvGu
Is this it?
Well this PaymentIntent Id has the customer cus_NLAw0ZBByp9PHW attached to it. does the customer param you set in the PaymentSheet is the same ?
cus_NLAw0ZBByp9PHW
yes it is the same
and I still do not see the checkbox option
Can you log the content of this please?
PaymentSheet.CustomerConfiguration(id=paymentInitResponse.value?.data?.paymentResponse?.customerReference?:"",
ephemeralKeySecret = paymentInitResponse.value?.data?.paymentResponse?.paymentToken?.id ?:"")
yes off course
I would need to generate a new payment though
one sec
payment Id : pi_3Mayd0GmCT9nlFnw1pMvhVFB
this is the whole response from backend
implementation 'com.stripe:stripe-android:20.17.0'
For ephemeralKeySecret can you check if in the backend they set the same customerId too?
can you check if they are doing something like this:
const ephemeralKey = await stripe.ephemeralKeys.create(
{ customer: "cus_NLAw0ZBByp9PHW" })
I am getting the customer id from the backend
and what about the ephemeralKey?
ok, and my question is, does the backend creating the ephemeralKeys with the same customer of the PayemtIntent?
And are they sending back the ephemeralKey.secret, which you need to pass to the PaymentSheet.CustomerConfiguration.ephemeralKeySecret
yes
ephkey_1Mayd0GmCT9nlFnwRA4t4DU4
this the ephemeral key for this payment intent
Now for PaymentSheet.CustomerConfiguration.ephemeralKeySecret are you passing the secret of that ephemeral key? ti should be starting with ek_test_YW...
I wasn't passing maybe the right key
I am testing with the other key
now I can see the saved cards on other platforms but can't save cards on my side
ok cool, we're making some advance here.
yeah
can you please relog the PaymentSheet.CustomerConfiguration?
yes one min
CustomerConfiguration(id=cus_NLAw0ZBByp9PHW, ephemeralKeySecret=ek_test_YWNjdF8xTVBCT2dHbUNUOW5sRm53LDhGZFJDTnBSODc2YldDdDFjUFhaVEF5RmxsNEVJS1A_00aqm05JXh)
pi_3Maz6tGmCT9nlFnw0qtrdACc
What code are you using in order to display the PaymentSheet? paymentSheet.presentWithPaymentIntent
stripeLauncher.launch(
PaymentSheetContract.Args.createPaymentIntentArgs(
paymentInitResponse.value?.data?.paymentResponse?.paymentSecret ?:"",
PaymentSheet.Configuration(
merchantDisplayName = "Ticketing",
customer = PaymentSheet.CustomerConfiguration(id=paymentInitResponse.value?.data?.paymentResponse?.customerReference?:"",
ephemeralKeySecret = paymentInitResponse.value?.data?.paymentResponse?.paymentToken?.secret ?:""),
)
)
)
I found this code on your sample with jetpack compose
trying
I don't think this works well with composable functions
the example is inside an activity
this is the link I am using
https://github.com/stripe/stripe-android/blob/master/paymentsheet-example/src/main/java/com/stripe/android/paymentsheet/example/samples/activity/LaunchPaymentSheetWithComposeActivity.kt
stripeLauncher.launch(
PaymentSheetContract.Args.createPaymentIntentArgs(
clientSecret,
PaymentSheet.Configuration(
merchantDisplayName = merchantName,
customer = customerConfig,
googlePay = googlePayConfig,
)
)
)
Yeah I see, but what is the issue exactly ? because at the end its inside an Activity:
https://github.com/stripe/stripe-android/blob/master/paymentsheet-example/src/main/java/com/stripe/android/paymentsheet/example/samples/activity/LaunchPaymentSheetWithComposeActivity.kt#L12
What is the issue you are facing exactly ?
I am not able to create PaymentSheet()
it is crashing
LifecycleOwner com.ticketing.MainActivity@fbe827f is attempting to register while current state is RESUMED.
val paymentSheet = PaymentSheet((context as ComponentActivity)) {
}
Not sure I'm understanding you here. In both example, the two function are called from BasePaymentSheetActivity which are AppCompatActivity what is the different from your integration?
I am calling it from a composable function
@Composable
fun EventDetailsPage(eventDetails: TicketEvent?) {
the second example I sent does not rely on an activity reference
The paymentSheet.presentWithPaymentIntent is called also from a composable function, you can initiate the paymentSheet from the root activity and pass it with a ViewModel, on of the options...
https://github.com/stripe/stripe-android/blob/master/paymentsheet-example/src/main/java/com/stripe/android/paymentsheet/example/samples/activity/LaunchPaymentSheetCompleteActivity.kt#L14
but this would mean I am creating the payment even if I don't want to use it and I would be always observing its state as long as the application is running
just wondering
why is this not working?
stripeLauncher.launch(
PaymentSheetContract.Args.createPaymentIntentArgs(
I'm sure that paymentSheet.presentWithPaymentIntent is supporting the checkbox for saving paymentmethod. but I'm not for stripeLauncher.launch. Doing some tests...
please can we try to get this working because the other option although would work but will be a bit heavy on the application
Agree.
I just tested using the stripeLauncher.launch and I'm having the checkbox for saving the Payment.
can you send me the code you are using exactly please?
There is a difference in your integration that is blocking that from displaying. Try to run the sample project and pass your values within it and see if you manage to display the checkbox. Something like:
stripeLauncher.launch(
PaymentSheetContract.Args.createPaymentIntentArgs(
"pi_3Maz6tGmCT9nlFnw0qtrdACc....",
PaymentSheet.Configuration(
merchantDisplayName = merchantName,
customer = PaymentSheet.CustomerConfiguration(
id = "cus_NLAw0ZBByp9PHW",
ephemeralKeySecret = "ek_test_YW...."
),
googlePay = googlePayConfig,
)
)
)
Use your public key too when building the example.
Use this activity and see what is the difference between your integration and the official one:
https://github.com/stripe/stripe-android/blob/master/paymentsheet-example/src/main/java/com/stripe/android/paymentsheet/example/samples/activity/LaunchPaymentSheetWithComposeActivity.kt#L12
there isn't really much of a difference but I will try
There must be, if you don't see the Checkbox.
I put the code inside the activity and did not work
I am downloading the whole sample and checking if it would make a different
Yes please
sorry for the delay
No worries, take your time
you don't get the checkbox because you pass setup_future_usage: "off_session" on the backend https://dashboard.stripe.com/test/logs/req_4Zq7TwT6XAVLOw
you only get the checkbox if you don't pass setup_future_usage yourself; then the customer has a checkbox to choose to use it or not. There's no checkbox if you have explicitly chosen to set setup_future_usage on the PaymentIntent, because you don't want the customer to be able to turn it off
so what should be done to fix this issue exactly?
I need to pass the message to the other developers since I do not have access to the backend nor the dashboard
depends what you want. If you really want the customer to have that checkbox, remove that line in your backend Node.js code setting setup_future_usage: "off_session"