Code Monkey home page Code Monkey logo

flaskpaypallib's Introduction

flaskpaypallib's People

Contributors

codad5 avatar jerrygeorge360 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

flaskpaypallib's Issues

'Flask' object has no attribute 'redirect'

Hello i have the next error
'Flask' object has no attribute 'redirect'
when i go to "http://127.0.0.1:5000/shirts"
Flask version 1.0.2
Python version 3.7.0 (default, Jun 28 2018, 08:04:48) [MSC v.1912 64 bit (AMD64)]
on windows
Code

from flask import Flask,flash, render_template , jsonify ,request,send_file,make_response,session,escape,redirect,url_for
app = Flask(__name__)

from flask_paypal_lib import Sandbox

Payer = Sandbox('USD', 10, 'shirts', 6, 'nice shirts', 10, 20, 2, 3, 7, 2, 'CAPTURE', 'http://127.0.0.1:5000/okme',
                'okme', 'http://127.0.0.1:5000/')

Payer.init_app(app)
client_id="my sandbox client_id"
client_secret_key="my sandbox secret_key"
Payer.generate_access_token(client_id, client_secret_key)

Payer.create_order_route('shirts')

Payer.complete_process()

app.secret_key="secret_key"
if __name__ == '__main__':
    app.run(debug=False)

output on chrome
Internal Server Error
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

Log
127.0.0.1 - - [16/Jan/2023 17:10:20] "GET /shirt HTTP/1.1" 404 - https://www.sandbox.paypal.com/checkoutnow?token=895154sgsdgsgd740 [2023-01-16 17:10:23,500] ERROR in app: Exception on /shirts [GET] Traceback (most recent call last): File "K:\Users\USUARIO\Anaconda3\lib\site-packages\flask\app.py", line 2292, in wsgi_app response = self.full_dispatch_request() File "K:\Users\USUARIO\Anaconda3\lib\site-packages\flask\app.py", line 1815, in full_dispatch_request rv = self.handle_user_exception(e) File "K:\Users\USUARIO\Anaconda3\lib\site-packages\flask\app.py", line 1718, in handle_user_exception reraise(exc_type, exc_value, tb) File "K:\Users\USUARIO\Anaconda3\lib\site-packages\flask\_compat.py", line 35, in reraise raise value File "K:\Users\USUARIO\Anaconda3\lib\site-packages\flask\app.py", line 1813, in full_dispatch_request rv = self.dispatch_request() File "K:\Users\USUARIO\Anaconda3\lib\site-packages\flask\app.py", line 1799, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "K:\Users\USUARIO\Anaconda3\lib\site-packages\flask_paypal_lib\sandbox.py", line 286, in create_order_route return self.app.redirect(self._create_order()) AttributeError: 'Flask' object has no attribute 'redirect'

Capture transaction data

i want to capture the transaction data when the user finish the payment

    def complete_process(self):
        """
        this completes the transaction by either capturing or authorizing the payment
        registers an endpoint that would be redirected after approval.
        Parameters
        ----------
        """
        with self.app.app_context():
            @current_app.route(f'/{self.return_url_endpoint}')
            def complete_process():
                res=''
                if self.intent=="CAPTURE":
                    res=self._capture()
                elif self.intent=="AUTHORIZE":
                    res=self._authorize()
                else:
                    res='not successful'
                return res  #<--- You are showing the data

So is there a way to get that data? and bind it with the user? for give to the user more roles after payment

or i need to overwrite the class?

Payer = Sandbox('USD', 10, 'shirts', 6, 'nice shirts', 10, 20, 2, 3, 7, 2, 'CAPTURE', 'http://localhost:8080/okme',
                'okme', 'http://localhost:8080/')
Payer.init_app(app)

Payer.generate_access_token(client_id, client_secret_key)

Payer.create_order_route('shirts')

Payer.complete_process()




@app.route("/")
def home():
    return render_template("pago/paypal.html")
@app.route("/okme")
def okme():
    if request.method == 'GET':
        print("GET")
        print(request.data)
    if request.method == 'POST':
        print("POST")
        print(request.get_json())

if __name__ == '__main__':
    app.run(debug=False,host="localhost",port="8080")

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.