#0Bietnua-ios-check-default-pm

1 messages · Page 1 of 1 (latest)

glass pine
#

Hello 👋
Could you clarify the use-case for me here? 🙂
Typically you'd want to check this on your server-side

lament star
#

Right now I am able to set default payment method by calling one of api on our backend

#

So is there any way from sdk

#

I can know the current user already have default payment method

#

I need it to remove some warning on UI

#

So not sure I can get that information directly from sdk or I can’t

glass pine
#

hmm let me check

lament star
#

Thanks

glass pine
lament star
#

I can get customer from customer context but I don’t see any property to determine about default payment method

#

I can see defaultSource

#

But not sure that is default payment method

glass pine
lament star
#

That one from server side

#

I just wanna try to get it directly from sdk

glass pine
#

Oh no! sorry for the confusion. I was just pointing to the field description.
Default source may not be the default if you use PaymentMethod API.
You'd also want to check invoiceSettings > default_payment_method

lament star
#

I can see it but I don’t see invoice setting in response

glass pine
#

ah okay
Let me dig deeper

lament star
#

I can get customer info
customerContext.retrieveCustomer { customer, eror in
customer?.allResponseFields
}

#

but seem there is not much information and also don't see anything relates to default payment method

glass pine
#

and the response that you're seeing is the same as what you pasted above?

lament star
#

same information
Optional<Dictionary<AnyHashable, Any>>
▿ some : 9 elements
▿ 0 : 2 elements
▿ key : AnyHashable("email")
- value : "email"
- value : abc@abc.com
▿ 1 : 2 elements
▿ key : AnyHashable("livemode")
- value : "livemode"
- value : 0
▿ 2 : 2 elements
▿ key : AnyHashable("default_source")
- value : "default_source"
- value : <null>
▿ 3 : 2 elements
▿ key : AnyHashable("shipping")
- value : "shipping"
- value : <null>
▿ 4 : 2 elements
▿ key : AnyHashable("description")
- value : "description"
- value : <null>
▿ 5 : 2 elements
▿ key : AnyHashable("id")
- value : "id"
- value : cus_KHmljPMPHNr7DN
▿ 6 : 2 elements
▿ key : AnyHashable("default_source_type")
- value : "default_source_type"
- value : <null>
▿ 7 : 2 elements
▿ key : AnyHashable("created")
- value : "created"
- value : 1632485267
▿ 8 : 2 elements
▿ key : AnyHashable("object")
- value : "object"
- value : customer

(lldb)

glass pine
#

Thanks! Looking

#

if you try listPaymentMethodsForCustomer what does it return?

lament star
#

I can see list of payment method

#

but no thing relate to default payment method

#

the list is use for STPPaymentOptionsViewController

#

same data

glass pine
#

Ah okay! Was worth a try.
Let me reach out to a colleague as I don't have the sandbox setup yet to test this out.
Appreciate your patience though 🙂 thank you

lament star
#

{
"object": "list",
"data": [
{
"id": "pm_1Kiy7yFl4EumnGYfaFP5hYA5",
"object": "payment_method",
"billing_details": {
"address": {
"city": null,
"country": null,
"line1": null,
"line2": null,
"postal_code": "95678 ",
"state": null
},
"email": null,
"name": null,
"phone": null
},
"card": {
"brand": "visa",
"checks": {
"address_line1_check": null,
"address_postal_code_check": "pass",
"cvc_check": "pass"
},
"country": "US",
"exp_month": 11,
"exp_year": 2022,
"fingerprint": "IahTe3KX8yvOLDcq",
"funding": "credit",
"generated_from": null,
"last4": "1111",
"networks": {
"available": [
"visa"
],
"preferred": null
},
"three_d_secure_usage": {
"supported": true
},
"wallet": null
},
"created": 1648633667,
"customer": "cus_KHmljPMPHNr7DN",
"livemode": false,
"type": "card"
}

#

no worry, just wanna check I can get from SDK or not

#

if not I will ask backend guy to help me

glass pine
#

I've looked through the SDK docs and not finding a reference to the default payment method anywhere so it is highly likely that its not supported. I've reached out to my colleagues to confirm this

lament star
#

okay. Thanks for that.

#

so we can't get it from SDK

#

let me ask backend guy to help me

#

Thanks for your help

glass pine
#

No worries. We're still waiting on confirmation on what I mentioned above and checking if there are any workarounds available

lament star
#

I have one more question

#

when cilck done

#

sdk doesn't return to this list

#

I saw sdk return paymentOptionsViewControllerDidFinish immediately

#

Is there any way I can go back the list after add a new card?

maiden mauve
#

👋 I'm hopping in since @glass pine had to head out

#

For your original question about getting the invoice_settings.default_payment_method , there isn't a way to get this from STPCustomrContext. The simples option would be to retrieve the Customer from your backend and grab it from there

#

Still looking into the answer for your other question 👍

#

When you click "Done" what screen do you get directed to?

lament star
#

it return to paymentOptionsViewControllerDidFinish

#

in paymentOptionsViewControllerDidFinish, I will close the list

#

is this current design?

maiden mauve
#

I believe this is by design - the thought is that if you're adding a new card, that's the card that you want to use to complete the payment. You'd only need to see the full list of payment methods if you hadn't selected a card to use yet

lament star
#

ok, got it. Thank you