Blink

Blink

    ›Reference

    Getting started

    • Overview
    • Quick Start
    • Environments
    • Support

    Panels

    • Basics
    • Panel options
    • Custom content

    User Journeys

    • The basics
    • Conditions
    • Actions
    • Throttles
    • Journey Groups
    • Complete Examples

    Guides

    • How to enable donations

    Blink Javascript SDK

    • Load the SDK
    • Blink managed functions
    • Blink managed variables
    • Reference

      • showDonationModal()
      • promptDonationPopup()
      • promptSubscriptionPopup()
      • isSubscribed()
      • getSubscription()
      • onSubscriptionChange()

    Blink notifications

    • Webhooks
    • Events

      • Subscription created
      • Subscription canceled
      • Subscription reactivated
      • Subscription unpaid
      • Subscription finished
      • Payment created
      • Payment refunded

      Objects

      • Event
      • Subscription
      • Donation
      • Payment
      • Amount
      • User
      • Merchant

    blinkSDK.getSubscription()

    Get a user's valid subscription if the user is authenticated and has a valid subscription.

    Usage

        const mySubscription = blinkSDK.getSubscription();
        if (mySubscription != null) {
            console.log("Blink user has a valid subscription since" + subscription.createdAt);
        }   
    

    Signature

        blinkSDK.getSubscription()
    

    Parameters

    none

    Returns

    In case of success, it will return a subscription object, or null if the user doesn't have a valid subscription.

    Objects definitions

    Subscription

    {
        "id" : // subscription id
        "deliveryAddressId" : // id of the user's address to deliver the print version of the newspaper/magazine
        "blinkSignature" : // Blink's proof that the user is subscribed
        "userId" : // Blink user id
        "amount" : // amount paid for each cycle, expressed in currency units
        "createdAt" : // subscription create date
        "canceledAt" : // date when the user has cancelled the subscription
        "nextPaymentAttempt" : // date for the next payment
        "currencyCode" : // currency ISO 4217 code (i.e. USD/GBP/EUR)
        "offerId" : // id of the subscription offer created by the merchant
    }
    
    nametypedescription
    idStringsubscription id
    deliveryAddressIdString(can be null)id of the user's address to deliver the print version of the newspaper/magazine
    blinkSignaturehex String(can be null)Blink's proof that the user is subscribed
    userIdStringBlink user id
    amountNumberamount paid for each cycle, expressed in currency units
    createdAtiso date Stringsubscription create date
    canceledAtiso date String (can e null)date when the user has cancelled the subscription
    nextPaymentAttemptiso date Stringdate for the next payment
    currencyCodeString(can be null)currency ISO 4217 code (i.e. USD/GBP/EUR)
    offerIdStringid of the subscription offer created by the merchant
    ← isSubscribed()onSubscriptionChange() →
    • Usage
    • Signature
    • Parameters
    • Returns
    • Objects definitions
      • Subscription
    Blink
    Docs
    Getting StartedPublic API
    Integration
    Donation
    Blink
    Copyright © 2021 Blink Ledger Systems Inc. All rights reserved