Paypal buttons callback - ruby-on-rails

In a ruby on rails app I want the ability for a person to donate to my paypal. However, I want to get a callback to know how much they donated. Is this possible with the default paypal 'buy' or 'donate' button, or will I have to use some sort of paypal api. Hopefully, there is some option besides the api.
Any info at all would be much appreciated.

Take a look at Instant Payment Notification (IPN). When IPN is configured PayPal will POST transaction data to a listener script you have sitting on your server. It'll handle payments, refunds, disputes, or pretty much any transaction that hits your PayPal account so you can automate things based on specific events in real-time.

Related

Ruby on rails. Monthly subscription best practices

Hello I have a monthly subscription on my app using Braintree which is working ok. I would like some advice on best practices for the event where payments aren't made on time for whatever reason.
I currently have a User model with subscribed:boolean subscribeddate:date and subscribedend:date.
When a user completes payment through braintree, the attributes get updated to subscribed:true subscribeddate:Date.today and subscribedend:Sometime_way_in_the_future .
When a user cancels a subscription, the attributes get updated too, subscribed:false and subscribedend:(a braintree attribute, billing_due_date)
This way I can filter things in my app according to dates and subscription status. The only problem I can see with this is if Braintree tries to charge an account one month but fails. Braintree has an attribute for this (.days_past_due), but my app has no way of knowing whether this has occurred or not.
What are the best practices for this? Should I do a scheduled task each day to check if every single user has a value for the .days_past_due attribute on the Braintree server? Would this not be incredibly slow if I have a lot of users?
I may be going about this all wrong and I'd just like a bit of advice on the matter,
Thanks.
Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support#braintreepayments.com.
Your best bet is going to be to implement Braintree's recurring billing webhooks. Webhooks send you a notification via HTTP POST whenever an event occurs that may not have been directly triggered by an API call—such as a customer getting charged via their subscription, a subscription getting canceled, or a subscription going past due. This will allow you to directly respond to subscription events, without having to perform daily checks to see if any changes have occurred.
To use webhooks, you need to choose which events you want to receive webhooks for, designate an endpoint on your server where we'll send the notifications, and set up that endpoint with code to parse the webhook notification into a useable form. For details, see this guide with instructions.

Accept credit card number or paypal information in ios app

I have an application in which i need to add a screen which will accept paypal information or credit card detail and then that will be passed to server for charge processing.
i have doubt whether this is possible or not, if possible then whether apple will approve it or not.
My requirements are
1) customer will buy a ride
2) driver will accept that and driver should get paid.
Customer will add credit card detail and send to server where money will be deducted
driver will ask for payout so driver will be asked paypal detail and sent to server and server will process the transaction pay to driver.
So its clear that we can not use in app purchase as its not buying the digital items.
Please suggest if there is any alternate way to achieve this
Thanks in advance
I'm looking at using Braintree for my app's financial services. Struggling with it, but might be good for you to look at as well.

Charging the user myself, without having them to enter in their card details

I'm working with stripe. I'm confused: is the only way to charge the user (customer) by showing them the Stripe pop up where they enter in their bank card details and click ok? Is there any way to charge them without having them doing that themselves, let's say, by a cron task which is run once a month on my web server where they're registered?
I'm guessing, there should be a way to do so but they have to do that manually at least once, for the second time their card details are saved at Stripe server and I, indeed, can charge them automatically, is that so?
It sounds like you're trying to do subscriptions, which is a whole Stripe topic in and of itself. You may want to check out Pete Keen's blog (and book). A relevant entry is here - https://www.petekeen.net/using-stripe-checkout-for-subscriptions
This gem may also be helpful - https://github.com/andrewculver/koudoku

Rails & Stripe: Is it possible to let user pay an amount monthly until they completed the amount?

For example the user needs to pay $2000,
and I want to let them pay the $2000 in 5 months, and then complete the payment not charge them anymore.
This is the closes I have came close to, please let me know if this is wrong:
1- Create Subscription plans for the amounts of payment.
2- Creating a delayed job to cancel the subscription after the 5 month.
Will this be risky to do so ?
Thanks,
Yes, that's exactly how you'd want to handle it. To be more detailed...
First, you'll need to have a web hooks endpoint:
https://stripe.com/docs/webhooks
Next, you'll want to subscribe the customer to a plan like normal. We'll notify your site, via the web hooks, of when payments are made on a recurring subscription. Specifically, you'll want to watch for invoice.payment_succeeded events:
https://stripe.com/docs/api#event_types
Once a specific customer has hit the right number of payments (which you'll track on your end), you'd then issue a cancel subscription request:
https://stripe.com/docs/api#cancel_subscription
Hope that helps!
Larry
PS I work on Support at Stripe.

Stripe notification mechanism

I have a typical scenario like i have a video model which are paid.
I have stripe integrated for credit card processing. But the problem is how can i check if the user is subscribed and the users payment is not out of date before the user the watching video?
Any ideas how to accomplish this?
Any help would be appreciated.
thanks.
First you need a way to tell if the user is valid. You can do that by keeping track of amount owed, or by using a datetime field such as last_paid_at which you update when the user pays their bill.
In a before_filter for videos, check if the user is invalid. So if the balance > 0 or if it's been longer than a month since the last payment.
Check out Stripe Webhooks to get notified when a payment goes through. Basically webhooks are endpoints where stripe can send you information.

Resources