ecommerce-2-api icon indicating copy to clipboard operation
ecommerce-2-api copied to clipboard

handle item order without payment gateway

Open MilanRgm opened this issue 7 years ago • 0 comments

You have used the braintree for the payment so can you please help me to figure out how i can remove that to support cash on hand not from any payment gateway.

if not order.is_complete:
				order_total = order.order_total
				nonce = request_data.get("payment_method_nonce")
				if nonce:
					result = braintree.Transaction.sale({
					    "amount": order_total,
					    "payment_method_nonce": nonce,
					    "billing": {
						    "postal_code": "%s" %(order.billing_address.zipcode),

						 },
					    "options": {
					        "submit_for_settlement": True
					    }
					})
					success = result.is_success
					if success:
						#result.transaction.id to order
						order.mark_completed(order_id=result.transaction.id)
						#order.mark_completed(order_id="abc12344423")
						order.cart.is_complete()
						response["message"] = "Your order has been completed."
						response["final_order_id"] = order.order_id
						response["success"] = True
					else:
						#messages.success(request, "There was a problem with your order.")
						error_message = result.message
						#error_message = "Error"
						response["message"] = error_message
						response["success"] = False
			else:
				response["message"] = "Ordered has already been completed."
				response["success"] = False

Here success is derived as success = result.is_success and result depends on braintree. Also order.mark_completed() depends on the result of braintree.

MilanRgm avatar Jul 02 '18 02:07 MilanRgm