I'm developing an application using react native and Stripe api in order to handle all the sensitive information about the users and their credit cards.
I'm trying to manage a digital wallet inside the application: one user can add/delete or see a list of their own cards (directly inside the mobile app). I am very confused about this point. For now I'm using my server side as an intermediate between my application and Stripe.
For example to add a credit card I give the possibility to insert card information using a form, then i create the token, and finally I send that token to my server-side (POST /users/cards body:{tokenId}
) endpoint which, usingstripe.createSource({ customerId, tokenId })
, I can save a card into a customer object (In my DB I store only the customer ID).
For delete a card I use this endpoint of my server:DELETE users/user_id/cards/card_id
and this endpoint usestripe.deleteCard({ customerId, cardId })
to delete the specified card from customer.
For get the list of cards:GET users/cards/
and the endpoint usestripe.listCards(customerId)
.
My questions are: Can I do this? Is there a better solution? Is this PCI compliance? Can i use my server as an intermediate between my clients and Stripe?The second point is simple: in a checkout phase (in the client side) how can I let the user to choose which credit cards use for the payment and create a token with that? Can I send the cardId to my server in a POST request? Is it secure?