| space If you want to place multiple products/addons in one license key, you may use | and : like: Some Product:12345678|An addon:87654321|Another addon:aabbccddee To the buyer, this is displayed as: Some Product: 12345678 An addon: 87654321 Another addon: aabbccddee You may add as many products/addons as you like. The total size of the a single server response must not exceed 2048 bytes. Keep this in mind, when adding fields to the license key data. To automatically revoke a license on order cancellation (chargeback/refund/ cancelled subscription), setup an ipn call on https://www.digistore24.com/settings/ipn - for more information on ipn with Digistore24, visit https://www.digistore24.com/test/ipn LICENSE AGREEMENT / TERMS OF USAGE You may use, modify, use the modified version of this file for the purpose of using any webshop, billing system, web page, sales page or any other page with the purpose of selling digital or physical goods with the Digistore24 Inc.. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ // EDIT HERE: // Make sure, this is set to your thankyou page key // as configured on https://www.digistore24.com/settings/thank_you: define( 'THANKYOU_PAGE_KEY', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' ); function digistore_exit( $response ) { header( 'Content-Type: application/json' ); header( 'X-Robots-Tag: noindex, nofollow' ); die( json_encode( $response ) ); } function digistore_error( $message ) { $response = array( 'status' => 'error', 'message' => $message, ); digistore_exit( $response ); } function digistore_signature( $thankyou_page_key, $array) { unset($array[ 'sha_sign' ]); $keys = array_keys($array); sort($keys); $sha_string = ""; foreach ($keys as $key) { $value = html_entity_decode( $array[ $key ] ); $value = $array[ $key ]; $is_empty = !isset($value) || $value === "" || $value === false; if ($is_empty) { continue; } $sha_string .= "$key=$value$thankyou_page_key"; } $sha_sign = strtoupper(hash("sha512", $sha_string)); return $sha_sign; } function digistore_post_value($varname) { return empty($_POST[ $varname ]) ? '' : $_POST[ $varname ]; } function digistore_license_key_data() { $order_id = digistore_post_value('order_id'); // e.g. 'A1B2C3D4' $email = digistore_post_value('email'); $first_name = digistore_post_value('address_first_name'); $last_name = digistore_post_value('address_last_name'); $product_name = digistore_post_value('product_name'); $product_id = digistore_post_value('product_id'); // In the Digistore24 backoffice in the product editor you may set the // maximaum number of units, that a buyer may buy. The default is 1, // so that $quantity is usually equal 1. $quantity = digistore_post_value('quantity'); $api_mode = digistore_post_value('api_mode'); // 'live' or 'test' $is_test_mode = $api_mode != 'live'; // Note: not all orders have the complete address. // To make the complete address a requirement on the orderform, // edit the product settings in Digistore24 $address_street = digistore_post_value('address_street_name'); $address_street_no = digistore_post_value('address_street_number'); $address_city = digistore_post_value('address_city'); $address_state = digistore_post_value('address_state'); $address_zipcode = digistore_post_value('address_zipcode'); $address_phone_no = digistore_post_value('address_phone_no'); // The license data is displayed to the customer. You may add any data // you like, but keep in mind, that the total size of the http response // must not exeed 2048 bytes. // If your keygenerator does not deliver license data, Digistore24 adds // default license data (first name, last name, email, product name). // EDIT HERE: Make sure all license data are included in the following array. $license_data = array( 'order_id' => $order_id, 'first_name' => $first_name, 'last_name' => $last_name, 'email' => $email, 'product_name' => $product_name, ); return $license_data; } function digistore_license_key( $license_key_data ) { // EDIT HERE: // Replace the body of this function by your license key generation code // Make sure, the key meets the requirements stated // at the top of this file. $serialized = serialize( $license_key_data ); $license_key = md5( $serialized ); return $license_key; } $received_signature = digistore_post_value('sha_sign'); $expected_signature = digistore_signature( THANKYOU_PAGE_KEY, $_POST); $sha_sign_valid = $received_signature == $expected_signature; if (!$sha_sign_valid) { digistore_error('invalid sha signature'); } $license_key_data = digistore_license_key_data(); $license_key = digistore_license_key( $license_key_data ); // $license_key is either a string (if there is a single license key) // or an associative array like (for multiple license keys): // $license_key = array( // 'product name 1' => 'license key 1', // 'product name 2' => 'license key 2', // ); // $response must not have more than 2048 bytes. $response = array( 'status' => 'success', 'key' => $license_key, 'data' => $license_key_data, // 'headline' => 'Your license data', // optional - if ommited, the headline is 'Your license data' (in the user's language) // 'show_on' => array( 'receipt_page', 'invoice', 'order_confirmation_email' ), // optional - determines where to show these data in DigiStore? Defaults to: all three places // 'hidden_data_keys' => array( 'hidden_key' ), // optional - array key(s) of $license_key_data. Hide parts of $license_data from the user. You may use this to add a hidden hash value to $license_key_data. ); digistore_exit( $response );