I'm essentially following this guide:
https://rails.devcamp.com/ruby-gem-walkthroughs/payment/how-to-use-a-custom-form-for-stripe
However, I'm confused about two things:
What if I want to add additional data to be filled out by the user, such as billing address, zip code, full name, and use that for stripe to verify the credit card with? What do I need to add and where?
How do I tell that the payment has gone through? I'm going to be selling an online product -- I need some way to verify that the user has paid successfully in order to unlock access to the product.
Thanks!
1) You can specify with the Stripe.js options whether you would like to add billing and/or shipping address to your checkout form.
2) You can check your payment results by:
The return value of your API call to create a charge. Look for the status parameter
Log in to your dashboard and check it there
Use Stripe's webhooks, and listen for the charge.succeeded event type.
Related
So I have everything implemented with braintree and rails. However, I wanted to switch it up a little. I have a user role which is a business account. When someone wants to sign up as a business account I want them to pay before the devise registration is actually saved? I've seen it on a lot of website but cant really find any resources online how to do it. Someone please give an example of how it can work.
As a general Idea what you can do is one registration of user on business account take the card information also for billing.
On submit of that information it will go to a controller action with all the params of registration and billing.
Try to charge the card through brain tree and if they payment is successfull you can register the user because you have access to the params and you can save this transaction for the user also.
Its just a general idea that how can you implement it.
As one of the comments say, you question is vague.
What I would do is to have a column in that table that tells whether the record has payed or not.
If it hasn't payed then restrict its ability to log in. This way you can still record its information and it may be usefull for some cases, say to remind that user through an email that he/she should complete its payment.
I'm making a task website similar to Taskrabbit where users can post tasks they want completed and others can make an offer for how much they'd charge to complete the task.
I'd like to use Braintree Marketplace with Devise to create individual "merchant accounts" associated with each user, but I'm having trouble figuring out how to make each user a merchant once the user has signed up.
Braintree has a "merchant create" action:
result = Braintree::MerchantAccount.create(merchant_account_params)
but I'm not sure what to do with it.
I have a Transactions controller for Braintree transactions, but that doesn't seem like the place to set up merchants. Would I need another controller? Or can I make a method in my User model to verify their account so they can receive money?
Any help would be greatly appreciated!
Thanks,
Zach
Full disclosure: I work at Braintree. If you have any further questions, feel free to contact our support team.
As outlined in our Marketplace guide there are 3 steps to set up a sub merchant and have them start transacting. They are:
Creating the Sub-merchant
Confirming the Sub-merchant
Transacting with the Sub-merchant
Once the sub-merchant has been created/signed up, then the submerchant must be confirmed on Braintree's end. This process happens asynchronously and we notify you of the status via a webhook. To receive this webhook you need to set up an endpoint that we call into.
After the submerchant has been confirmed, then you can start transacting with the merchant by indicating the submerchant to associate with the transaction when the transaction is performed.
I am trying to set up a simple payment using PayPal and MVC, right now I have code which accepts an ID from the database on items you can purchase.
I have managed to find code which takes me to this screen:
I have some code which after you click "Continue" PayPal will return to and call, but the only thing I have in that bit of code is this:
public ActionResult PayPalExpressCheckoutAuthorisedSuccess(string token, string PayerID)
{
return RedirectToAction("GivePurchasedItemsToUse");
}
I can see they have given me the token and payer id, but I am unsure where to go from here, in the PayPalExpressCheckourAuthorisedSuccess method, do I send something back to PayPal? Nothing yet has been displayed on any of the two PayPal accounts I am using.
The tutorial I followed was: http://rituranjangupta.blogspot.nl/2012/10/paypal-with-aspnet-mvc.html
Assuming I understood the state of where you are, which is after a user has "approved*" a Paypal Payment (where Paypal redirects back to your RETURNURL), you will need to "complete" the transaction.
GetExpressCheckoutDetails - (optional) if you want to obtain details e.g. Paypal shipping address
DoExpressCheckoutPayment - this is the actual step that completes the transaction
Extensive Reference: Paypal Developer -> Express Checkout
*approved
TIP: Don't misinterpret "approved" as "payment" - all it really means is that the user has approved a Paypal payment for you to use (e.g. user has agreed to pay some amount, chosen what funding source, shipping, etc.) - you still need to "finalize" things
Hth..
When I submit a braintree transaction, and it is unsuccessful, it returns result.params that I can use. However, due to PCI compliance reasons, it cannot return CC or CVV information.
Since it's an unsuccessful txn, the page renders the current page. I would like to auto populate the payment info, whether it's a CC or paypal transaction, so the user does not need to reenter the payment. I think it's bad user experience.
If repopulating the payment info is not possible, could I just somehow reuse the generated payment_method_nonce and send it to braintree. Looking through the docs, I can't seem to find anything that I can use to solve this.
https://developers.braintreepayments.com/javascript+ruby/reference/general/result-handling/result-objects#params
I work at Braintree. If you're looking for more help with your integration, you can always get in touch with our support team.
Instead of creating a transaction with the payment method nonce, create a payment method with the nonce. This will give you a reusable token you can then use to create a transaction.
From the "Getting Started" guide:
Create a transaction
Obtained from the Braintree client SDK, a payment method nonce can be used in any place credit card information or a payment method token is used in the Braintree server-side client libraries.
So since you can create a payment method token from credit card params, you can also create it from a payment method nonce.
Simply post it to your own controller/action that is set up to make the request. From there, you can check the success of the transaction and respond accordingly. You also have full access to the params, to do with as you wish. You probably want to keep them out of your logs.
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.