Guides

Coupon Integration Control

This guide explains how to integrate the coupon feature provided by Saucelive with the client’s own coupon system.

The UI shown below can be managed through Broadcast Registration or the Live Console.
If the Click Event option is set to either Download Coupon or Custom, the coupon feature can only be used in environments where bridge communication is available.

Redirect Link

In the coupon bridge, you can use the linkUrl variable as a parameter.

Usage Example

    case "sauceflexMoveCoupon":
     // 쿠폰 버튼 클릭시 링크 이동
      const link=jsonData.params.linkUrl
      const couponType =jsonData.params.couponType

      if(link && couponType ==='link' ){
       window.location.href = link
      }
      break;

Redirect Link (New Tab)

Same as above, but the specified linkUrl will open in a new browser tab.

Usage Example

    case "sauceflexMoveCoupon":
     // 쿠폰 버튼 클릭시 링크 새창
      const link = jsonData.params.linkUrl
      const couponType =jsonData.params.couponType
      if(link && couponType ==='newWindow' ){
        window.open(link)
      }
      break;

Download Coupon

You can implement the coupon download functionality using your own API.
Please refer to the Coupon Integration Guide example above or the sample code below.

Usage Example
(This is a basic example. The code below is for reference only and does not function as-is.)

case "sauceflexMoveCoupon": // Coupon Download on Button Click
  const couponCode = jsonData.params.couponCode;
  const couponType = jsonData.params.couponType;

  // If you are operating your own API server
  if (YOUR_COUPON_API) {
    fetch(`${YOUR_COUPON_API}/${couponCode}`)
      .then((res) => res.json())
      .then((res) => {
        // If the coupon download result is returned with a value stored in success
        if (res.success) {
          window.alert(`${res.percent}% You have successfully downloaded the coupon.`);
        } else {
          window.alert("All coupons are no longer available.");
        }
      })
      .catch(() => {
        window.alert("An error occurred while downloading the coupon.");
      });
  } else {
    location.href = `https://COUPON_DOWNLOAD_PAGE/${couponCode}`;
  }
  break;

Custom

This method allows you to store and use arbitrary values—such as individual JSON objects—freely.

Usage Example
(This is a basic example. The code below is for reference only and does not function as-is.)

case "sauceflexMoveCoupon": // When the coupon button is clicked, it can trigger a coupon download or redirect to a link using a predefined value.

  const metadata=jsonData.params.metadata;
  // test value "{\"couponId\": \"1\",\"title\":\"coupon1\",\"discount\": \"0\"}"
  const parsedMetadata = JSON.parse(metadata)
  const couponId = parsedMetadata.couponId
  const title = parsedMetadata.discount
  const discount = parsedMetadata.discount

  // If you are operating your own API server directly.
  if (YOUR_COUPON_API) {
    fetch(`${YOUR_COUPON_API}/${couponId}`,{ param:{ discount  } } )
      .then((res) => res.json())
      .then((res) => {
        // When the coupon download result is returned with the value stored in success.
        if (res.success) {
          window.alert(`${res.discount}% ${title} You have successfully downloaded the coupon. `);
        } else {
          window.alert("All coupons have been used.");
        }
      })
      .catch(() => {
        window.alert("An error occurred while downloading the coupon.");
      });
  } else {
    location.href = `https://COUPON_DOWNLOAD_PAGE/${couponId}`;
  }
  break;