Support string product ids (repulze) master codeberg/master v0.8.1
authorChristian Weiske <cweiske@cweiske.de>
Mon, 23 Jun 2025 20:01:31 +0000 (22:01 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Mon, 23 Jun 2025 20:01:31 +0000 (22:01 +0200)
data/schema.sql
src/ProductRepository.php
www/.htaccess

index be97ed83a45a9753ba08597a33a73645083478c2..abd7965ccdac50b0c2e5aa7434ab47325145a7c7 100644 (file)
@@ -46,7 +46,7 @@ CREATE TABLE product_purchases (
     id INTEGER PRIMARY KEY AUTO_INCREMENT,
     userId INTEGER NOT NULL,
     gameId INTEGER,
-    productId INTEGER,
+    productId VARCHAR(64),
 
     created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
     updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
index c28387c486da9843cd3257eaa4d8c74c8c6fc4c5..0c953f1d1dc57005b13ac43bd60b8a09675a3ddc 100644 (file)
@@ -13,7 +13,7 @@ class ProductRepository
         $this->db = new Db();
     }
 
-    public function createPurchase(int $userId, int $gameId, int $productId): void
+    public function createPurchase(int $userId, int $gameId, string $productId): void
     {
         $stmt = $this->db->prepare(
             'SELECT id FROM product_purchases'
@@ -82,7 +82,7 @@ class ProductRepository
         return $productsByGame[$gameuuid] ?? [];
     }
 
-    public function getCachedProduct(int $productId): ?object
+    public function getCachedProduct(string $productId): ?object
     {
         $cacheDir = __DIR__ . '/../cache/';
         $productsCacheFile = $cacheDir . 'products.min.json';
@@ -90,7 +90,7 @@ class ProductRepository
 
         foreach ($productsByGame as $products) {
             foreach ($products as $product) {
-                if ($product->id === $productId) {
+                if ($product->id == $productId) {
                     return $product;
                 }
             }
index 7fdaa3839a81575cd0877aaf2930daf241664129..a460cceb7a3de4f875ff626b50de4e9c32763048 100644 (file)
@@ -60,8 +60,8 @@ RewriteRule ^api/rest/user/achievement/summary/view.json;jsessionid=(.*)$ /api/r
 RewriteRule ^api/rest/wallet/payment/game/([A-Za-z0-9]*)/init-transaction/do/view.json$ /api/rest/wallet/payment/game/init-transaction.php?gameuuid=$1 [END]
 RewriteRule ^api/rest/wallet/payment/game/([A-Za-z0-9]*)/init-transaction/do/view.json;jsessionid=(.*)$ /api/rest/wallet/payment/game/init-transaction.php?gameuuid=$1&jsessionid=$2 [END]
 
-RewriteRule ^api/rest/wallet/payment/game/([A-Za-z0-9]*)/product/([0-9]*)/init-transaction/do/view.json$ /api/rest/wallet/payment/game/product/init-transaction.php?gameuuid=$1&productid=$2 [END]
-RewriteRule ^api/rest/wallet/payment/game/([A-Za-z0-9]*)/product/([0-9]*)/init-transaction/do/view.json;jsessionid=(.*)$ /api/rest/wallet/payment/game/product/init-transaction.php?gameuuid=$1&productid=$2&jsessionid=$3 [END]
+RewriteRule ^api/rest/wallet/payment/game/([A-Za-z0-9]*)/product/([0-9a-z_.]*)/init-transaction/do/view.json$ /api/rest/wallet/payment/game/product/init-transaction.php?gameuuid=$1&productid=$2 [END]
+RewriteRule ^api/rest/wallet/payment/game/([A-Za-z0-9]*)/product/([0-9a-z_.]*)/init-transaction/do/view.json;jsessionid=(.*)$ /api/rest/wallet/payment/game/product/init-transaction.php?gameuuid=$1&productid=$2&jsessionid=$3 [END]
 
 
 RewriteRule ^connect_check.php$ - [R=204,L]