How to extract amount from a receipt email - email-parsing

I noticed many reimbursement apps can parse the amount out from a receipt email. Just curious what are the necessary steps to achieve that? Especially considering there is no pattern in the receipt email itself.
Since we have so many vendors, if we need parse email, do we need find patterns for each of the vendors? Seems not very scalable.

Related

How to store card information inside our app from Paypal?

I have been reading Paypal documents for past one week and so.
There are so many things but i did not get any information regarding storing user's card information.
I need something similar like UBER
Please if you are talking about actual credit card numbers, don't store anything of the sort inside of your app! Just don't do it! For the your sake and everyone else avoid it at all costs!! There is too much risk involved, and you can find yourself in the middle of a security nightmare, not to mention finding yourself sued.
Instead Paypal has other ways to handle what you want to do.
See this here https://developer.paypal.com/docs/integration/direct/store-a-credit-card/
Paypals Reference Transactions API that returns an unique reference ID allowing you to make future transactions without actually storing card info.
Here is more pertinent information as well https://developer.paypal.com/docs/classic/express-checkout/integration-guide/ECReferenceTxns/

Handle payment via bank transfer for Rails

I am building a rails application for place booking. The app should be able to facilitate bank transfer (not VISA/Mastercard direct payment) for payment. Basically we let users know our bank account number. User can then pay via iBanking / go to ATM or Bank. Nah, when we received the payment, we should know whom this payment comes from and from which booking.
How are we supposed to know whom send it and for which booking it is, while there is no additional data in the transfer information other than amount of money. I heard we can apply a unique cents identifier, like when the payment is $8, we make it $8 2 cents to link it to the user who sends it and the booking data.
Is that the best practice in linking the actual payment data and the booking data? If it is, is there any ruby gem capable for generating the unique cents identifier? Or if not, is there any better approach?
Thank you for your assistance.
Bit vague, but a lot of companies that bill people, and allow the user to pay by bank transfer, require the user to put a specific reference number on the transaction, which ties the transaction back to that user's account.
It needs to be made obvious to the user (and it usually is) that if they fail to put in the right reference number then the payment won't be linked with them, and therefore won't show up as a credit on their account.
This doesn't feel like a particularly satisfactory system, as it puts the onus on the user to get it right or risk being charged extra for late payment, or have a hassle sorting it out. But, lots of successful companies seem to operate like this.

RoR: Providing users with unique email addresses

As an RoR newbie, I'm hoping to get insight into what direction I need to take on how to achieve the following (or if its even possible.)
My app will serve as a middle-man between a user and a 3rd party application. Users of the 3rd party application are provided a unique email address that they can send email(text) to, which is then saved into the 3rd party app.
Instead of users sending text to the 3rd party app, I want intercept this text, and strip out the metadata (date, from, subject, etc.), then save each of the pieces of data accordingly into the 3rd party app. With that being said, I envisioned providing users with unique email addresses from my application, that I would match up to their 3rd party address.
Question 1: How would I auto-provision my unique email addresses in
RoR? Question 1.1: Are there providers/APIs that allow for this?
The dirty way is for me to use a hosting provider that allows for unlimited email addresses and manually create a lot of them.
I was looking at using a service such as Mailgun or Cloudmailin to help facilitate the capture/parsing of the incoming email contents.
I don't believe a "catch-all" email address would serve me, as users can share my provided email address to anyone, (e.g. via a mailto link on their website), so most people emailing in may not be users in my application.
All advice/assistance is greatly appreciated. Thanks for your time.
Mailgun is your best bet for something like this - you can use a route to match the pattern of your email addresses, POST it to your RoR app, and then handle all of the processing and parsing internally. This will easily let you scale to however many addresses you want (and you can design your addresses so different patterns go different places).
Also, Mailgun/Rackspace "Fanatical Support" is really nice to have when something goes wrong.
Having used MailGun for the last 18 months or so, the one caveat I will give you is that while it is very reliable and easy to use, you will occasionally experience delivery delays depending on how busy they are. These can be a bit confusing or frustrating, but I've never had them "lose" a piece of mail on me.

Detecting a duplicate customer

I have a bunch of customer data that is normalized into multiple tables. I want to decide the best criteria for make a best guess that a customer might be the same. There needs to be a balance between minimizing the number of duplicates but also minimizing the false positives and therefore interrupting users to ask about potential dupes.
I am looking at some combination of first/last name + phone number || email address.
The first question is, what is a good set of criteria for determining if a customer might be the same as another customer.
The second question is, for this specific application, I only want to detect duplicates for customers that have signed up within the last 2 months or so. Does this change the detection criteria at all?
How would you go about asking a customer if they are the owner of a duplicate accoount?
"Hey Sam Jones, there is another Sam Jones that has an ip in your local area, his email is sam.jones#abc.com and your latest registration had an email of sam.jones#apple.com, are you the same guy/girl?"
If the above is even close to your scenario, then you would be leaking private information. i.e. the other Sam Jone's email address.
Typically you don't allow a customer to signup with the same email address, and secondly you verify that the email address they do sign up with is valid. That way if they signup again with a mistype in the email, they can't validate it.
An important thing is to choose attributes that are unlikely to change. If you use something like telephone number or email address, you risk having duplicates any time someone changes ISPs or mobile phone providers.
If these customers are customers that have made purchases in the past, you can store a hash of their credit card number and a hash of their billing address. Whenever they make another purchase, hash their payment info and compare it to your database. (notice I said to store a
hash, NOT their actual payment info)
if this question is of still interest to you, please check this tool https://sourceforge.net/projects/deduper/
I wrote this tool mainly for the purpose that you have mentioned in this question

How to mark IMAP message as fetched?

I am working on PHP project that should fetch emails from IMAP server, and store them in local database.
Same IMAP server can be used by other email clients, like outbox and so on.
The problem is how to know which messages I already fetched, and which I didn't? I am thinking to use search by datetime, but is it reliable(I would have cronjob, that would access user mail box every minute, and check for emails, but not sure if datetime can cause some issues, for example in case when at almost same time arrive short message and message with big attachment).
I was thinking about system tags, but user can modify them via email client, so I can rely on them, and don't want to modify them and confuse client.
Next I was thinking about custom tags, but not all IMAP servers support them(and our software need to be flexible as much as possible).
Any good idea how I could solve this problem?
Keep track of the currently highest synced UID of the folder you are syncing, and verify that the UIDVALIDITY value of the folder match.
Unique identifiers are assigned in a strictly ascending fashion in the mailbox; as each message is added to the mailbox it is assigned a higher UID than the message(s) which were added previously. Unlike message sequence numbers, unique identifiers are not necessarily contiguous.

Resources