i'm working on a paypal donate feature in a rails 4 app. I'm not very familiar with paypal api, so any advices about the right way to work with it are welcome.
What i want to do:
the donate page is a form to create a new Donateur object who will hold all informations about the donator like name, email, status of the donation (paid or not) etc
When a user fill and submit this form to make a donation, i want to redirect him to the paypal paiement page (after the form submission has succeed).
Then, when paypal donation is done, IPN send to my app the paiement datas so i can update the previous Donateur entry created and fill informations about the success or failure of the donation.
What i got
I have the classic form for creating a new Donateur object, nothing special here.
In my controller, i wonder how i can redirect user to the paiement page of my paypal account
#donateurs_controller.rb
def create
#donateur = Donateur.new(post_params)
#donateur.save ? redirect_to(PAYPAL_DONATE_PAGE) : render('index')
end
The callback (after paiement) doesn't matter for the moment
My question
Donations with paypal are they classic transactions (so i could use the api like if i was selling some products) or should i specifiy something about it s a donation while make a payement call?
Thanks
I've fix my problems. I used this gem https://github.com/paypal/buttonmanager-sdk-ruby to generate a donate button on form submit. I can get programmaticaly the api request url sent when clicking this button, so i don't have to display it on the screen.
Related
I have create the basics of subscription Paypal using the RailsCast and now I'm doing what is missing there.
Now I'm developing the process to do the Devise user registration together/just after the payment is done. For now, I'm trying something like this and this.
As the RailsCast got the e-mail from PayPal using this line:
#subscription.email = PayPal::Recurring.new(token: params[:token]).checkout_details.email
So, I thought that I could get first name, middle name and last name from PayPal as well. From PayPal documentation it seems that it is possible but I couldn't get it through paypal-recurring gem.
I have tried to see if I can learn what I have to do from paypal-recurring GitHub docs and code but I couln't find and tried some possibilities without success.
Is it possible? Maybe in another way not using paypal-recurring gem?
If you have another recomendation/reference to do this registration process, please, let me know.
Update
As #Andrew suggested PayPal IPN, I thought it would be better update my question as I want to have the first_name from PayPal as a default value to ease the process to the user register in my database but he or she may want to change to another name.
The process that I want is something like:
The user chooses his plan and to pay with PayPal
User is sent to PayPal
User fills payment info on PayPal site
User is sent again to my site
My site gets e-mail and name of the user from PayPal and asks the user to confirm or change the data, and provide his password to create the login to my site
My site uses the user data provided to register the user and sends the request to PayPal to request the payment and create the recurring profile
Ok, based on your current outline of steps you can handle that exact flow using Express Checkout.
SetExpressCheckout will generate a token for you, and you then redirect the user to PayPal. They review and approve the payment and are then redirected back to your site. There you can call GetExpressCheckoutDetails to obtain the email, name, address, etc. and display a final review page for the customer to confirm everything or make changes if necessary. Finally, you'd call DoExpressCheckoutPayment to finalize the payment using the customers confirmed details.
I would look at PayPal IPN (Instant Payment Notification). It'll POST transaction details to a listener script you have sitting on your server so you can process the data accordingly in real-time.
I've inherited an app which uses the legacy shopify API and I have a hard deadline of August 21st, so I want to avoid updating the API to solve the problem.
We are selling e-documents, and the current purchase process is as follows:
User searches and places a product in the cart
The User checks out
and goes through the purchase process on the Shopify site
This all seems to work fine. What we would like is to redirect the user back to our app with information about the successful purchase (or failure) of the products. As it stands, we don't know what products the user has purchased and we are therefore unable to provide them links to download the documents.
Is there some parameter we can pass to shopify to create that redirect, or do we need to ping the API about past purchases, or is there some other step we are missing?
This one is quite easy... Shopify provides you with a textarea element in the admin (checkout and payments) where you can paste code. In this code, you have access to the entire order contents. You can get at this with Liquid.
All you have to do, is render a link to your App and pass the order details to the App via that link. Now your customers will see the Thank You for your purchase, and a button/link to click to complete things as you wish.
Okay, it turns out that what I'm looking for are shopify Webhooks: http://wiki.shopify.com/WebHook
It appears that the app is already set up to send order_create and order_payed and all we have to do is capture the data sent to us.
The second day I am playing with integrating PayPal to my website. I am trying to obtain the following behavior:
the user click on the BUY link => is redirected to PAYPAL page (that's ok)
the user finished payment, on the PayPal website is displayed "Thank you" page
after 10 seconds is user redirected to "Thank you" page on my website
to user's PayPal email is sent information about the product he bought
This is what I try to implement, but unfortunatelly I still can't find the right way to do it... My app is in Ruby on Rails, currently I am working with Sandbox and use PayPal Payments Standard.
Could you please give me some advise/tip/link, how to implement this behavior?
You need PayPal Standard's Buy Now Button.
You can either use form created by PayPal or create own form to post to PayPal.
I'm not familiar with ruby-on-rails. However, you view the sample here. You also need to include return url and cancel url if you want to bring user back to your site.
Paypal has a return parameter which should work if you're using a form to send the user to their site for checkout:
The URL to which PayPal redirects buyers’ browser after they complete
their payments. For example, specify a URL on your site that displays
a “Thank you for your payment” page. Default – PayPal redirects the
browser to a PayPal webpage.
I am currently working a system whereby my users can pay for items that they have added to an order.
The payment will be using Worldpay.
I have a Worldpay account, but I am a little confused as to what steps I need to do next.
I am using symfony and I have an order, with products associated to it. I have then created a 'Pay Now' link, which links to a executePayment action.
What I'd really like, is for this to then take me to the hosted payment pages on Worldpay, pay for the order and then takes me back to my site to an order success page.
Has anyone implemented WorldPay using symfony before?
Thanks
EDIT:
So It seems, that I can have a form on the page where the Pay Now button is, but change it to a <input type="submit" /> and then post the details to https://secure-test.wp3.rbsworldpay.com/wcc/purchase
Is there some kind of callback functioanlity, to redirect me to a confirmation/failure page if the transaction was completed?
Thanks
WorldPay works like this...
1) You have a form on your website that collects your customer details. You then POST this data to https://secure-test.wp3.rbsworldpay.com/wcc/purchase
2) The customer will add their payment details in to WorldPay
3) Next, (depending on if the payment was successful or not) the user will be either directed to your resultY.html or resultC.html page that you can upload to your file management section within the WorldPay admin.
Alternatively you can supply a URL to a callback file on your server that is pinged when the customer clicks pay. This allows you to get information about the transaction and add it to your database.
With the callback page on your server, you can output a confirmation of payment, but you then have to include a link to physically get the user to come back to your site. I think automatically redirecting from this page is against Worldpay's T&Cs.
Hope this helps.
Philip
I user RBSWorldPay with Symfony - its very simple to setup - yes there is a callback function that you setup within the Settings of your RBSWorldPay account - you can also test by adding a test field - again check the RBS Documentation for testing.
I'm in the middle of developing an e-commerce site that is using Paypal as it's payment gateway. All I want to do is run some code before the user heads off to Paypal to pay for their order, but I have no idea how to do it.
The user should click a submit button, changes are made (in this case, the status of the order), and then the user is redirected to the payment gateway. Eg:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult GoToPaypal(FormCollection collection)
{
//change order status
//send user to paypal where they pay for their order
}
So my question is how do you do application stuff and then redirect to paypal's payment gateway? Example HTML and C# would be lovely :)
Note: This guy seems to have the same issue - (and probably explains it better).
You could POST to paypal from your action method but it will be difficult to show the user the response. In addition, you want to take the users to the paypal website without using a GET request (GET exposes the parameters in the url string and Paypal probably does not accept a GET request).
From what I understand, you have a form with some fields that posts to PayPal. Before the form is posted to Paypal, you want to capture the fields on the form, do some processing with it and then let them post to paypal.
One way of doing this is with jQuery. You wireup the submit event
http://api.jquery.com/submit/
When submit is clicked, in the event handler for the submit you created above, make an ajax call with the form fields you need to your MVC action.
http://api.jquery.com/jQuery.post/
Do the processing and send back a response.
When the page receives the ajax response, change form fields if required that are received from the ajax response.
Finally Use jQuery to submit the form.
==
You mean redirect to paypal, after you're done doing what you want to do?
// run some code
//
// go to paypal
return RedirectResult("http://paypal.com/blah");