def _initiate_payment_system_checkout(self, checkout_data: Dict[str, Any]) -> str: """Создаёт чекаут в системе PayPal, возвращает его id.""" pp_capture = PaypalCheckout.Schema().load(checkout_data) request = OrdersCreateRequest() request.prefer('return=representation') request.request_body(pp_capture.Schema().dump(pp_capture)) tracking_id: str = '' try: response = self.client.execute(request) if response.result.status == PaypalOrderStatus.CREATED.value: tracking_id = response.result.id else: print(response.status_code) for link in response.result.links: logger.debug('\t{}: {}\tCall Type: {}'.format(link.rel, link.href, link.method)) logger.debug('Total Amount: {} {}'.format(response.result.purchase_units[0].amount.currency_code, response.result.purchase_units[0].amount.value)) # If call returns body in response, you can get the deserialized version # from the result attribute of the response order = response.result logger.debug(order) except IOError as ioe: logger.error(f'Paypal failed Checkout creation{ioe}') if isinstance(ioe, HttpError): # Something went wrong server-side logger.error(ioe.status_code) return tracking_id
def create_order( self, basket, currency, return_url, cancel_url, order_total, address=None, shipping_charge=None, intent=None, preferred_response='minimal', ): request = OrdersCreateRequest() request.prefer(f'return={preferred_response}') request.request_body( self.build_order_create_request_body( basket=basket, currency=currency, return_url=return_url, cancel_url=cancel_url, order_total=order_total, intent=intent, address=address, shipping_charge=shipping_charge, )) response = self.client.execute(request) return response.result
def create_order(self, request_body): request = OrdersCreateRequest() request.prefer('return=representation') request.request_body(request_body) response = self.client.execute(request) return response
def create_order(self, data: BaseTransactionSlip, *args, **kwargs) -> BaseCreateOrderResult: if not isinstance(data, BaseTransactionSlip): raise RuntimeError("请传入一个 BaseTransactionSlip 实例") # params = {"out_trade_no": data.sid, "subject": data.name, # "total_amount": data.price, "return_url": data.sync_url} request = OrdersCreateRequest() request.prefer('return=representation') request.request_body({ "application_context": { "return_url": data.sync_url }, "intent": "CAPTURE", '' "purchase_units": [{ "invoice_id": data.sid, "description": data.name, "amount": { "currency_code": self.config['currency_code'], "value": data.price } }] }) response = self.paypal.execute(request) print("创建订单数据") self.__print_paypal_response(response) for link in response.result.links: if link.rel == 'approve': return BaseCreateOrderResult(link.href)
def create_paypal_order(currency, price, quantity, order_id, receiver, product_name, product_id) -> dict: request = OrdersCreateRequest() request.prefer('return=representation') request.request_body ( { "intent": "CAPTURE", "application_context": { "return_url": f"http://{environ.get('SITE_URL')}/order/payment/complete/{order_id}", "cancel_url": f"http://{environ.get('SITE_URL')}/order/{order_id}", "brand_name": environ.get('BRAND_NAME'), "landing_page" : "BILLING", "shipping_preference" : "NO_SHIPPING" }, "purchase_units": [ { "amount": { "currency_code": currency, "value": str(float(quantity) * float(price)), "breakdown": { "item_total" : { "currency_code" : currency, "value" : str(float(quantity) * float(price)) } } }, "items": [ { "name": product_name, "sku": ' ' + product_id, "unit_amount": { "currency_code": currency, "value": price }, "quantity": quantity, "category": "DIGITAL_GOODS" } ], "payee": { "email_address": receiver } } ] } ) try: response = client.execute(request) return { 'address' : response.result.links[1].href, 'transaction_id' : response.result.id } except Exception as e: with open('logging/log.txt', 'a') as l: l.write(str(e) + '\n') l.close()
def create_paypal_order(session, donation): paypalSettings = getPayPalSettings() client = PayPalHttpClient(paypalSettings.environment) req = OrdersCreateRequest() # set dictionary object in session['extra_test_headers'] in TestCases if session.get('extra_test_headers', None) and donation.is_test: for key, value in session.get('extra_test_headers').items(): req.headers[key] = value req.prefer('return=representation') req.request_body(build_onetime_request_body(donation)) return client.execute(req)
def pago(request): # Creating Access Token for Sandbox client_id = "AWKxRtjpmHR9Jd8n8fMGO77lqcIw7fFHML19xSzd1Scfv4Mk-XGwnjBYJIkaRaFa_y2LC2PXBulTMPFK" client_secret = "EGlVhQYGDzop2HftvmEqh726ChUjz4e7x_Ai4Hp900iA8troRX5feiS6ThlfB-HSVwzKNdHW2W3BzCyf" # Creating an environment environment = SandboxEnvironment(client_id=client_id, client_secret=client_secret) client = PayPalHttpClient(environment) # Construct a request object and set desired parameters # Here, OrdersCreateRequest() creates a POST request to /v2/checkout/orders requestPaypal = OrdersCreateRequest() sesion_id = request.session.session_key registro = Ventas_por_enviar.objects.filter(sesion=sesion_id) posicion = (len(registro)) total = registro[posicion - 1].total total_stripe = float(total) total_stripe = total_stripe * 100 requestPaypal.prefer('return=representation') requestPaypal.request_body({ "intent": "CAPTURE", "purchase_units": [{ "amount": { "currency_code": 'MXN', "value": float(total), } }], "application_context": { "return_url": "http://127.0.0.1:8000/checkout/exitoso", "cancel_url": "http://127.0.0.1:8000/checkout/cancelado", "brand_name": "Joyapan" } }) try: # Call API with your client and get a response for your call response = client.execute(requestPaypal) if response.result.status == 'CREATED': approval_url = str(response.result.links[1].href) print(approval_url) return render(request, 'checkout/pago.html',{#aqui es donde esta el boton 'approval_url':approval_url,'STRIPE_PUBLISHABLE_KEY':settings.STRIPE_PUBLISHABLE_KEY,'total':total,'total_stripe':total_stripe, }) except IOError as ioe: print(ioe) if isinstance(ioe, HttpError): # Something went wrong server-side return render(request, 'checkout/pago_cancelado.html')
def get_data(): request = OrdersCreateRequest() request.prefer('return=representation') request.request_body({ "intent": "CAPTURE", "purchase_units": [{ "amount": { "currency_code": "USD", "value": "100.00" } }] }) return request
def create_paypal_donation(currency, amount, donation_id, receiver, referrer) -> dict: request = OrdersCreateRequest() request.prefer('return=representation') request.request_body ( { "intent": "CAPTURE", "application_context": { "return_url": f"http://{environ.get('SITE_URL')}/donation/check/{donation_id}", "cancel_url": f"http://{environ.get('SITE_URL')}/donation/cancel/{donation_id}", "brand_name": environ.get('BRAND_NAME'), "landing_page" : "BILLING", "shipping_preference" : "NO_SHIPPING" }, "purchase_units": [ { "amount": { "currency_code": currency, "value": amount, "breakdown": { "item_total" : { "currency_code" : currency, "value" : amount } } }, "payee": { "email_address": receiver } } ] } ) try: response = client.execute(request) return { 'payment_address' : response.result.links[1].href, 'transaction_id' : response.result.id } except Exception as e: with open('logging/log.txt', 'a') as l: l.write(str(e) + '\n') l.close()
def create_order(self, order_body, debug=False): request = OrdersCreateRequest() request.prefer('return=representation') #3. Call PayPal to set up a transaction request.request_body(order_body) response = self.client.execute(request) if debug: print('Status Code: ', response.status_code) print( 'Status: ', response.result.status) print( 'Order ID: ', response.result.id) print( 'Intent: ', response.result.intent) print ('Links:') for link in response.result.links: print('\t{}: {}\tCall Type: {}'.format(link.rel, link.href, link.method)) print ('Total Amount: {} {}'.format(response.result.purchase_units[0].amount.currency_code, response.result.purchase_units[0].amount.value)) return response
def create_order_with_minimum_payload(self, debug=False): request = OrdersCreateRequest() request.prefer('return=representation') request.request_body(self.build_minimum_request_body()) response = self.client.execute(request) if debug: print 'Order With Minimum Payload:' print 'Status Code:', response.status_code print 'Status:', response.result.status print 'Order ID:', response.result.id print 'Intent:', response.result.intent print 'Links:' for link in response.result.links: print('\t{}: {}\tCall Type: {}'.format(link.rel, link.href, link.method)) print 'Total Amount: {} {}'.format(response.result.purchase_units[0].amount.currency_code, response.result.purchase_units[0].amount.value) json_data = self.object_to_json(response.result) print "json_data: ", json.dumps(json_data,indent=4) return response
def create_order(client): request = OrdersCreateRequest() request.prefer("return=representation") body = { "intent": "CAPTURE", "purchase_units": [{ "reference_id": "test_ref_id1", "amount": { "value": "100.00", "currency_code": "USD" } }], "redirect_urls": { "cancel_url": "https://example.com/cancel", "return_url": "https://example.com/return" } } request.request_body(body) return client.execute(request)
def create_order(self, buy_order_id, total_amount, description, unit_price_currency, debug=False): request = OrdersCreateRequest() request.prefer('return=representation') # 3. Call PayPal to set up a transaction request.request_body( self.build_purchase_order_body(buy_order_id, total_amount, description, unit_price_currency)) response = self.client.execute(request) if debug: print('Status Code: ', response.status_code) print('Status: ', response.result.status) print('Order ID: ', response.result.id) print('Intent: ', response.result.intent) return response
def create_order(self, debug=False): request = OrdersCreateRequest() request.prefer('return=representation') # 3. Call PayPal to set up a transaction request.request_body(self.build_request_body()) response = self.client.execute(request) if debug: print 'Status Code: ', response.status_code print 'Status: ', response.result.status print 'Order ID: ', response.result.id print 'Intent: ', response.result.intent print 'Links:' for link in response.result.links: print('\t{}: {}\tCall Type: {}'.format(link.rel, link.href, link.method)) print 'Total Amount: {} {}'.format( response.result.purchase_units[0].amount.currency_code, response.result.purchase_units[0].amount.value) return response """Setting up the JSON request body for creating the order. Set the intent in the
def create_order(self, body): request = OrdersCreateRequest() request.prefer('return=representation') request.request_body(body) response = self.client.execute(request) if settings.DEBUG: print('Status Code: ', response.status_code) print('Status: ', response.result.status) print('Order ID: ', response.result.id) print('Intent: ', response.result.intent) print('Links:') for link in response.result.links: print('\t{}: {}\tCall Type: {}'.format(link.rel, link.href, link.method)) print('Total Amount: {} {}' \ .format( response.result.purchase_units[0].amount.currency_code, response.result.purchase_units[0].amount.value ) ) return response
def get_paypal_order_id(config: GatewayConfig, amount: float, currency: str) -> str: """Get token (Paypal order id). Only for use in tests when payment has not yet been created. """ client = get_paypal_client(**config.connection_params) request = OrdersCreateRequest() request.prefer("return=representation") request.request_body({ "intent": "CAPTURE", "purchase_units": [{ "amount": { "currency_code": currency, "value": amount } }], }) response = client.execute(request) return response.result.id
def create_order(amount): request = OrdersCreateRequest() request.prefer('return=representation') request.request_body({ "intent": "CAPTURE", "purchase_units": [{ "amount": { "currency_code": "USD", "value": amount } }] }) try: # Call API with your client and get a response for your call response = client.execute(request) # print ('Order With Complete Payload:') # print ('Status Code:', response.status_code) # print ('Status:', response.result.status) # print ('Order ID:', response.result.id) # print ('Intent:', response.result.intent) # print ('Links:') for link in response.result.links: # print('\t{}: {}\tCall Type: {}'.format(link.rel, link.href, link.method)) # print('Total Amount: {} {}'.format(response.result.purchase_units[0].amount.currency_code, # response.result.purchase_units[0].amount.value)) # If call returns body in response, you can get the deserialized version from the result attribute of the response order = response.result return order except IOError as ioe: print(ioe) if isinstance(ioe, HttpError): # Something went wrong server-side print(ioe.status_code)
def create_payment(self, *, price: str, currency: str, reference: str) -> HttpResponse: """ Create a new PayPal payment that gets authorized on the Frontend :param currency: Currencies international abbreviation, e.g. EUR, USD :param reference: A given reference ID for the PayPal order :param price: Price of the product with 2 digits precision :return: The response of the API call to PayPal """ request = OrdersCreateRequest() request.prefer("return=representation") request.request_body({ "intent": "CAPTURE", "purchase_units": [{ "reference_id": reference, "amount": { "currency_code": currency, "value": price, } }] }) return self.client.execute(request)
def create_order(self, purchase_items,site_name,return_url,cancel_url,debug=True): request = OrdersCreateRequest() request.prefer('return=representation') #3. Call PayPal to set up a transaction request.request_body(self.build_request_body(purchase_items,site_name,return_url,cancel_url)) response = self.client.execute(request) if debug: print('Status Code: ', response.status_code) print('Status: ', response.result.status) print('Order ID: ', response.result.id) print('Intent: ', response.result.intent) print('Links:') return_link = "" for link in response.result.links: print('\t{}: {}\tCall Type: {}'.format(link.rel, link.href, link.method)) print('Total Amount: {} {}'.format(response.result.purchase_units[0].amount.currency_code, response.result.purchase_units[0].amount.value)) if link.rel =='approve': return_link = link.href return response
def post(self, request, *args, **kwargs): ''' 1、安装步骤 https://github.com/paypal/Checkout-Python-SDK 2、安装扩展 pip install paypal-checkout-serversdk ''' # 支付配置,或客户端ID和密钥 client_id = "ATEQmbELmKGz1SSEqdsLiDKT7hJFUEMa6bVDkeCeDTA-Clk1zkXAyRyAdg79QmiYzprlEx9l-H1AZDT5" client_secret = "EJ41EU53uhly-niPE7Cb0b7WhXIk2wfzgs5A6jr0cGBtUOwf5xTmm7pj1GqmeVdaztW_yO_icjFi_Kiz" # Creating an environment environment = SandboxEnvironment(client_id=client_id, client_secret=client_secret) client = PayPalHttpClient(environment) # 创建订单 request = OrdersCreateRequest() request.prefer('return=representation') request.request_body({ "intent": "CAPTURE", "application_context": { "return_url": "https://www.example.com/success", "cancel_url": "https://www.example.com/cancel", "brand_name": "EXAMPLE INC", "landing_page": "BILLING", "shipping_preference": "SET_PROVIDED_ADDRESS", "user_action": "CONTINUE" }, "purchase_units": [{ "reference_id": "PUHF", "description": "Sporting Goods", "custom_id": "CUST-HighFashions", "soft_descriptor": "HighFashions", "amount": { "currency_code": "USD", "value": "220.00", "breakdown": { "item_total": { "currency_code": "USD", "value": "180.00" }, "shipping": { "currency_code": "USD", "value": "20.00" }, "handling": { "currency_code": "USD", "value": "10.00" }, "tax_total": { "currency_code": "USD", "value": "20.00" }, "shipping_discount": { "currency_code": "USD", "value": "10" } } }, "items": [{ "name": "T-Shirt", "description": "Green XL", "sku": "sku01", "unit_amount": { "currency_code": "USD", "value": "90.00" }, "tax": { "currency_code": "USD", "value": "10.00" }, "quantity": "1", "category": "PHYSICAL_GOODS" }, { "name": "Shoes", "description": "Running, Size 10.5", "sku": "sku02", "unit_amount": { "currency_code": "USD", "value": "45.00" }, "tax": { "currency_code": "USD", "value": "5.00" }, "quantity": "2", "category": "PHYSICAL_GOODS" }], "shipping": { "method": "United States Postal Service", "name": { "full_name": "John Doe" }, "address": { "address_line_1": "123 Townsend St", "address_line_2": "Floor 6", "admin_area_2": "San Francisco", "admin_area_1": "CA", "postal_code": "94107", "country_code": "US" } } }] }) # try: # # Call API with your client and get a response for your call # response = client.execute(request) # print('Order With Complete Payload:') # print('Status Code:', response.status_code) # print('Status:', response.result.status) # print('Order ID:', response.result.id) # print('Intent:', response.result.intent) # print('Links:') # for link in response.result.links: # print('\t{}: {}\tCall Type: {}'.format(link.rel, link.href, link.method)) # print('Total Amount: {} {}'.format(response.result.purchase_units[0].amount.currency_code,response.result.purchase_units[0].amount.value)) # order = response.result # print(order) # except IOError as ioe: # print(ioe) # if isinstance(ioe, HttpError): # # Something went wrong server-side # print(ioe.status_code) # # # # 执行支付,翻来例子(https://www.example.com/success?token=0GY18103X3714024Y&PayerID=CNJZ7XSZ642R2),传token作为订单id,执行支付 # request = OrdersCaptureRequest("0GY18103X3714024Y") # try: # response = client.execute(request) # order = response.result.id # print(order) # except IOError as ioe: # if isinstance(ioe, HttpError): # # Something went wrong server-side # print(ioe.status_code) # print(ioe.headers) # print(ioe) # else: # # Something went wrong client side # print(ioe) return JsonResponse({"res": 3, "pay_url": 123})
def create_paypal_order(order): req = OrdersCreateRequest() req.prefer('return=representation') req_body = create_paypal_order_body(order) req.request_body(req_body) return get_paypal_client().execute(req)
def post(self): try: data = request.get_json() identity = get_jwt_identity() validation = order.validate_razorpay_paypal_cod_order(data) if validation['isValid']: if identity['id']: args = { 'user_id': identity['id'], 'user_amount': data['amount'], 'user_display_amount': data['displayAmount'], 'order_id': data['orderId'], 'coupon_id': data['couponId'] if 'couponId' in data else None } # Price check result = run_db_query( 'select _finaltotalvalue, status from ' ' store.fncheckprice(' '_user_id=>%(user_id)s, ' '_order_id=>%(order_id)s, ' '_coupon_id=>%(coupon_id)s, ' '_webtotalvalue=>%(user_amount)s )', args, 'price check call', True) if result == 'error': raise Exception elif result['status']: # Creating Access Token for Sandbox client_id = secrets['LIVE_PAYPAL_ID'] client_secret = secrets['LIVE_PAYPAL_SECRET'] # Creating an environment # environment = SandboxEnvironment(client_id=client_id, client_secret=client_secret) environment = LiveEnvironment( client_id=client_id, client_secret=client_secret) client = PayPalHttpClient(environment) order_request = OrdersCreateRequest() order_request.prefer('return=representation') order_request.request_body({ "intent": "CAPTURE", "purchase_units": [{ "amount": { "currency_code": "USD", "value": args['user_display_amount'] } }], "application_context": { "shipping_preference": 'NO_SHIPPING' } }) try: # Call API with your client and get a response for your call response = client.execute(order_request) if response.result and response.result.id: return { 'message': 'success', 'data': { 'orderId': response.result.id } }, 200 else: return { 'message': 'Error while completing payment, please retry.' }, 500 except IOError as ioe: if isinstance(ioe, HttpError): # Something went wrong server-side print(ioe.status_code) return { 'message': 'Error while completing payment, please retry.' ' If the issue still persists, try after sometime.' }, 500 else: return { 'message': 'Price changed for one or more product. Getting the latest price' }, else: return {'message': 'User Auth is missing.'}, 401 else: return {'message': 'Validation error, try again'}, 500 except Exception as e: app.logger.debug(e) return { 'message': 'Error while completing payment, please retry.' ' If the issue still persists, try after sometime.' }, 500
async def create_transaction( transaction_body: CreateTransactionModel, identity: Optional[str] = Depends(get_jwt_identity_optional)): try: order = Order.objects.get(id=transaction_body.orderID, orderer=identity) shipping = order.addresses['shipping'] shipping = { "method": "United States Postal Service", # TODO: make this dynamic "address": { "name": { "full_name": shipping['name'] }, "address_line_1": shipping['street1'], "address_line_2": shipping['street2'], "admin_area_2": shipping['city'], "admin_area_1": shipping['region'], "postal_code": shipping['zip'], "country_code": shipping['country'] } } base_amount = price_service.calculate_order_subtotal(order) tax = price_service.calculate_order_tax(order) amount = base_amount + tax shippingAmt = price_service.calculate_order_shipping(order) total = amount + shippingAmt discount = price_service.calculate_order_discount(order) requestBody = { "intent": "CAPTURE", "application_context": { "brand_name": PayPalSettings.BRAND_NAME, "landing_page": 'BILLING', "shipping_preference": "SET_PROVIDED_ADDRESS", "user_action": "PAY_NOW", "return_url": transaction_body.location + "/checkout/placed?id=" + str(order.id), "cancel_url": transaction_body.location + "/checkout", }, "purchase_units": [{ # "reference_id": "", # "description": "", "custom_id": str(order.id), # "soft_descriptor": "", "amount": { "currency_code": "USD", "value": '{:.2f}'.format(round(amount, 2)), "breakdown": { "item_total": { "currency_code": "USD", "value": '{:.2f}'.format(round(total, 2)) }, "shipping": { "currency_code": "USD", "value": '{:.2f}'.format(round(shippingAmt, 2)) }, "tax_total": { "currency_code": "USD", "value": '{:.2f}'.format(round(tax, 2)) }, "discount": { "currency_code": "USD", "value": '{:.2f}'.format(round(discount, 2)) } } }, "items": [], "shipping": shipping }] } for item in order.products: requestBody['purchase_units'][0]['items'].append({ "name": item.product.title, "unit_amount": { "currency_code": "USD", "value": '{:.2f}'.format(float(item.product.price)) }, "tax": { "currency_code": "USD", "value": '{:.2f}'.format(float(item.product.price) * order.taxRate) }, "quantity": str(item.qty), "description": item.product.excerpt, "sku": item.product.sku, "category": "DIGITAL_GOODS" if item.product.digital else "PHYSICAL_GOODS" }) requestArgs = OrdersCreateRequest() requestArgs.prefer('return=representation') requestArgs.request_body(requestBody) response = paypal_client.client.execute(requestArgs) return response.result.id except DoesNotExist: raise NotFoundError().http_exception except Exception as e: raise e
def conta(request): if request.POST: rq = request.POST pprint(rq) if 'lojasim' in rq: usr = models.Cliente.objects.get(pk=request.user.id) usr.loja = True pprint(usr) usr.save() messages.info(request,' Agora é uma loja') elif 'exc_prod' in rq: prod = models.Produto.objects.exclude(pk=rq['exc_prod']) prod.save() messages.info(request,' Excluido') elif 'tipo' in rq: # rq['img_prod'] = 'gbstr/'+rq['img_prod'] pprint(request.FILES) print('entro pdsadasdkasd´sadas') if request.FILES: rf = request.FILES prod = forms.produtoform(rq,rf) pprint(prod) print('produto aqqq') else: prod = forms.produtoform(rq) pprint(prod) if prod.is_valid(): cloudinary.uploader.upload(rf['img_prod'], folder="gbstr") prod.save() print('salvo prod') messages.info(request, 'Produto cadastrado') else: print(prod.errors) messages.info(request, 'Produto não cadastrado') return redirect(settings.LOGIN_REDIRECT_URL, permanent=True) # print('foi =-=-') tkn = settings.TKN_PAYPAL url = "https://api.sandbox.paypal.com/v1/oauth2/token" url_order = 'https://api.sandbox.paypal.com/v2/checkout/orders' # Creating Access Token for Sandbox client_id = "AeiuNrrRAuS4rFA1VhDtnS_L47TrJ6wakg5by7FOLdJ4JQalehB1Najy7HU6iTeJMKKfj7csQDFhSQuV" client_secret = "EH8iMPsj1CwLkPr4bx_1VseaWmuALLPX5FaOwr6s4GdFEUkV2ZxFYJa0pojule4ODYg44aU4VRfMPxZK" # Creating an environment environment = SandboxEnvironment(client_id=client_id, client_secret=client_secret) client = PayPalHttpClient(environment) req = OrdersCreateRequest() req.prefer('return=representation') req.request_body( { "intent": "CAPTURE", "purchase_units": [ { "amount": { "currency_code": "BRL", "value": "100.00" } } ] } ) # try: # # # Call API with your client and get a response for your call # # response = client.execute(req) # # # print # 'Order With Complete Payload:' # print # 'Status Code:', response.status_code # print # 'Status:', response.result.status # print # 'Order ID:', response.result.id # print # 'Intent:', response.result.intent # print # 'Links:' # for link in response.result.links: # print('\t{}: {}\tCall Type: {}'.format(link.rel, link.href, link.method)) # print # 'Total Amount: {} {}'.format(response.result.purchase_units[0].amount.currency_code, # response.result.purchase_units[0].amount.value) # # If call returns body in response, you can get the deserialized version from the result attribute of the response # order = response.result # print # order # except IOError as ioe: # print # ioe # if isinstance(ioe, HttpError): # # Something went wrong server-side # print # ioe.status_code pprint(client) clent = models.Cliente.objects.get(pk=request.user.id) cart = models.Carrinho.objects.get(cliente_cli=clent.id) prods = models.Produto.objects.all() # pprint(clent) # pprint(cart) # if len(cart) isArray: # cart = [cart] # pprint(cart.produto_cli) # pprint(prods) return render( request, 'conta.html', { 'prod': forms.produtoform, # 'userform':forms.cria_usr(), 'usuario': clent, 'carrinho': cart, # 'totalpedido': models.Tot_ped.objects.all(), # 'venda': models.Venda.objects.all(), 'produtos': prods, # 'pagamento': models.Pagamentos.objects.all(), 'prodtipo': models.Produto.STATUS_CHOICES } )