#Parth R. Jangid (Pseudo Bugs)

1 messages · Page 1 of 1 (latest)

serene quartzBOT
charred nebula
south kestrel
#

Thanks for the reference but I didn't understand from it that well, I am confused.
I need some clarification on this. My current code attaches a payment method to my customer okay. I am not sending anything else other than my payment Method ID to my server. So is this okay to do so? Earlier I have sending card details directly and Rebeus not to do so until I am PCI complaint which I amm not.

2nd Query is that why do we use set up intent?

3rd what did you mean by this: You should use the setup intent's client secret to collect the payment method details.?
Like I am passing the customer while I create the set up intent okay and then I am returning the client secret to my iOS App then how do I do what you are trying to say?

charred nebula
#

So is this okay to do so?
How are you currently creating the PM? The PM should be created when you submit payment details on the setupintent, so that's not recommended.
2nd Query is that why do we use set up intent?
SetupIntents are used to create payment methods so that they are set up for future use (reduces liklihood of decline or needing 3ds auth later on)
Like I am passing the customer while I create the set up intent okay and then I am returning the client secret to my iOS App then how do I do what you are trying to say?
That would be this step in the guide I sent you: https://stripe.com/docs/payments/save-and-reuse?platform=ios&ui=payment-sheet#collect-payment-details

Learn how to save payment details and charge your customers later.

south kestrel
#

I understood the answer to 2nd.

For the 1st question: I have a Checkout button on clicking that I am fetching the Setup Intent's client secret and then creating a Payment Method like this:
STPAPIClient.shared.createPaymentMethod(with: paymentMethodParams)

Then I was sending this to another backend endpoint to confirm the Setup Intent but it didn't work.

charred nebula
#

Yeah you shouldn't do that

#

Follow the guide I sent

#

If you submit payment method details properly on the setupintent a payment method will be automatically created for you

#

Read over that guide

south kestrel
#

I tried understanding that Collect payment details step but I want to ask you that it is using Stripe's built in payment Sheet. It is creating an object and then passing it to the PaymentButton button but I am not using Payment Sheet in my application.

charred nebula
#

What are you using? How are you collecting payment details?

#

With your own form?

south kestrel
#

Nah not my own form instead using this: STPPaymentCardTextField

#

So like I have a checkbox so if the user selects that then before processing the payment I want to save that card for that user and then proceed ahead with the payment.

serene quartzBOT
charred nebula
#

Oh ok. Just curious, why not use the payment sheet?

south kestrel
#

Like it's someone else's project so I have to stick to what they say.

#

So like what I am trying to do is that possible? Is there any way to do this?

charred nebula
#

Ok I think it's possible

#

In that guide, you'll notice that we create a PaymentIntent and pass its client secret to collect payment method details and submit payment

#

You should be able to just substitute out that PaymentIntent with a SetupIntent and use the SetupIntent's client secret to collect payment details and set it up for future use

south kestrel
#

Okay I will look into it but in the meanwhile please don't close this thead

charred nebula
#

We close threads after some inactivity because the open thread list gets unmaintainable

#

If you come back later and thread is closed, just message in main channel and we'll open up a new one

south kestrel
#

Oh okay

#

Hi,
Can you point me to a reference where I can see if any method like STPSetupIntentParams exists

lean blaze
south kestrel
#

Oh okay I look into that too.

#

So @lean blaze , is STPAPIClient.shared.confirmSetupIntent and STPPaymentHandler.shared().confirmSetupIntent the same thing?

lean blaze
#

Can you link to the docs where you are seeing these objects?

south kestrel
#

@lean blaze I believe it worked but I need a confirmation from your side whether I am not violating any policies/regulations. Please bear with me I will post some small snippet of code.

south kestrel
#

