import jingrow


def execute():
	from jingrow.utils.password import get_decrypted_password, set_encrypted_password

	stripe_account = jingrow.db.get_single_value("Jcloud Settings", "stripe_account")

	# Fetch credentials from "Stripe Settings" pagetype
	secret_key = get_decrypted_password("Stripe Settings", stripe_account, "secret_key")
	publishable_key = jingrow.db.get_value(
		"Stripe Settings", stripe_account, "publishable_key"
	)

	jingrow.reload_pagetype("Jcloud Settings")

	# Set credentials in Jcloud Settings
	jingrow.db.set_single_value("Jcloud Settings", "stripe_publishable_key", publishable_key)
	set_encrypted_password(
		"Jcloud Settings", "Jcloud Settings", secret_key, "stripe_secret_key"
	)
