Author Topic: Licensing with Gumroad in QB64.  (Read 944 times)

0 Members and 1 Guest are viewing this topic.

Offline loudar

  • Newbie
  • Posts: 73
  • improve it bit by bit.
    • View Profile
Licensing with Gumroad in QB64.
« on: May 16, 2020, 08:36:43 pm »
Hey you all!
I don't know if this is 100% the right board, but I think so?

Anyway, as a little side-project I've been working on getting licensing in QB64 to work. I'm using Gumroad for the licensing, since it's easy, reliable and commonly used. Feel free to suggest more to implement if you want!

Just paste the function into your code, feed it with a license key and modify the IF-ELSE at the bottom to your needs.
Feel free to use a key you generated yourself via defining devkey$ to get rid of the limitations of standard keys.

Code: QB64: [Select]
  1. FUNCTION checkLicense (license$)
  2.     IF license$ = devkey$ THEN
  3.         checkLicense = 1
  4.     ELSE
  5.         shellcmd$ = "cmd /c curl http://api.gumroad.com/v2/licenses/verify -d " + CHR$(34) + "product_permalink=XXun" + CHR$(34) + " -d " + CHR$(34) + "license_key=" + license$ + CHR$(34) + " > license.txt"
  6.         SHELL shellcmd$
  7.         DO: LOOP UNTIL _FILEEXISTS("license.txt") = -1
  8.         OPEN "license.txt" FOR INPUT AS #1
  9.         IF EOF(1) = 0 THEN
  10.             DO
  11.                 LINE INPUT #1, licensecallback$
  12.                 p = 0
  13.                 u = 0
  14.                 o = 0
  15.                 DO
  16.                     p = p + 1
  17.                     IF MID$(licensecallback$, p, 1) = CHR$(34) THEN
  18.                         u = p
  19.                         DO: u = u + 1: LOOP UNTIL MID$(licensecallback$, u, 1) = CHR$(34)
  20.                         attribute$ = MID$(licensecallback$, p + 1, u - p - 1)
  21.                         IF attribute$ <> "purchase" AND attribute$ <> "custom_fields" AND attribute$ <> "How did you discover Datanet?" AND attribute$ <> "variants" THEN
  22.                             o = u
  23.                             DO: o = o + 1: LOOP UNTIL MID$(licensecallback$, o, 1) = "," OR MID$(licensecallback$, o, 1) = "}"
  24.                             IF MID$(licensecallback$, o - 1, 1) = CHR$(34) THEN
  25.                                 value$ = MID$(licensecallback$, u + 3, o - u - 4)
  26.                             ELSE
  27.                                 value$ = MID$(licensecallback$, u + 2, o - u - 2)
  28.                             END IF
  29.                             p = o
  30.                             SELECT CASE attribute$
  31.                                 CASE IS = "success": success$ = value$
  32.                                 CASE IS = "uses": uses = VAL(value$)
  33.                                 CASE IS = "seller_id": sellerID$ = value$
  34.                                 CASE IS = "product_id": productID$ = value$
  35.                                 CASE IS = "product_name": productname$ = value$
  36.                                 CASE IS = "permalink": permalink$ = value$
  37.                                 CASE IS = "product_permalink": productpermalink$ = value$
  38.                                 CASE IS = "email": email$ = value$
  39.                                 CASE IS = "price": price = VAL(value$)
  40.                                 CASE IS = "currency": currency$ = value$
  41.                                 CASE IS = "quantity": quantity = VAL(value$)
  42.                                 CASE IS = "order_number": ordernumber = VAL(value$)
  43.                                 CASE IS = "sale_id": saleID$ = value$
  44.                                 CASE IS = "sale_timestamp": saletimestamp$ = value$
  45.                                 CASE IS = "purchaser_id": purchaserID = VAL(value$)
  46.                                 CASE IS = "test": test$ = value$
  47.                                 CASE IS = "How did you discover Datanet?": discovery$ = value$
  48.                                 CASE IS = "license_key": licensekey$ = value$
  49.                                 CASE IS = "ip_country": IPcountry$ = value$
  50.                                 CASE IS = "is_gift_receiver_purchase": isgift$ = value$
  51.                                 CASE IS = "refunded": refunded$ = value$
  52.                                 CASE IS = "disputed": disputed$ = value$
  53.                                 CASE IS = "dispute_won": disputewon$ = value$
  54.                                 CASE IS = "id": id$ = value$
  55.                                 CASE IS = "created_at": createdat$ = value$
  56.                                 CASE IS = "variants": variants$ = value$
  57.                                 CASE IS = "chargebacked": chargebacked$ = value$
  58.                                 CASE IS = "ended_at": endedat$ = value$
  59.                                 CASE IS = "failed_at": failedat$ = value$
  60.                             END SELECT
  61.                         ELSE
  62.                             DO: p = p + 1: LOOP UNTIL MID$(licensecallback$, p, 1) = "{" OR MID$(licensecallback$, p, 1) = "[" OR MID$(licensecallback$, p, 1) = ","
  63.                         END IF
  64.                         attribute$ = ""
  65.                         value$ = ""
  66.                     END IF
  67.                 LOOP UNTIL p >= LEN(licensecallback$)
  68.             LOOP UNTIL EOF(1) = -1
  69.         END IF
  70.         CLOSE #1
  71.         KILL "license.txt"
  72.         IF success$ = "true" AND uses < 100 AND productname$ = "Datanet" AND permalink$ = "XXun" AND licensekey$ = license$ AND endedat$ = "" AND failedat$ = "" THEN
  73.             checkLicense = 1
  74.         END IF
  75.     END IF
Check out what I do besides coding: http://loudar.myportfolio.com/

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Licensing with Gumroad in QB64.
« Reply #1 on: May 16, 2020, 09:13:04 pm »
Does this licensing company also stop Windows 10 from not knowing who the programmer is? When it doesn't know who the programmer is, it sends a huge warning to the person that runs the .exe you make unless you are running it yourself. This stopped me from putting .exe's on my old website or selling anything. I looked into it once and Microsoft charges around $150 or so. There's still a way for people to run your exe's but it's a pain.

Offline loudar

  • Newbie
  • Posts: 73
  • improve it bit by bit.
    • View Profile
Re: Licensing with Gumroad in QB64.
« Reply #2 on: May 17, 2020, 05:46:25 am »
Well, I guess it's the standard "Yes, trust this application please" but finding a way around that would be neat, that's true.

And I just use it as a gateway to distribute the software, nothing more really. But found that it could be interesting at least.
« Last Edit: May 17, 2020, 07:34:18 am by loudar »
Check out what I do besides coding: http://loudar.myportfolio.com/