Braintree python transparent redirect with vault option - python

Braintree's transparent redirect works beautifully, I don't have to pass any credit card info through my servers, and I'd like to keep it this way. My question is what is the preferred method to allow returning customers to use vaulted credit card/billing information? Credit card token is a protected field, so it cannot be submitted by the customer via an option field. Instead, I need to specify credit card token before generating the transaction data field. The problem with this is twofold, 1. handling disabled javascript if I were to attempt some AJAX and 2. forcing a returning user through a separate page so they can choose their credit card/billing info is almost as much hassle as re-entering the info itself.

You're right that using credit card tokens with transparent redirect is slightly difficult to deal with using the current Braintree API.
However if you already have the users credit card information stored in the vault, you can use a server to server request since you won't have to capture any sensitive information. A simple HTML select for the credit card token field would work, and your HTML form would post to your own sever.
To make this solution even more comprehensive, you can have the tr_data field included, if the user wants to enter a new card you can submit the form to Braintree as a TR request.
If you have any more questions or want to work through this code together email Braintree support: support#getbraintree.com
I'm a developer at Braintree and would be happy to help you with any more technical questions.

I am a Python developer and just successfully integrated Django with Braintree.
I used almost the same approach as BenMills's description: using S2S API rather than TR for credit card switching while having the ability to create a new credit card on the same page!
But I think there might be a potential way to solve your problem: General several TR forms in one single page with corresponding tr_data for each credit card under that user, thus you don't have to worry about using AJAX to generate tr_data upon user's choices.

Related

How to make a Django application send money to its users using PayPal

I have a Django app for online cockfights. Users can bet if their accounts on the site have balance. They do that by first buying a digital product "Online Sabong Cash-In" through PayPal. The money is sent to the website's PayPal business account. I believe, this kind of transaction is called user-to-website transaction, and I've made this work using django-paypal library. I've followed this tutorial for that simple transaction: https://overiq.com/django-paypal-integration-with-django-paypal/ .
Now, I want to give the website the feature where users can cash-out or like withdraw their money if they want. I want to have the website-to-user transaction. How can I do that, please? I've searched on Google a lot and all I see are articles for user-to-website transaction. I've found one way but I don't know how to do it using django-paypal library:https://developer.paypal.com/docs/checkout/integration-features/pay-another-account/.
PayPal has a Payouts API, which you can request access to. However, only certain use cases will be approved.
(There is a way to facilitate user-to-user transactions by setting a payee object for the checkout, but that's not what you're asking in the question)

How can I programatically do fake payment in payu sandbox?

I have django oscar application which use PayU as a payment provider. I'm writing tests, to test my refund mechanism. So I am using sandbox service for do such things. I have created test, which place request to PayU "create order". Then I got a redirect url, where I can (in browser) do fake payment using my bank account. But in test, I would like to do it programatically. I read whole documentation, but I didn't find such option. On SoF there is no similar questions. PayU support didn't aswer my question(they have 24h).
I'm wondering if there is possibility to post proper form to proper url on payu - but after quick html review I think it may be tricky.
Do you have any ideas how to solve this problem?
After reading documentation I have found sollution.
First of all, I should not use "pay with bank account".
I should use "pay with credit/debit card".
And in payu documentation there is information which data use to complete payment programatically (by sending POST data).
Refer to below link for the documentation of PayU refund:
https://documentation.payubiz.in/refunds/

PayPal Classic APIs determine account type

How do I determine which type of account a person has when using the permissions api? I need to make a different decision if they have a pro account versus a standard business account. Thanks!
This can be be done using the Adaptive Accounts API and more specifically the GetVerifiedStatus call.
A successful response will include the UserInfoType Fields including the accountType which is what you're looking for.
You can find what a successful response looks like here, click on GetVerifiedStatus and fill in the blanks.
I'm not aware of any way to see that via the API. That's typically something you'd leave up to the end-user to know when they're signing up. Ask them if they have Pro or not, and based on that, setup your permissions request accordingly.

Easiest way to implement paypal shopping for e-books

I have an existing django website, and I would like to sell some pdf files through it using paypal. The buyer needs to be able to select 1 or more books, get transferred to the paypal site to enter in payment info. Then after a successful payment, the buyer gets redirected back to my website and the books start downloading automatically.
I have looked at the django-paypal and django-merchent apps, but I don't know how to handle the multiple downloads. As far as I know, using these apps, after a successful purchase, the app sends a success signal, but doesn't tell me which books were ordered.
What is the best way to implement this either with the django-paypal app or using some other method? Again, I'm looking for the easiest/quickest solution.
Thanks,
With respect, the question is slightly naive, in that there is typically a separation between the shopping cart, and the payment processing. A payment returns a binary result - it either worked or it didn't. It is up to your application to recall what was being paid for.
The Paypal API returns the success or failure of an identified payment; plus will happily consume a list of items you give it, so that the user is presented with a breakdown of the total amount. But note that you are telling paypal what is being paid for. It is consuming that data, not providing it.
So the answer depends entirely upon your chosen solution (django-paypal or django-merchant or whatever). Read their documentation. Presumably there is some way to inspect the contents of a recently approved transaction. Cycle through the cart and enable a download of each.
Django-paypal, for example, has no interest of what is in the cart. It just fires a signal when a payment is successful, and passes back the transaction identifier. Your application must recall what the transaction was for.
Often it's not as easy as you'd hope.

