def post(self, request, format=None): body = json.loads( request.body ) # import this library at top..dont need to install tho body = body['values'] sale = Sale() # import from models.py at top of this file # set the field values sale.name = body['name'] sale.address1 = body['address1'] sale.address2 = body['address2'] sale.city = body['city'] sale.state = body['state'] sale.zipcode = body['zipcode'] sale.total = body['total'] sale.items = body['items'] sale.payment_intent = stripe.PaymentIntent.create( amount=int(int(sale.total) * 100), currency='usd', ) sale.save() return Response({ 'sale_id': sale.id, 'client_secret': sale.payment_intent['client_secret'], })
def post(self, request, format=None): body = json.loads(request.body) sale = Sale() sale.name = body["name"] sale.address1 = body["address1"] sale.address2 = body["address2"] sale.city = body["city"] sale.state = body["state"] sale.zipcode = body["zipcode"] sale.total = body["total"] sale.items = body["items"] sale.payment_intent = stripe.PaymentIntent.create( amount=int(sale.total) * 100, currency='usd') sale.save() return Response({ 'sale_id': sale.id, 'client_secret': sale.payment_intent['client_secret'] })
def post(self, request, format=None): body = json.loads(request.body) print(body) sale = Sale() sale.name = body['name'] sale.address1 = body['address1'] sale.address2 = body['address2'] sale.city = body['city'] sale.state = body['state'] sale.zipcode = body['zipcode'] sale.total = body['total'] sale.items = body['items'] sale.payment_intent = stripe.PaymentIntent.create(amount=int( sale.total * 100), currency='usd') sale.save() return Response({ 'sale_id': sale.id, 'client_secret': sale.payment_intent['client_secret'] })
def post(self, request, format=None): body = json.loads(request.body) sale = Sale() sale.name = body['name'] sale.address1 = body['address1'] sale.address2 = body['address2'] sale.city = body['city'] sale.state = body['state'] sale.zipcode = body['zipcode'] sale.total = body['total'] sale.items = body['items'] sale.payment_intent = stripe.PaymentIntent.create( amount=int(sale.total * 100), # $10.00 is 1000s currency='usd', ) sale.save() return Response({ # pylint: disable=maybe-no-member 'sale_id': sale.id, 'client_secret': sale.payment_intent['client_secret'], })