Stripe iOS integration server side code - swift

I have been playing around with the Stripe SDK and API and I am a little confused. I have a very simple use case. I want to use the built in STPAddCardViewController and STPAddCardViewControllerDelegate to save card information that a user puts in. We also need to charge the card based on the credit card the user created. We have a unique identifier for each user when they create an account and any user that has access to our app does need to create an account. What is the best way to do this?
We also aren’t able to get the card information (STPCardParams) that a user selects from the STPAddCardViewControllerDelegate. How would we do that?
The part that I am having the most trouble with is the server side piece. I know Stripe gives example code for this but I haven’t been able to get it to work for us. We are using a backend as a service for our app so don’t use code to create our server. Is there any simple code that we can deploy that allows us to pass the card information, our Stripe API key, a charge amount, and a currency to a server (on heroku for example), and just have that server charge the card for us? I don’t think this is that hard to do and it seems like it can be pretty cookie cutter for everyone who is using stripe. If this is the case, does anybody have the code for this? Is it possible to use stripe without server side code?

Related

Finalize Stripe payment on server with 3D secure/sca (card authentication)

I'm trying to implement Stripe payment in my Flutter mobile app, but I need to finalize the payment on server side.
Does anyone know how I can do this with also 3D secure/sca? I am able to show 3D secure/sca page only finalising payments on client side. Checking online documentation, I have found this: https://stripe.com/docs/payments/accept-a-payment-synchronously, but stripe packages (I have tried with stripe sdk and stripe_flutter) don't provide stripe.handlecar action.
To answer your headline question: You cannot. If you could, the whole security feature would be pointless. You need client side authentication.
PSD2/3D Secure/2-factor-authentication or any other mechanism relies on the bank to tell the client what to do to authenticate. They might reroute you to a different site, owned by the bank, they might ask you for a PIN or one-time-code, or anything else they deem suitable. They will interact with the user, that is the only point of all this.
The method that will handle it is called confirmPaymentIntent (might vary a little depending on which package you use). It will need to be called client side with a payment intent for the payment. It will then show a testing screen for the test card numbers stripe provides.

Finishing Whatsapp Business API Setup

