How to process Stripe payment authentication in iOS (Swift)? - ios

I don't know if there's a lot of people people in here who are familiar with Stripe, but I hope someone can help me out. I'm setting up iDEAL payment in my app using Sources, and I'm using the guide on the Stripe website to help me out. Everything was explained very clear about how to set up the source, but the problem I'm running into is that the guide is very unclear about how I should continue after the source has been created and the user has authenticated the payment. It only describes how to continue when you're a web developer, but it's very unclear how to continue when you're an iOS developer. Basically what I want to do, is to get notified on whether the source object became chargeable (successful authentication) or failed. It only says you can get notified about the authentication status through client-side polling, but it's poorly described how to set up client-side polling in iOS. Can someone give me some directions on how I should continue after the authentication has been completed and the user returns back to the app? How can I get access to the new status of the source object after I return to the app?

It's not possible to charge a given source or create a customer in your iOS application as those calls require your Secret API key. You should never have the Secret API key in your iOS application otherwise an attacker could get his hands on it and then create charges, refunds or transfers on your behalf.
Once the source is created client-side, you need to send its id src_XXXX to your server. There, you will be able to call the Create Charge API to charge your source with your Secret API key.
Since you plan to use iDeal, the source is not chargeable immediately. Instead, you need to either poll the source client-side until it's ready to be charged or you need to listen for the source.chargeable webhook event indicating that the source is ready to be charged.
Once it is ready, you will be able to charge the source on your server.

Related

I have integrated twilio otp api and it suddenly stop working

I have integrated twilio and it was working fine but suddenly
end users stop receiving top message at their mobile. Is there any capacity problem if yes then how to fix this
Without providing the code, I can give the following suggestions to check upon.
1. Check if the Twilio Account has enough balance to send messages
you can check this in the dashboard.
2. Check if the Message template used is verified or not.
If the template is rejected for some reason, you won't be able to use it.
3. Use the API Gateway Dashboard to determine the cause for no sending messages.
If you can see the messaged being in outbounds mode, but not being sent, you can check the reason for it.
4. Check if the Twilio API library used has changed the API structure
Refer to Twilio Docs and confirm if the APIs have received some changes in them, deprecating any changes. (This is very rare, as most API Providers keep the Legacy API code format active for some time for users to migrate from it.)
5. Confirm If any New Government Rules are changed.
Ex. In India, there are some new laws put up for sending SMSes to users. You would need to follow the rules to register the template again to a Mobile Carrier's site, and then use it. These details will be provided on Twilio Dashboard.

how to make an quickbooks Api call and bypass login

I know I'm probably going to get a "no, you can't do that" but it doesn't seem reasonable to me.
My client uses Quickbooks Online and wants to be able to have his customers sign in to his web site and see how much they owe, and then pay their invoices with a credit card.
Obviously, the customers themselves can't be signing into Quickbooks Online. We want the web server to be able to directly access the data via the api.
I've found the api but I'm not sure if it's possible to have the webserver connecting to it and getting the data it needs.
I know this can be done with other systems. I've done it with GMail and Salesforce using OAuth2.
The biggest piece I want to load from quickbooks as well might be something unavailable as I couldn't find it in the API anywhere. When my client opens Quickbooks Online, he can send an email to any customer that will include a link to pay online by credit card. We'd like to be able to find that link and redirect the user to it. But I'm not sure if it's available via the api.
I could go with webhooks but that would require storing all that data on our webserver, and syncing it for existing data. Not to mention what happens if an update happens to fail.
You're misunderstanding how OAuth works a bit, which is what is causing the confusion here.
The person who owns the QuickBooks company logs in, not the end-user. They log in ONCE, and that gets you OAuth tokens that you can use to make server-to-server calls forever going forward.
Soooo...
I know I'm probably going to get a "no, you can't do that" but it doesn't seem reasonable to me.
You can do what you're trying to do, you're just going about it the wrong way.
Obviously, the customers themselves can't be signing into Quickbooks Online.
Correct.
We want the web server to be able to directly access the data via the api.
That's fine, and totally do-able.
I've found the api but I'm not sure if it's possible to have the webserver connecting to it and getting the data it needs.
It is do-able.
The key understanding here is that you're going to have an OAuth connection process that the person who owns QuickBooks is going to go through just once, to get you OAuth tokens.
You're then going to store those OAuth tokens server-side (e.g. in your database).
You can then use those stored OAuth tokens to make future server-to-server API calls whenever you want.
When my client opens Quickbooks Online, he can send an email to any customer that will include a link to pay online by credit card. We'd like to be able to find that link and redirect the user to it. But I'm not sure if it's available via the api.
I don't think this information is available via the API right now.
There is an API endpoint to send an email invoice, if that's helpful:
https://developer.intuit.com/docs/api/accounting/invoice

Stripe Create User Function in Swift

I was just wondering if there was a simple function to create a customer in the Stripe API from my app in Swift? Instead of having to create a manual HTTP post request to my server, "createCustomer.php", and then retrieve the results (This is what I do right now).
I tried to search this up on Google, but I can't seem to find anything. I simply want the user to save their card details for later user, that's why I am in need of creating a customer.
Thanks in advance!
Except for payment information tokenization (which is done via Stripe's iOS or Android SDKs in mobile apps, and Checkout or Stripe.js in web apps), all API requests must be sent from a backend server.
The reason is that aside from token creation, all other API requests must be sent using your secret API key. You cannot embed or share the secret API key with your mobile app in any way, as it would then be possible for an attacker to retrieve it and use it to issue API requests on your behalf.
This is why there is no Swift function to create a customer -- the customer creation must be done from your backend, using the server-side language of your choice.

how can i communicate ios side with server side (heroku)

I am implementing Stripe Payments in my iOS app and i obviously cant store credit card information over the iOS app so i have to create tokens and send that to the server to be charged etc.
My question is how can i communicate iOS => server and vice versa
My web app is in Rails by the way.
I read in some places that i might need to create a API on my server? then call it from my iOS side?
if anyone has an idea on how to do such a thing please let me know, i would appreciate it a lot.
Yes, you must create (or update) your Rails application to expose an HTTP API, which usually communicates using JSON. Your API will need to respond to POST/GET/whatever requests the iOS app make and behave correctly based on what you expect to do (do something with some tokens from my understanding).
Please notice though that handling payments and not having already the knowledge on how to do such a thing might be dangerous for the end user.
To give you a general overview of the process:
Create Rails routes, controllers, models required to manage the logic of perform a payment from a token, this is entirely your job unless the Rails app you are working with, already support this
Update your iOS app to send, probably with a POST request, the token you talked about, you'll probably need to define some sort of authentication protocol, look into JWT or something similar, you won't have cookies at your disposal in the iOS app
It's a long but interesting task

Integrating Paypal Rest SDK into Rails app --

I'm a fairly new developer and this is my first time integrating a rest API with an app. The goal is to implement a subscription process where a user can select from a choice of 4 subscriptions and then submit a payment through Paypal or stripe, but I'm struggling to understand how PayPal's rest API works. I've read their documentation and looked at some examples which gave me an idea of where to start. However, I had a few questions that I couldn't seem to find the answer to online:
Are subscription plans that are created through the rest API permanently associated with the account they have been created on?
If they are permanent, how can I avoid hardcoding the Plan ID? This seems like bad practice even though it is done in some of the examples.
When should I be generating new tokens? Every time they expire? Every time a user wants to subscribe to a plan?
How do I automatically execute agreements after they have been created? (I assume executing the agreement is what makes it active and begins the collection of payment).
Thanks, it would be nice to get some clarification on some of this stuff.

Resources