Retrieving my own data via FaceBook API

I am building a website for a comedy group which uses Facebook as one of their marketing platforms; one of the requirements for the new site is to display all of their Facebook events on a calendar.
Currently, I am just trying to put together a Python script which can pull some data from my own Facebook account, like a list of all my friends. I presume once I can accomplish this I can move to pulling more complicated data out of my clients account (since they have given me access to their account).
I have looked at many of the posts here, and also went through the Facebook API documentation, including Facebook Connect, but am really beating my head against the wall. Everything I have read seems like overkill, as it involves setting up a good deal of infrastructure to allow my app to set up connections to any arbitrary user's account (who authorizes me). Shouldn't it be much simpler, given I only ever need to access 1 account?
I cannot find a way to retrieve data without having to display the Facebook login window. I have a script which will retrieve all my friends, but it includes a redirect where I have to physically log myself in to Facebook.
Would appreciate any advice or links, I just feel like I must be missing something simple.
Thank you!
Just posting up my notes on the successful advice, should others find this post;
Per Daniel and William's advice, I obtained the right permissions using the Connect options. From William, this link explains how the Facebook connection works
https://developers.facebook.com/docs/authentication/
This section on setting up the actual authentication was most helpful to me.
http://developers.facebook.com/docs/api
Basically, it goes as follows:
Post a link to the following URL. A user will need to physically click on it (even if that user is just you, the site admin).
https://graph.facebook.com/oauth/authorize?client_id=YOUR_CLIENT_ID&redirect_uri=http://www.example.com/HANDLER
This will redirect to a Facebook login, which will return to http://www.example.com/HANDLER after the user authenticates. If you wish to do more than basic reads and news feed updates you will need to include this variable in the above link: scope=offline_access,user_photos. The scope variable just includes a comma separated list of values, which Facebook will explicitly tell the authenticating user about during the login process, and they will have to OK. Most helpful for me was the offline_access flag (user_photos lets you get at their photos too), so I can pull content without someone logging in regularly (so long as I store the access token obtained later)
Have a script located at http://www.example.com/HANDLER that will take a variable from the request (so facebook will redirect to http://www.example.com/HANDLER&code=YOUR_CODE after authentication). Your handler needs to pull out the code variable, and then send the following request:
https://graph.facebook.com/oauth/access_token?
client_id=YOUR_CLIENT_ID&
redirect_uri=http://www.example.com/oauth_redirect&
client_secret=YOUR_SECRET_KEY&
code=YOUR_CODE
This request will return a string of the form access_token=YOUR_ACCESS_TOKEN.
Just parse off the 'access_token=', and you will have a token that you can use to access the facebook graph API, in requests like
http://graph.facebook.com/me/friends?access_token=YOUR_ACCESS_TOKEN
This will return a JSON object containing all of your friends
Hope this saves someone else some not fun time straining through documentation. Thanks for the help!
It is true, that Facebook's API is targeted at developers who are creating apps that will be used by many users.
Thankfully, the new Graph API is much simpler to use than its predecessor, and shouldn't be terribly difficult for you to work with without using or creating a lot of underlying infrastructure.
You will need to implement authorization, but this is not difficult, and as long as you prompt the user for the offline_access permission, it'll only need to be done once.
The documentation on Desktop Authentication would probably be most relevant to you at this point, though you might want to move to the javascript-based authentication once you've got a web app up and running.
Once the authentication is done, all you're doing is making GET requests to various urls and working with the resulting JSON.
Here's the documentation about Events, and you can get a list of friends from the friends connection of a User.
I'm not expert on Facebook/Facebook Connect, however I've seen it used/used applications with it and it seems there's really only the 'official' way to do it. I'm afraid it looks like your best bet would probably be something along the lines of this.
http://wiki.developers.facebook.com/index.php/Connect/Authentication_and_Authorization
Regardless of how you actually 'use' it, you'll still need to authorize the application to connect to the account and this means having a Facebook App as well.
The answer to Facebook application authentication is hard to find but is actually found within the "Analytics" page of the Graph API.
Specify the following: https://graph.facebook.com/oauth/access_token?client_cred&client_id=yourappid&client_secret=yourappsecret , you will then be given an access_token that you may use on all other calls.
The Facebook provided APIs do NOT currently provide this level of functionality.

Categories

Resources