Integrating Paypal Rest SDK into Rails app -- - ruby-on-rails

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.

Related

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

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.

Recurring billing in activemerchant using Moneris Canada

I am working on an e-commerce site which allows user to purchase a product in 3 monthly instalments. Previously I was using Stripe payment gateway for instalments. I was using Stripe webhooks to update my system after instalments gets paid.
Now I have to achieve the same thing using Moneris(Canada) payment gateway. There are official libraries for Java, PHP & .NET but I am using Ruby. I looked into ActiveMerchant. It allows single charge but I couldn't find anything about recurring payment support.
As far as I know there is no any webhook support but I am looking for API's which I can schedule to run to fetch data from Moneris & update my system accordingly.
I would prefer using ActiveMerchant & a bit of custom code to update my system. I am looking for a good starting point which can lead to a better solution given this scenario.
AFAIK Moneris at this time doesn't support access to reporting via API so there's no programmatic way of checking that a recurring payment was successful or not, neither through webooks or through reportings.
This answer suggests another solution...
Looking for some one who has implemented Moneris recurring payments for a website subcription
...which is basically just storing the credit cards on Moneris in exchange for a token, presumably, (what the poster refers to as "the vault") and then setting up your own scheduler to request payments as needed and getting real-time feedback on success or failure of payments.

Braintree Sub-Merchant Display Income

Currently integrating Braintree's marketplace service with my Rails 4 app.
Wondering if there is any way to display current earnings to a sub-merchant (including what is in escrow and what has been deposited into their bank account).
I realize I can handle this just using the rails side of things, but making a call to their api to get this info seems more efficient and definitely better for congruency b/t braintree and my app.
Having trouble finding anything regarding this in the documentation. Thx.
I work for Braintree.
There is currently no way to use the Braintree API to return current earnings for a submerchant.
If you have any additional questions, feel free to reach out to Braintree support.

Sending AND Receiving Payments with Paypal on Rails

I am building a marketplace app for a client and need to be able to both send payments and receive payments. I am currently using ActiveMerchant to handle incoming payments, but I don't see anywhere in the documentation if it is possible to SEND payments. I've read elsewhere that it may in fact be possible to send payments using one of Paypal's many API's but I'm not sure which one I should be looking to use.
If anyone has ever had to SEND payments within a rails system I would appreciate some insight, where to start looking, gems, etc.
Thanks!
I would look into Adaptive Payments it seems to offer something similar to what you are looking for. There is also a gem for it over here which seems to be actively developed.
If this wont work for you for any reason let me know and I can look for something else.
PayPal supports it with MassPay. Not sure about ActiveMerchant.
(To get MassPay enabled on the live PayPal site, contact CS. For Sandbox, log a ticket at https://www.paypal.com/mts/).

Can I get an order confirmation from PayPal Standard without relying on the customer to click "Return to site" from PayPal?

I need to do order processing upon confirmation of payment. Using PayPal Standard, is there a way I can get an order ID (that my site specifies) and a flag for whether the payment is received or not?
It appears that CMS's like Joomla have been able to do what I'm describing, but I haven't been able to find anything in PayPal Documentation that indicates how. Of course, I'm sure the answer is in there, and I will ontinue looking, but if someone could save me some time by pointing me in the correct direction, I would really appriciate it!
Just a little more information, I am developing this site in ASP.NET MVC with C#. I have also been researching PayPal IPN feature, but after talking to other developers in the office, they strongly recommend steering clear of IPN because of it's asynchronous nature.
Any thoughts?
Thanks for any help.
There are many ways to get information from PayPal. Essentially they break down into two categories, "push" and "pull".
"Push" is when PayPal pushes information to you. There are two ways that PayPal pushes information
Information sent in the URL when the customer returns to your site.
The IPN notifications.
"Pull" is when you request information from PayPal. PayPal provides a variety of APIs that you can use to get information about your transactions. So, for example, you could set up a job that runs every X minutes and asks PayPal for information about any orders that you know were sent to PayPal, but for which you didn't receive information on a return URL.
Here are a couple of links to get you started:
https://www.x.com/community/ppx/transaction_information
https://www.x.com/docs/DOC-1372

Resources