예제 #1
0
파일: views.py 프로젝트: jamslevy/PQ
  def get(self):
	merchant = self.merchant_info()
	# Create a (static) instance of Controller using your vendor ID and merchant key
	controller = Controller(merchant['id'], merchant['key'], is_sandbox=merchant['is_sandbox'])
	#Create your order:
	order = gmodel.checkout_shopping_cart_t(
		shopping_cart = gmodel.shopping_cart_t(items = [
			gmodel.item_t(merchant_item_id = 'oil_quiz',
						  name             = 'Oil Quiz',
						  description      = 'Oil quiz!',
						  unit_price       = gmodel.price_t(value    = DEFAULT_QUIZ_PRICE,
															currency = 'USD'),
						  quantity = 1),
			gmodel.item_t(merchant_item_id = 'energy_quiz',
						  name             = 'Energy Quiz',
						  description      = 'Energy quiz.',
						  unit_price       = gmodel.price_t(value    = DEFAULT_QUIZ_PRICE,
															currency = 'USD'),
						  quantity = 1),
		]),
		checkout_flow_support          = gmodel.checkout_flow_support_t(
			continue_shopping_url      = self.return_url() + user_id,
			request_buyer_phone_number = False))

	# Encode the order into XML, sign it with your merchant key and form
	# Google Checkout Button html.
	prepared = controller.prepare_order(order)

	# Now prepared.html contains the full google checkout button html
	template_values = {'checkout_button': prepared.html(), 'page_title': 'Take a Quiz' }
	path = tpl_path(STORE_PATH +'store.html')
	self.response.out.write(template.render(path, template_values))
예제 #2
0
파일: checkout.py 프로젝트: jamslevy/PQ
def render_quiz_button(self, proficiency_tag, proficiency_name ):
	merchant = merchant_info(self)
	# Create a (static) instance of Controller using your vendor ID and merchant key
	controller = Controller(merchant['id'], merchant['key'], is_sandbox=merchant['is_sandbox'])
	#Create your order:
	order = gmodel.checkout_shopping_cart_t(
		shopping_cart = gmodel.shopping_cart_t(items = [
			gmodel.item_t(merchant_item_id =  proficiency_tag,
						  name             = proficiency_name,
						  description      = proficiency_name,
						  unit_price       = gmodel.price_t(value    = DEFAULT_QUIZ_PRICE,
															currency = 'USD'),
						  quantity = 1),
		]),
		checkout_flow_support          = gmodel.checkout_flow_support_t(
			continue_shopping_url      = return_url(self) + user_id,
			request_buyer_phone_number = False))

	# Encode the order into XML, sign it with your merchant key and form
	# Google Checkout Button html.
	prepared = controller.prepare_order(order)

	# Now prepared.html contains the full google checkout button html
	return prepared.html()