#coltonidle-Customer
1 messages ยท Page 1 of 1 (latest)
Okay so this is in kotlin for my android app
This method returns 0 as sources size
CustomerSession.getInstance()
.retrieveCurrentCustomer(object : CustomerSession.CustomerRetrievalListener {
override fun onCustomerRetrieved(customer: Customer) {
Log.e("LOG", "got it: " + customer.email) //Proper email shows
Log.e("LOG", "got it: " + customer.sources.size) //but size is 0
}
override fun onError(
errorCode: Int,
errorMessage: String,
stripeError: StripeError?
) {
Log.e("LOG", "failed")
}
})
This method gives me the right info
CustomerSession.getInstance().getPaymentMethods(PaymentMethod.Type.Card, object : CustomerSession.PaymentMethodsRetrievalListener {
override fun onError(
errorCode: Int,
errorMessage: String,
stripeError: StripeError?
) {
Log.e("LOG", "ERROR" + errorMessage)
}
override fun onPaymentMethodsRetrieved(paymentMethods: List<PaymentMethod>) {
Log.e("LOG", "got it: " + paymentMethods.size) // This returns 2!!!
}
})
So I'm basically curious why customer.sources.size == 0 in one case, but in another call I get 2.
So the first one is the Source attached to the Customer. The second one is the PaymentMethod attached to the Customer
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
They are .. simple different things. Payment Method is a newer API and we recommend to use nowadays. Source is an older API an exists for legacy users
Interesting. Thank you!
@hoary plank so one last question. So if I wanted to add a new payment method, and delete a payment method... which apis would I use?
To delete would I use detachPaymentMethod?
How do I add a payment method/create a new credit card for my user?
You should use the new PaymentMethod API. Yes to delete you use Detach API. To add a new, simple create a new PaymentMethod and Attach to the Customer
Is there any helper to create PaymentMethod?
Or maybe. A better way to phrase the question is...
Creating a PaymentMethod object seems easy but it looks like the first argument is a id. How do I know what kind of id to set for a new PaymentMethod that I'm creating?
I'm basically building this screen myself, and was hoping you could point me in the right direction of creating this PaymentMethod and then I will just attach this to the customer (like you said).
Oh I see. This is the Payment Element? JS?
I am confused. Are you using Android in client? The image above is JS
The image above was just an example of what my designer gave me to create.