I came from a similar state in this question.
My objective is to reply to interested customers via whatsapp messages. I'll use a very special setup, so I'll be using the API.
Reasons:
With not to pay anyone other than container hosts
Solution with custom API
Customer doesn't like any extra costs
Just like user noboundaries, I see the numbers, but I cant get the certificate
User Navjot Singh has explained I need to create a "business api account"
I tried just that, put out all my contacts and stuff, in this site.
They did respond yes, but only with pointless instructions, since I wish not to contract any messaging providers. I had taken a look at it, but they charge a very expensive price beyond the $0.005 whatsapp will charge. Also, the solution I'm creating requires messages to be sent programatically, and the partners don't seem to provide the correct solution.
So, I wish to skip into using the api. I followed the appropriate guides:
Getting started
Phone Number
I already got some things done:
two phone numbers (one of them for testing) with whatsapp business;
company has been verified, with domain
have business management account
local environment with docker
I can access the local environment and I have set an user account and the admin acount. I can log into those via the API, since postman can ignore certificates, but in order to proceed I really feel like I need that certificate.
So to sim up I guess I need help creating the whatsapp business account for my customer. Any advice?
Also i'd appreciate any other helpful insight or feedback. I really feel lost and I don't see a place where I can talk to people trying to do the same thing, or doing this is much of a madness after all?
thanks for getting to read until here, and I apologize for my non natural, almost broken English.
Hi I wanted to start big in stackOverflow but I fell flat.
About the subject at hand, westerday I dwelt deep into the rabbit hole.
For most companies, you actually are forced to work with a provider, such as twllio or messagebird. They act as intermediary between the facebook business and the whatsapp business api.
Some of they offer messaging separated from whatsapp api setup I still need to take a look into it, but for those who are trying to set up whatsapp business api on their one, it seems as of november 2020 it's not possible.
please check out:
respond.io's guide
blog post from take.net PT-BR (google translate didn't like me trying to translate this to English)

Stripe integration with iOS: Saving and referencing saved cards

I'm trying to make an app that sells a service, for which users pay based on the amount of time they've used it for, so I don't have a physical shipping address involved.
I want to be able to allow my users to save and then reference saved cards in future transactions. I know the way Stripe tracks a specific customer is through a customer_id, but I'm not sure how to attach a card to a specific customer_id and then reference it in future.
Also, I'm a little confused on the use of ephemeral_keys. Some Stripe tutorials talk about needing these on the server side, and some don't mention them at all, and that leaves me very confused.
This one talks about ephemeral_keys while creating a paymentIntent: https://stripe.com/docs/mobile/ios/basic#
And this one doesn't: https://stripe.com/docs/payments/integration-builder
Any help would be greatly appreciated! Please let me know if you need any more information from me.
PS: If you could also point me to some of the relevant View Controllers Stripe uses to save new cards and display saved cards, I'd be more than grateful!
The flow on https://stripe.com/docs/mobile/ios/basic includes the Customer for your payment context, which will cause the created PaymentMethod to be attached to that Customer. You can verify this after the initial payment by retrieving the PaymentMethod on your backend with your secret key and checking its customer field [0].
If you have a PaymentMethod and want to attach it to a Customer, you'd use the API on the backend [1].
You can retrieve a list of the Customer's existing PaymentMethods via the API [2] on the backed as well (again, with your secret key). Then you can pass a list of their id's and some identifying feature (last 4 digits, as an example) to your app in order to display and let the customer select the one they want to use. Then you take that PaymentMethod's 'id' and use it to create the new payment.
Ephemeral keys are usually only used with the iOS (or Android) SDK's, so when you're using the backend of your integration (i.e. the part that is running on a server somewhere and not distributed with your app) you generally don't need to worry about them.
[0] https://stripe.com/docs/api/payment_methods/retrieve
[1] https://stripe.com/docs/api/payment_methods/attach
[2] https://stripe.com/docs/api/payment_methods/list

Implementing stripe connect directly from within an iOS app

There is a post re: implementing stripe connect from a couple of years ago.
How to use Stripe Connect in an iOS app
I have built an app where only User A needs to register and login while User B can choose from a list of User As and i am trying to set up the app so User B can pay directly to a User A.
While the basic version of stripe is relatively easy to implement Stripe connect is giving me a bit of grief.
Specifically there is an example called Rocket Rider on github (which is meant to.mimic uber, etc.) made by stripe but in this example the "Pilot" had to register via a website.
I'd like it all to happen from within my app. I've read the docs a few.times now and still a touch uncertain.
Is the post from a few years ago still relevant? Is the only way to have the registration done via the app to use a webview?
In the stripe docs there is a section https://stripe.com/docs/mobile/ios/standard
Which essentially goes through the implementation for iOS. But I wasn't sure if these docs only refer to payment that as the developer I would receive if say I was selling a product to users.
Again, in my app there is a list of User As and each User A would register ideally within the app and then User B can choose who to pay. I wasn't sure if the "Standard" doc above also refers to this scenario.
Thanks
Been looking into the same thing today (March 2019) and have a few answers for you
The current state of the Stripe Cocoa Pod does not have anything that has to do with connect accounts. That will not help you in any way with creating connect accounts.
All is not lost. If you must stay in-app, you may create what is called a Custom Account--This means that you are responsible for the UI, User Validation, and Communication. Your users will not be able to use the Lovely Express Dashboard either....but you can stay in app.
As you alluded to, you are still able to use Safari to open Stripe Express and have your app handle the deep linking once the experience is complete. While this is an annoyance, there are some serious perks to having the Express experience. You don't have to deal anything bank account related because the Express Dashboard will handle it for you and Stripe will handle all verification communication. (Outside app).
TLDR: You can do it completely in app using Custom Accounts......but you'll be on your own!

Automate distribution of redemption codes for Custom B2B app

I have built a Custom B2B app for one of our clients. My question is how to automate the distribution of the redemption codes.
I have already looked at some of the MDM providers. Their solutions are too expensive and all we really need is a way to distribute the app from a webserver, not manage a bunch of mobile devices.
As you probably already know, when a client buys a Custom B2B app through the Apple VPP program, they get a spreadsheet with valid redemption codes for the number of licenses they have built. This spreadsheet has 2 columns: 1) redemption code 2) URL to redeem the code
I want to provide my client with a URL where they can send their users to download the app. They just don't have the expertise/infrastructure to distribute the app themselves. And emailing clients is not going to work.
I'm not a web guy, but it seems to me that we could write a webpage that would look at the spreadsheet for the next available activation code and then redirect the user to the associated URL. I'm not concerned with the number of licenses they distribute since I have another way of auditing the real number of users (Flurry). So I want this to be as painless as possible.
In fact, I have multiple clients and want to provide them each with their own URL for their clients. It seems like this shouldn't be too difficult to code.
The problem is, I'm not the guy to write that code. Any ideas on how best to do this?
Assuming that you don't want to show the user a website you should be able to do this with an online service like parse.com and the features it offers.
From a user POV you would supply them with a link which directed them to parse.com with a path and parameters indicating the action to be taken (get app) and what account is associated. This would redirect the users browser to the appropriate destination.
The main issue (and this applies to any solution) is knowing if the user actually followed through and used the code. i.e. should it be removed from the DB so it isn't offered to another user in future. Then you would update the DB each time you get a new spreadsheet.
Anyway, this could be achieved with a little javascript in parse.com, specifically, by using cloud code which can interrogate and modify the DB and then redirect the user.
Obviously if you need user authentication of some kind or other restrictions then you would need to start adding some web interface on top of this in order to collect the details.