LogoKikoMart Docs

Cloud Functions

Deploy the notification and Stripe payment functions to Appwrite.

KikoMart uses two Go cloud functions. You'll find both in the Functions folder of your package:

  • kikomart-v1.0/
    • Documentation/
    • Functions/
      • Notification.tar.gz sends push notifications
      • Strip.tar.gz handles Stripe payments

Notification function#

  1. Go to Functions → + Create Function → Create Manually.

  2. Set Name to notification_function.

  3. Set Runtime to Go (go-1.26).

  4. Set Entrypoint to main.go.

  5. Under Deployment, upload Notification.tar.gz and click Deploy.

  6. Open the function's Settings and add these required environment variables. Enter the real values from your own project:

    VariableValue
    APPWRITE_API_ENDPOINTYour API endpoint, e.g. https://fra.cloud.appwrite.io/v1
    APPWRITE_API_KEYThe API key you created
    DATABASE_IDThe Database ID of kiko_mart_db
    STORE_ADMIN_TOPIC_IDTopic ID of Store admin topic from Messaging → Topics
    DELIVERYMAN_TOPIC_IDTopic ID of deliveryman topic from Messaging → Topics
    PAYMENT_FUNCTION_IDFunction ID of the Stripe payment function
    PAYMENT_API_SECRETThe same value you set as API_SECRET in the Stripe payment function
    SECURITY_ENFORCETurns request security checks on or off (true or false)
  7. In Settings → Executions → Scopes, enable these scopes and click Update:

    CategoryScopes
    Authteams.read, teams.write, users.read
    Databasesrows.read, rows.write
    Functionsexecutions.write
  8. Under Security, click Add role and select All users so the apps can run the function.

  9. Note down the Function ID. The apps use it as notificationFunctionId.

PAYMENT_FUNCTION_ID and PAYMENT_API_SECRET come from the Stripe payment function below. Create that function first, or come back and fill these two in afterwards.

Stripe payment function#

Only required if you accept online payments with Stripe.

  1. Go to Functions → + Create Function → Create Manually.

  2. Set Function Name to stripe_payment.

  3. Set Runtime to Go (go-1.26).

  4. Set Entrypoint to main.go.

  5. Under Deployment, upload Strip.tar.gz and click Deploy.

  6. Open the function's Settings and add these required environment variables:

    VariableDescription
    STRIPE_SECRET_KEYYour Stripe secret key (sk_test_… or sk_live_…)
    API_SECRETA secret string used to secure requests to the function
    PAYMENT_SUCCESS_URLPage the customer is sent to after a successful payment
    PAYMENT_CANCEL_URLPage the customer is sent to if the payment is cancelled
    PAYMENT_MODEPayment mode (test or live)
    STRIPE_WEBHOOK_SECRETSigning secret of your Stripe webhook (whsec_…)
  7. In Settings → Executions → Scopes → Functions, enable executions.write and click Update.

  8. Under Security, click Add role and select All users.

  9. Note down the Function ID. The Customer App uses it as stripePaymentFunctionId.

Use Stripe test keys while developing and switch to live keys only when you go to production.

Your backend is ready. Next, set up the Store App.