Issue #356
StripeHandler.swift
From Stripe 16.0.0 https://github.com/stripe/stripe-ios/blob/master/CHANGELOG.md#1600-2019-07-18
Migrates STPPaymentCardTextField.cardParams property type from STPCardParams to STPPaymentMethodCardParams
final class StripeHandler { func createPaymentMethod( textField: STPPaymentCardTextField, completion: @escapin...

lean blaze
south kestrel
#

So currently my code added a card to my user's Stripe account.

After fetching the client secret from server:

if let card = paymentMethodsParams?.card {
  if let cardNumber = card.number,
  let expMonth = card.expMonth,
  let expYear = card.expYear,
  let cvc = card.cvc {
     let cardParams=STPPaymentMethodCardParams()
     cardParams.number = cardNumber
     cardParams.expMonth = expMonth
     cardParams.expYear = expYear
     cardParams.cvc = cvc
                      
     let paymentMethodParams = STPPaymentMethodParams(card: cardParams, billingDetails: nil, metadata: nil)
                      
  let setupIntentParams = STPSetupIntentConfirmParams(clientSecret: clientSecret)
                      setupIntentParams.paymentMethodParams = paymentMethodParams

                      STPAPIClient.shared.confirmSetupIntent(with: setupIntentParams) { setupIntentResult, error in
      if let error = error {
          print("Error confirming SetupIntent: \(error)")
        return
    }
                        
                        print("setupIntentResult^^^^: \(setupIntentResult)") }```

So this code added the card to the user's account but I just want to confirm that this code has nothing to do with being PCI complaint right? Not legal advice but just is this correct way?
south kestrel
#

So this code does work. Like it adds the payment method to the account but the log in my Stripe Dashboard:

POST /v1/setup_intents has many fields set to null:

"payment_method_options": {
    "card": {
      "mandate_options": null,
      "network": null,
      "request_three_d_secure": "automatic"
    }
  },
"status": "requires_payment_method",```

Why is that so?
lean blaze
#

Do you have the request ID?

south kestrel
#

req_CfUH6ClI078Wol this correct?

lean blaze
#

Okay, you only passed the customer and nothing else. So all the other fields are empty or null

south kestrel
#

Oh and I don't know why was my card details not passed because my code is like this:

let paymentMethodParams = STPPaymentMethodParams(card: cardParams, billingDetails: nil, metadata: nil)
                      
let setupIntentParams = STPSetupIntentConfirmParams(clientSecret: clientSecret)
                      setupIntentParams.paymentMethodParams = paymentMethodParams

                      STPAPIClient.shared.confirmSetupIntent(with: setupIntentParams) { setupIntentResult, error in
if let error = error {

    print("Error confirming SetupIntent:\(error)") 
return
    }
                        
                        print("setupIntentResult^^^^: \(setupIntentResult)")
                          
}
#

setupIntentParams.paymentMethodParams = paymentMethodParams
Isn't this step correct?

lean blaze
#

Are you sure there are card details in the cardParams object?

south kestrel
#

I will print it and share the exact response, that will help

serene quartzBOT
south kestrel
#
Printing the cardParams: <StripePayments.STPPaymentMethodCardParams: 0x600003f4fa70; last4 = 4242; expMonth = 2; expYear = 45; cvc = <redacted>; token = >
2023-06-16 10:13:21.729273-0700 sofiit[6882:14500074] LOG ANALYTICS: ["publishable_key": "some_key_I_have_hidden", "app_version": "1.0", "install": "S", "apple_pay_enabled": 1, "additional_info": [], "company_name": "sofiit", "os_version": "16.4", "bindings_version": "23.9.0", "ocr_type": "none", "pay_var": "legacy", "product_usage": ["STPPaymentCardTextField"], "device_type": "arm64", "source_type": "card", "event": "stripeios.setup_intent_confirmation", "analytics_ua": "analytics.stripeios-1.0", "app_name": "sofiit"]

#

The weird thing is that the card is being added the Stripe Account but the response has no details of card.

#

My events looks like this:

SetupIntent seti_1NJgD7BilogIeZ8xCWqgbBnK has succeeded - 6/16/23, 10:13:22 AM
A card payment method ending in 4242 was attached to customer cus_O2cK7KonnxAZ0g
6/16/23 - 10:13:22 AM
A new SetupIntent seti_1NJgD7BilogIeZ8xCWqgbBnK was created - 6/16/23, 10:13:21 AM
lean blaze
south kestrel
#

Got it sir. Thank you so much. But this is the correct way right to add payment method right? Now I understood that I the paymentMethodId is what I should extract from the setupIntentResult

One last question the official docs say that:
Instead of passing this to STPAPIClient.confirmSetupIntent(...) directly, we recommend using STPPaymentHandler to handle any additional steps for you.

I understood that sometime there will be authentication and then user might be navigated to browser if var useStripeSDK is false, So like I can set the return URL. So like how should one handle authentication?

cobalt palm
#

Good question, finding our docs on handling 3DS now...

south kestrel
#

Damn this is too much.
I will look into this. Thank you so much for the reference.

Also, I have this query in mind:
I am using this STPAPIClient.shared.confirmSetupIntent right now okay. And the https://stripe.dev/stripe-ios/stripe/documentation/stripe/stpsetupintentconfirmparams docs says that I should use STPPaymentHandler and the 3DS docs also seem to be using STPPaymentHandler.

So then I will refactor code but then STPPaymentHandler has a method confirmSetupIntent which needs authenticationContext: STPAuthenticationContext so where do I get this from?

#

Also using this approach of creating a setup intent and creating a new payment method on iOS side and then confirming is allowing me to attach the card twice. A card with same details was already existing and then I did this process one more time and again it added the payment method. The id is different but the finger print is the same. So is it my duty to keep track of fingerprints and only process if it does not already exists?

cobalt palm
cobalt palm
south kestrel
#

Makes sense I will try something using that fingerprint thing.

cobalt palm
south kestrel
cobalt palm
#

No worries, I needed to look it all up myself

south kestrel
cobalt palm
#

Sounds good, on that topic we actually have this doc specifically about saving payment methods with the payment sheet. It doesn't have a section on the card element flow but like I said that payment doc should be very similar https://stripe.com/docs/payments/save-and-reuse

south kestrel
#

Too many things to consider.
Thanks a lot.
I will revert with question if I have any.