# Overview

If the enterprise's API interface needs to be billed, you can use the FizzGate open platform function. As a powerful API gateway and management tool, FizzGate provides enterprises with flexible interface billing capabilities and helps them achieve accurate billing and revenue management. Through this function, enterprises can tailor their internal APIs or expose them using the partner's API. The partner obtains the fizz-appid and fizz-secret through registration and then signs the call interface.

# API Package

  1. Configure payment

Add in application.yml file:

pay:
   alipay:
     gatewayUrl: https://openapi.alipay.com/gateway.do
     app_id: Alipay app_id
     merchant_private_key: Alipay merchant private key
     alipay_public_key: Alipay merchant public key
     notify_url: the notification address you configured in Alipay
     return_url: the callback address you configured in Alipay
     sign_type: RSA2
     charset: utf-8
  1. Create a route

Before creating an API package, please make sure you have created a route in the routing management. The route can have the caller option enabled or the caller option not enabled. If the route is referenced by the package, the call will be automatically checked. side options. The routing type can be any one of service orchestration, service discovery, and reverse proxy types, such as:

  1. Create a package

Add an API package, fill in the basic information, and pay attention to the package type. At this stage, only traffic package billing is supported. If your price is 0, users can subscribe to the package for free. The document set selection allows you to select the documents that need to be displayed in the document. For specific operations, see document set creation. If you do not fill it in, the document will not be displayed. If the package is selected to be put on the shelf, it will be visible in the market, and the API market will display the package products.

# API Purchase

  1. Registered user

Users register through the login interface and can register an account with the role of "Open Platform User". After logging in, this account will only display: Open Platform - My API menu. In this menu, users can obtain fizz-appid and fizz-secret.

  1. Purchase a package

Click Open Platform-My API-API Market, select the corresponding package, and click to purchase;

  1. Call API

The appid is used for authentication inside the package. The caller needs to pass the following request header when calling the interface:

fizz-appid appid request header
fizz-sign signature request header, passing the signature value generated based on the key
fizz-ts timestamp request header, passing the current timestamp

verification method: MD5 signature is a built-in authentication method

Signature generation method: MD5(appid++timestamp++key), such as: MD5(10001_1605255335977_e4502ba3a71448bbbcecef22b305d2ba)

Example:

fizz-appid: 10001
fizz-sign: e4502ba3a71448bbbcecef22b305d2ba
fizz-ts: 1605255335977

# Postman setting method

# Environment variable settings

fizz-appid: Copy from the management background

fizz-secret: copy from the management backend

# Set Pre-request

//Get the appid and secretKey preset as environment variables

appid = pm.environment.get("fizz-appid");

secretKey = pm.environment.get("fizz-secret");

//Define a string composed of appid, string to be translated, random number, and key

var timestamp = Date.now();

var str = appid + "\_" + timestamp + "\_" + secretKey;

console.log(str);

//Encrypt str with md5

var strmd5= CryptoJS.MD5(str).toString();

console.log(strmd5);

pm.environment.set("fizz-ts", timestamp);

pm.environment.set("fizz-sign", strmd5);

# Other settings

# Configure the API market header and feet

Click System Management-Parameter Management to modify the two configuration parameters of the link information at the bottom of the website and the API management platform menu.