BFH Handwriting Downloads: Difference between revisions
Jump to navigation
Jump to search
(Created page with "Category:BFH HandwritingCategory:Web Development == Reseting download count == <syntaxhighlight lang="mysql"> select p.catno, p.name, i.download_token, i.download_coun...") |
|||
| (7 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
[[Category:BFH Handwriting]][[Category:Web Development]] | [[Category:BFH Handwriting]][[Category:Web Development]] | ||
== | == Verifying download count == | ||
<syntaxhighlight lang="mysql"> | <syntaxhighlight lang="mysql"> | ||
SELECT @order_id := [ORDER_ID]; | |||
select p.catno, | select p.catno, | ||
p.name, | p.name, | ||
| Line 12: | Line 14: | ||
inner join cart_order o on i.order_id = o.id | inner join cart_order o on i.order_id = o.id | ||
inner join address b on o.billing_id = b.id | inner join address b on o.billing_id = b.id | ||
where i.order_id = | where i.order_id = @order_id; | ||
</syntaxhighlight> | |||
== Reseting download count == | |||
<syntaxhighlight lang="mysql"> | |||
SELECT @order_id := [ORDER_ID]; | |||
SELECT @product_id := [PRODUCT_ID]; | |||
update order_item_link set download_count = 0 where order_id = @order_id and product_id = @product_id; | |||
</syntaxhighlight> | |||
== Download link format == | |||
<syntaxhighlight lang="php"> | |||
/** | |||
* DOWNLOAD_URI defined in /_config/scripts.php | |||
* $item namespace BFHHand\Cart\CartItemDownload | |||
*/ | |||
<?=DOWNLOAD_URI . $item->downloadCode() ?> | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="text"> | |||
[SERVER_ROOT_URI]/d/[ORDER_ID]-[DOWNLOAD_TOKEN] | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="sql"> | |||
SELECT @order_id := [ORDER_ID]; | |||
SELECT @product_id := [PRODUCT_ID]; | |||
SELECT | |||
CONCAT('https://bfhhandwriting.com/d/', i.order_id, '-', i.download_token) AS `download_url` | |||
FROM order_item_link i | |||
WHERE i.order_id = @order_id | |||
AND i.product_id = @product_id; | |||
</syntaxhighlight> | </syntaxhighlight> | ||
== Download validation == | |||
=== Code === | |||
[https://github.com/dbarchowsky/bfhhand_web/blob/master/_classes/Assets/AssetsDownloadPage.php `BFHHand\Assets\AssetsDownloadPage::validate_order_payment()`] | |||
=== Required information === | |||
* order authorization code (from the payment gateway) | |||
* order authorization date | |||
* order item download token | |||
* order item download count less than maximum download count | |||
=== Authorization rules === | |||
* Download limit of 3 downloads | |||
* Download link is available up to one year from the purchase date. | |||
Latest revision as of 21:44, 13 September 2019
Verifying download count[edit]
SELECT @order_id := [ORDER_ID]; select p.catno, p.name, i.download_token, i.download_count, CONCAT(IFNULL(CONCAT(b.first_name, ' '), ''), IFNULL(b.last_name, '')) as customer, i.product_id from order_item_link i inner join catalog_item p on i.product_id = p.id inner join cart_order o on i.order_id = o.id inner join address b on o.billing_id = b.id where i.order_id = @order_id;
Reseting download count[edit]
SELECT @order_id := [ORDER_ID]; SELECT @product_id := [PRODUCT_ID]; update order_item_link set download_count = 0 where order_id = @order_id and product_id = @product_id;
Download link format[edit]
/** * DOWNLOAD_URI defined in /_config/scripts.php * $item namespace BFHHand\Cart\CartItemDownload */ <?=DOWNLOAD_URI . $item->downloadCode() ?>
[SERVER_ROOT_URI]/d/[ORDER_ID]-[DOWNLOAD_TOKEN]
SELECT @order_id := [ORDER_ID];
SELECT @product_id := [PRODUCT_ID];
SELECT
CONCAT('https://bfhhandwriting.com/d/', i.order_id, '-', i.download_token) AS `download_url`
FROM order_item_link i
WHERE i.order_id = @order_id
AND i.product_id = @product_id;
Download validation[edit]
Code[edit]
BFHHand\Assets\AssetsDownloadPage::validate_order_payment()
Required information[edit]
- order authorization code (from the payment gateway)
- order authorization date
- order item download token
- order item download count less than maximum download count
Authorization rules[edit]
- Download limit of 3 downloads
- Download link is available up to one year from the purchase date.