Plugin Directory

Changeset 3298867


Ignore:
Timestamp:
05/22/2025 02:40:26 PM (11 months ago)
Author:
audienceplayer
Message:
  • released version 6.0.0
Location:
audienceplayer
Files:
32 edited
1 copied

Legend:

Unmodified
Added
Removed
  • audienceplayer/tags/6.0.0/audienceplayer.php

    r3093691 r3298867  
    99Description: AudiencePlayer integration
    1010Author: AudiencePlayer
    11 Version: 5.0.2
     11Version: 6.0.0
    1212Author URI: https://www.audienceplayer.com
    1313Text Domain: audienceplayer
  • audienceplayer/tags/6.0.0/composer.lock

    r3093691 r3298867  
    6767        {
    6868            "name": "phpstan/phpstan",
    69             "version": "1.11.2",
     69            "version": "1.12.27",
    7070            "source": {
    7171                "type": "git",
    7272                "url": "https://github.com/phpstan/phpstan.git",
    73                 "reference": "0d5d4294a70deb7547db655c47685d680e39cfec"
     73                "reference": "3a6e423c076ab39dfedc307e2ac627ef579db162"
    7474            },
    7575            "dist": {
    7676                "type": "zip",
    77                 "url": "https://api.github.com/repos/phpstan/phpstan/zipball/0d5d4294a70deb7547db655c47685d680e39cfec",
    78                 "reference": "0d5d4294a70deb7547db655c47685d680e39cfec",
     77                "url": "https://api.github.com/repos/phpstan/phpstan/zipball/3a6e423c076ab39dfedc307e2ac627ef579db162",
     78                "reference": "3a6e423c076ab39dfedc307e2ac627ef579db162",
    7979                "shasum": ""
    8080            },
     
    121121                }
    122122            ],
    123             "time": "2024-05-24T13:23:04+00:00"
     123            "time": "2025-05-21T20:51:45+00:00"
    124124        }
    125125    ],
    126126    "aliases": [],
    127127    "minimum-stability": "stable",
    128     "stability-flags": [],
     128    "stability-flags": {},
    129129    "prefer-stable": false,
    130130    "prefer-lowest": false,
     
    134134        "ext-json": "*"
    135135    },
    136     "platform-dev": [],
     136    "platform-dev": {},
    137137    "plugin-api-version": "2.6.0"
    138138}
  • audienceplayer/tags/6.0.0/languages/audienceplayer-wordpress-plugin.pot

    r3093691 r3298867  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: 5.0.2\n"
     5"Project-Id-Version: 6.0.0\n"
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/audienceplayer\n"
    77"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
  • audienceplayer/tags/6.0.0/readme.txt

    r3093691 r3298867  
    11=== AudiencePlayer ===
    22Contributors: audienceplayer
    3 Stable tag: 5.0.2
    4 Tested up to: 6.5
     3Stable tag: 6.0.0
     4Tested up to: 6.8
    55Requires at least: 5.5
    66Requires PHP: 7.1
     
    2222This plugin relies on the following external AudiencePlayer libraries, via which user profile data is exchanged with the AudiencePlayer Backend:
    2323
    24 1. **AudiencePlayer Ap wrapper library for PHP**
     241. **AudiencePlayer API wrapper library for PHP**
    2525  * link: [https://github.com/AudiencePlayer/audienceplayer-api-client-php](https://github.com/AudiencePlayer/audienceplayer-api-client-php)
    2626  * license: [https://github.com/AudiencePlayer/audienceplayer-api-client-php/blob/master/LICENSE](https://github.com/AudiencePlayer/audienceplayer-api-client-php/blob/master/LICENSE)
  • audienceplayer/tags/6.0.0/src/AudiencePlayer/AudiencePlayerWordpressPlugin/AudiencePlayerWordpressPlugin.php

    r3068993 r3298867  
    664664            'dialogue_user_subscription_will_switch_at_renewal' => '→ At the next renewal date, your subscription will switch to "{{ subscription_title }}"',
    665665            'dialogue_video_not_available_in_region' => 'The content is not available in your current country or region.',
    666             'dialogue_voucher_code_invalid' => 'Voucher code is not valid.',
    667             'dialogue_voucher_code_not_applicable' => 'Voucher code is not valid or cannot be applied on current subscription.',
    668             'dialogue_voucher_code_applicable_subscription_unknown' => 'This voucher can only be applied to an already existing subscription or when purchasing a new subscription.',
     666            'dialogue_voucher_code_applicable_subscription_unknown' => 'This voucher code can only be applied to an already existing subscription or when purchasing a new subscription.',
     667            'dialogue_voucher_code_claim_limit_overflow' => 'The voucher code cannot not be claimed, the allowed maximum number of claims has been exceeded.',
     668            'dialogue_voucher_code_invalid' => 'The voucher code is invalid.',
     669            'dialogue_voucher_code_not_applicable' => 'The voucher code can only be redeemed on a new subscription or product.',
     670            'dialogue_voucher_code_not_claimed' => 'The voucher code cannot not be claimed, likely it has already been used.',
     671            'dialogue_voucher_code_product_intersect_not_allowed' => 'The voucher code cannot be applied to all of the selected products.',
     672            'dialogue_voucher_code_product_not_allowed' => 'The voucher code cannot be claimed in combination with selected products.',
     673            'dialogue_voucher_code_product_type_not_allowed' => 'The voucher code cannot be applied to the type of one or more selected products.',
     674            'dialogue_voucher_code_subscription_not_allowed' => 'The voucher code cannot be claimed in combination with selected subscription.',
     675            'dialogue_voucher_code_usage_not_allowed' => 'Usage of this voucher code is not allowed',
     676            'dialogue_voucher_code_user_email_not_allowed' => 'The voucher code cannot be claimed in combination with your current e-mail address.',
     677            'dialogue_voucher_code_user_subscription_not_allowed' => 'The voucher code cannot be claimed in combination with your already existing subscription.',
     678
    669679            'form_toggle_off' => 'Off',
    670680            'form_toggle_on' => 'On',
  • audienceplayer/tags/6.0.0/src/AudiencePlayer/AudiencePlayerWordpressPlugin/Config/Constants.php

    r3093691 r3298867  
    3939
    4040        // Main plugin version number here and in main plugin file header are automatically overwritten in gulp-build script
    41         PLUGIN_VERSION = '5.0.2',
     41        PLUGIN_VERSION = '6.0.0',
    4242
    4343        // DB migration version number is maintained here
  • audienceplayer/tags/6.0.0/static/html/admin_help_release_notes.html

    r3093691 r3298867  
    22
    33    <h3>Release notes</h3>
     4
     5    <div class="audienceplayer-release-note">
     6        <h5>v6.0.0</h5>
     7        <p class="date">2025-05-22</p>
     8        <p class="content">
     9            <br/>
     10        <u>☞ WARNING: major version update, observe possible breaking changes and as always, test thoroughly!</u>
     11        <ul>
     12            <li>
     13                Refactored all the deprecated AudiencePlayer API mutations and queries related to voucher validation and
     14                Product/Subscription acquisition (single new mutation: "UserPurchaseStackAcquire").
     15            </li>
     16            <li>
     17                Affected functions (argument changes):
     18                <ul>
     19                    <li>audienceplayer-core.js::openModalPurchase()</li>
     20                    <li>audienceplayer-core.js::validateVoucherCode()</li>
     21                    <li>audienceplayer-core.js::redeemUserAccountVoucherCode()</li>
     22                </ul>
     23            </li>
     24            <li>
     25                Affected shortcodes (which trigger the functions mentioned above):
     26                <ul>
     27                    <li>[audienceplayer_article_detail]</li>
     28                    <li>[audienceplayer_purchase_product_button]</li>
     29                    <li>[audienceplayer_purchase_subscriptions]</li>
     30                    <li>[audienceplayer_user_account]</li>
     31                </ul>
     32            </li>
     33            <li>
     34                New default translations were added to cover all known voucher error codes.
     35                If you overwrite translations in your own template (e.g. using
     36                "$AudiencePlayerWordpressPlugin->setTranslations([...])"), you might want to add the translations keys
     37                as well if necessary:
     38                <ul>
     39                    <li>'dialogue_voucher_code_claim_limit_overflow' : 'The voucher code cannot not be claimed, the
     40                        allowed maximum number of claims has been exceeded.'
     41                    </li>
     42                    <li>'dialogue_voucher_code_not_claimed' => 'The voucher code cannot not be claimed, likely it has
     43                        already been used.'
     44                    </li>
     45                    <li>'dialogue_voucher_code_product_intersect_not_allowed' => 'The voucher code cannot be applied to
     46                        all of the selected products.'
     47                    </li>
     48                    <li>'dialogue_voucher_code_product_not_allowed' => 'The voucher code cannot be claimed in
     49                        combination with selected products.'
     50                    </li>
     51                    <li>'dialogue_voucher_code_product_type_not_allowed' => 'The voucher code cannot be applied to the
     52                        type of one or more selected products.'
     53                    </li>
     54                    <li>'dialogue_voucher_code_subscription_not_allowed' => 'The voucher code cannot be claimed in
     55                        combination with selected subscription.'
     56                    </li>
     57                    <li>'dialogue_voucher_code_usage_not_allowed' => 'Usage of this voucher code is not allowed'</li>
     58                    <li>'dialogue_voucher_code_user_email_not_allowed' => 'The voucher code cannot be claimed in
     59                        combination with your current e-mail address.'
     60                    </li>
     61                    <li>'dialogue_voucher_code_user_subscription_not_allowed' => 'The voucher code cannot be claimed in
     62                        combination with your already existing subscription.'
     63                    </li>
     64                </ul>
     65            </li>
     66        </ul>
     67        </p>
     68    </div>
    469
    570    <div class="audienceplayer-release-note">
  • audienceplayer/tags/6.0.0/templates/audienceplayer-shortcode-purchase-product-button.php

    r2875369 r3298867  
    1515            'call_to_action_tag',
    1616            'price',
     17            'currency',
    1718            'currency_symbol',
    1819            'articles {id}'
     
    4546            $args['product_id'] . ',' .
    4647            "'" . $productDescription . "'," .
     48            "'" . ($product->currency ?: 'EUR') . "'," .
    4749            "'" . $productPrice . "'," .
     50            "1," .
    4851            (($args['show_voucher_validation'] ?? false) ? 'true' : 'false') . ',' .
    4952            $actionAuthentication . ',' .
  • audienceplayer/tags/6.0.0/templates/audienceplayer-shortcode-purchase-subscriptions.php

    r2916756 r3298867  
    5252                $subscription->id . ',' .
    5353                "'" . $AudiencePlayerWordpressPlugin->helper->sanitiseJsString($subscription->description_short ?: $subscription->description) . "'," .
     54                "'" . ($subscription->currency ?: 'EUR') . "'," .
    5455                "'" . $price . "'," .
     56                "1," .
    5557                (($args['show_voucher_validation'] ?? false) ? 'true' : 'false') . ',' .
    5658                $actionAuthentication . ',' .
  • audienceplayer/tags/6.0.0/templates/audienceplayer-shortcode-user-account.php

    r3048935 r3298867  
    2424                is_account_method_changeable
    2525                is_switchable
    26                 subscription {id title description_short}
     26                subscription {id title description_short currency currency_symbol}
    2727                account {id method method_details}
    2828            }
     
    235235            $content .= '<script>jQuery(function($){' .
    236236                '$("#audienceplayer-user-account-validate-voucher-button").click(function(){' .
    237                 'window.AudiencePlayerCore.redeemUserAccountVoucherCode(' .
    238                 'this,' .
    239                 '$("#audienceplayer-user-account-validate-voucher-input").val(),' .
    240                 $AudiencePlayerWordpressPlugin->fetchPaymentProviderId() . ',' .
    241                 ($validUserSubscription ? $validUserSubscription->subscription->id : 0) . ',' .
    242                 ($validUserSubscription ? $validUserSubscription->id : 0) .
    243                 ');' .
     237                'window.AudiencePlayerCore.redeemUserAccountVoucherCode(this, $("#audienceplayer-user-account-validate-voucher-input").val());' .
    244238                '});' .
    245239                '});</script>';
     
    315309                    '<div><a href="javascript:void(0);" onclick="window.AudiencePlayerCore.openModalPurchase(this, \'payment_method\',' .
    316310                    $validUserSubscription->account->id . ',' .
    317                     'window.AudiencePlayerCore.CONFIG.translations.dialogue_payment_method_change_cost_explanation,' .
    318                     'false' .
     311                    'window.AudiencePlayerCore.CONFIG.translations.dialogue_payment_method_change_cost_explanation' .
    319312                    ');">' . $AudiencePlayerWordpressPlugin->fetchTranslations('dialogue_payment_method_change') . '</a></div>';
    320313
     
    325318                    '<div><a href="javascript:void(0);" onclick="window.AudiencePlayerCore.openModalPurchase(this, \'payment_method\',' .
    326319                    $validUserSubscription->account->id . ',' .
    327                     'window.AudiencePlayerCore.CONFIG.translations.dialogue_payment_method_change_cost_explanation,' .
    328                     'false' .
     320                    'window.AudiencePlayerCore.CONFIG.translations.dialogue_payment_method_change_cost_explanation' .
    329321                    ');">' . $AudiencePlayerWordpressPlugin->fetchTranslations('dialogue_payment_method_add') . '</a></div>';
    330322            }
  • audienceplayer/tags/6.0.0/templates/js/audienceplayer-core.js

    r3068993 r3298867  
    2222                operation: 'query{UserDetails{id,nomadic_articles{id,appr},history_articles{id,appr},entitled_articles{id},user_subscriptions{id,subscription_id,is_valid}}}'
    2323            },
     24        },
     25
     26        ERROR_CODE_TRANSLATIONS: {
     27            3600: 'dialogue_voucher_code_invalid',
     28            3601: 'dialogue_general_payment_error',
     29            3602: 'dialogue_voucher_code_not_applicable',
     30            3603: 'dialogue_voucher_code_applicable_subscription_unknown',
     31            3604: 'dialogue_voucher_code_not_applicable',
     32            3605: 'dialogue_voucher_code_usage_not_allowed',
     33            3606: 'dialogue_amount_balance_usage_not_allowed',
     34            3607: 'dialogue_voucher_code_claim_limit_overflow',
     35            3608: 'dialogue_voucher_code_user_email_not_allowed',
     36            3609: 'dialogue_voucher_code_subscription_not_allowed',
     37            3610: 'dialogue_voucher_code_user_subscription_not_allowed',
     38            3611: 'dialogue_voucher_code_product_not_allowed',
     39            3612: 'dialogue_voucher_code_product_intersect_not_allowed',
     40            3613: 'dialogue_voucher_code_product_type_not_allowed'
    2441        },
    2542
     
    375392         * @param resourceId
    376393         * @param message
     394         * @param currency
    377395         * @param price
     396         * @param purchaseNum
    378397         * @param isVoucherValidation
    379          */
    380         openModalPurchase: function (event, type, resourceId, message, price, isVoucherValidation) {
    381 
    382             let self = this;
     398         * @returns {boolean}
     399         */
     400        openModalPurchase: function (event, type, resourceId, message, currency, price, purchaseNum, isVoucherValidation) {
     401
     402            let self = this;
     403            purchaseNum = parseInt(purchaseNum) ? parseInt(purchaseNum) : 1;
    383404
    384405            // Check browser support before opening modal
     
    419440
    420441                let onSuccessCallback = function (response) {
    421                     if (response.data.PaymentArgumentsValidate) {
     442                    if (response.data.UserPurchaseIntentAcquire) {
    422443                        $validationResult.removeClass('error');
    423                         $validationResult.html(response.data.PaymentArgumentsValidate.voucher_description);
    424                         $price.html(response.data.PaymentArgumentsValidate.currency_symbol + ' ' + response.data.PaymentArgumentsValidate.total_price_after);
     444                        $validationResult.html(response.data['UserPurchaseIntentAcquire'].description);
     445                        $price.html(response.data['UserPurchaseIntentAcquire'].currency_symbol + ' ' + response.data['UserPurchaseIntentAcquire'].printable_price);
    425446                    }
    426447                };
    427448
    428449                let onFailureCallback = function (response) {
    429                     let errorMsg = response.responseJSON.errors[0].message;
    430                     let errorCode = response.responseJSON.errors[0].code;
    431                     if (errorCode === 400) {
    432                         errorMsg = self.parseTranslationKey('dialogue_voucher_code_invalid');
    433                     }
     450                    let errorResponse = self.parseGraphqlErrorResponse(response);
     451                    let errorMsg = self.parseErrorCodeTranslationKey(errorResponse.code, 'dialogue_voucher_code_invalid') ?
     452                        self.parseTranslationKey(self.parseErrorCodeTranslationKey(errorResponse.code, 'dialogue_voucher_code_invalid')) :
     453                        errorResponse.message;
     454
    434455                    // show validation result inline
    435456                    $validationResult.addClass('error');
     
    437458                };
    438459
    439                 let argsString = 'product_stack:[{purchase_num:1,id:' + resourceId + '}]';
    440 
    441                 if (type === 'subscription') {
    442                     argsString = 'subscription_id:' + resourceId;
    443                 }
    444 
    445460                $validateButton.click(function () {
    446461                    self.validateVoucherCode(
    447462                        $validateButton,
    448463                        $voucherCodeInput.val(),
    449                         argsString,
    450                         false,
     464                        '[{id:' + resourceId + ',currency:' + currency + ',resource_type:' + type + ',purchase_num:' + purchaseNum + '}]',
    451465                        onSuccessCallback,
    452466                        onFailureCallback
     
    467481                }
    468482
    469                 let voucherCodeOperation = $voucherCodeInput.val() ?
    470                     ',voucher_code:"' + $voucherCodeInput.val() + '"' :
    471                     '';
    472 
    473483                let operation = '';
    474484                let responseProperty = '';
     485                let voucherCodeOperation = $voucherCodeInput.val() ?
     486                    'voucher_code:"' + $voucherCodeInput.val() + '"' :
     487                    '';
    475488
    476489                switch (type) {
    477490
    478491                    case 'product':
    479                         operation = 'mutation{UserProductAcquire(' +
    480                             'payment_provider_id:' + self.CONFIG.paymentProviderId +
    481                             ',product_stack:[{purchase_num:1,id:' + resourceId + '}]' +
     492                    case 'subscription':
     493                        operation = 'mutation{UserPurchaseIntentAcquire(' +
    482494                            voucherCodeOperation +
     495                            ',is_execute_dry_run:false' +
     496                            ',operator_context:web' +
     497                            ',purchase_intent_stack:' + '[{id:' + resourceId + ',currency:' + currency + ',resource_type:' + type + ',purchase_num:' + purchaseNum + '}]' +
    483498                            ',redirect_url_path:"' + self.fetchCurrentUrl({product_id: resourceId}, afterPurchaseRedirectAction, ['purchase_product_id', 'purchase_subscription_id']) + '"' +
    484499                            '){payment_url}}';
    485                         responseProperty = 'UserProductAcquire';
    486                         break;
    487 
    488                     case 'subscription':
    489                         operation = 'mutation{UserSubscriptionAcquire(' +
    490                             'payment_provider_id:' + self.CONFIG.paymentProviderId +
    491                             ',subscription_id:' + resourceId +
    492                             voucherCodeOperation +
    493                             ',redirect_url_path:"' + self.fetchCurrentUrl({subscription_id: resourceId}, afterPurchaseRedirectAction, ['purchase_product_id', 'purchase_subscription_id']) + '"' +
    494                             '){payment_url}}';
    495                         responseProperty = 'UserSubscriptionAcquire';
     500                        responseProperty = 'UserPurchaseIntentAcquire';
    496501                        break;
    497502
     
    519524                        if (response.data[responseProperty].payment_url) {
    520525                            // redirect to payment provider
     526                            self.closeModal();
    521527                            window.location.replace(response.data[responseProperty].payment_url);
    522528                        } else {
     
    536542                        self.toggleElementIsWorking([$acceptButton], false);
    537543
    538                         let errorMsg = response.responseJSON.errors[0].message;
    539                         let errorCode = response.responseJSON.errors[0].code;
    540                         if (errorCode === 3600) {
    541                             errorMsg = self.parseTranslationKey('dialogue_voucher_code_invalid');
    542                         }
     544                        let errorResponse = self.parseGraphqlErrorResponse(response);
     545                        let errorMsg = self.parseErrorCodeTranslationKey(errorResponse.code) ?
     546                            self.parseTranslationKey(self.parseErrorCodeTranslationKey(errorResponse.code)) :
     547                            errorResponse.message;
    543548
    544549                        self.handleApiErrorCallback(
    545550                            event,
    546551                            errorMsg,
    547                             errorCode,
     552                            errorResponse.code,
    548553                            callbackNonAuthenticated,
    549554                            callbackNonAuthorised,
     
    808813         * @param $validateButton
    809814         * @param voucherCode
    810          * @param argsString
    811          * @param isSoloValidation
     815         * @param purchaseIntentStack
    812816         * @param onSuccessCallback
    813817         * @param onFailureCallback
    814818         */
    815         validateVoucherCode: function ($validateButton, voucherCode, argsString, isSoloValidation, onSuccessCallback, onFailureCallback) {
     819        validateVoucherCode: function ($validateButton, voucherCode, purchaseIntentStack, onSuccessCallback, onFailureCallback) {
    816820
    817821            let self = this;
     
    823827            }
    824828
    825             if (isSoloValidation) {
    826                 argsString = argsString ? argsString + ',is_solo_validation:true' : 'is_solo_validation:true';
    827             } else {
    828                 argsString = argsString ? argsString + ',is_solo_validation:false' : 'is_solo_validation:false';
    829             }
     829            voucherCode = voucherCode ? voucherCode.trim() : '';
    830830
    831831            if (voucherCode) {
    832832
    833                 let operation = 'query{PaymentArgumentsValidate(' +
    834                     'voucher_code:"' + voucherCode + '",' + argsString +
    835                     '){voucher_validity,voucher_description,total_price_after,currency,currency_symbol}}';
     833                let operation = 'mutation{UserPurchaseIntentAcquire(' +
     834                    'is_execute_dry_run:true' +
     835                    ',operator_context:web' +
     836                    ',purchase_intent_stack:' + (purchaseIntentStack ? purchaseIntentStack : '[]') +
     837                    ',voucher_code:"' + voucherCode + '"' +
     838                    '){' +
     839                    'validation_messages{message,code}' +
     840                    ',description,price,printable_price,price_before,price_voucher_diff,validation_status,currency,currency_symbol}' +
     841                    '}';
    836842
    837843                self.callApi(
     
    841847                    function (response) {
    842848                        self.toggleElementIsWorking([$validateButton], false);
    843                         // Acquisition was successful
    844                         onSuccessCallback(response);
     849                        if (response.data['UserPurchaseIntentAcquire'].validation_messages.length) {
     850                            // Validation messages detected on dry-run, mark as failure
     851                            onFailureCallback(response);
     852                        } else {
     853                            // Acquisition was successful
     854                            onSuccessCallback(response);
     855                        }
    845856                    },
    846857                    function (response) {
     
    13181329         * @param event
    13191330         * @param voucherCode
    1320          * @param paymentProviderId
    1321          * @param subscriptionId
    1322          * @param userSubscriptionId
    1323          */
    1324         redeemUserAccountVoucherCode: function (event, voucherCode, paymentProviderId, subscriptionId, userSubscriptionId) {
     1331         */
     1332        redeemUserAccountVoucherCode: function (event, voucherCode) {
    13251333
    13261334            let self = this;
    13271335            let $validateButton = $(event);
    1328 
    1329             voucherCode = voucherCode.trim();
     1336            voucherCode = voucherCode ? voucherCode.trim() : '';
     1337
     1338            let onFailureCallback = function (response) {
     1339
     1340                let errorResponse = self.parseGraphqlErrorResponse(response);
     1341                if (self.parseErrorCodeTranslationKey(errorResponse.code)) {
     1342                    self.openModalErrorMessage(self.parseTranslationKey(self.parseErrorCodeTranslationKey(errorResponse.code, 'dialogue_voucher_code_invalid')), errorResponse.code);
     1343                } else if (errorResponse.code === 422) {
     1344                    self.openModalErrorMessage(self.parseTranslationKey('dialogue_voucher_code_applicable_subscription_unknown'), errorResponse.code);
     1345                } else {
     1346                    self.handleApiErrorCallback(event, errorResponse.message, errorResponse.code);
     1347                }
     1348
     1349            };
    13301350
    13311351            let onSuccessCallback = function (response) {
     
    13331353                self.openModalAlert(
    13341354                    null,
    1335                     response.data['PaymentArgumentsValidate'].voucher_description,
     1355                    response.data['UserPurchaseIntentAcquire'].description,
    13361356                    self.parseTranslationKey('button_payment_accept_complete'),
    13371357                    function (event, $modalButton) {
     
    13431363                        }
    13441364
    1345                         let operation = 'mutation{UserPaymentVoucherRedeem(' +
    1346                             'code:"' + voucherCode + '",' +
    1347                             'payment_provider_id:' + paymentProviderId + ',' +
    1348                             'subscription_id:' + subscriptionId + ',' +
    1349                             'user_subscription_id:' + userSubscriptionId + ',' +
    1350                             'redirect_url_path:"' + self.fetchCurrentUrl() + '"' +
     1365                        let operation = 'mutation{UserPurchaseIntentAcquire(' +
     1366                            'is_execute_dry_run:false' +
     1367                            ',operator_context:web' +
     1368                            ',purchase_intent_stack:[]' +
     1369                            ',voucher_code:"' + voucherCode + '"' +
     1370                            ',redirect_url_path:"' + self.fetchCurrentUrl() + '"' +
    13511371                            '){payment_url}}';
    13521372
     
    13621382
    13631383                                // Acquisition was successful
    1364                                 if (response.data['UserPaymentVoucherRedeem'].payment_url) {
     1384                                if (response.data['UserPurchaseIntentAcquire'].payment_url) {
    13651385                                    // redirect to payment provider
    1366                                     window.location.replace(response.data['UserPaymentVoucherRedeem'].payment_url);
     1386                                    window.location.replace(response.data['UserPurchaseIntentAcquire'].payment_url);
    13671387                                } else {
    13681388                                    // payment is not necessary
     
    13791399                            function (response) {
    13801400                                self.toggleElementIsWorking([$modalButton], false);
    1381 
    1382                                 let errorMsg = response.responseJSON.errors[0].message;
    1383                                 let errorCode = response.responseJSON.errors[0].code;
    1384                                 if (errorCode === 422) {
    1385                                     self.openModalErrorMessage(self.parseTranslationKey('dialogue_voucher_code_applicable_subscription_unknown'), errorCode);
    1386                                 } else if (errorCode === 3600) {
    1387                                     self.openModalErrorMessage(self.parseTranslationKey('dialogue_voucher_code_invalid'), errorCode);
    1388                                 } else if (errorCode >= 400) {
    1389                                     self.openModalErrorMessage(self.parseTranslationKey('dialogue_voucher_code_not_applicable'), errorCode);
    1390                                 } else {
    1391                                     self.handleApiErrorCallback(event, errorMsg, errorCode);
    1392                                 }
     1401                                onFailureCallback(response);
    13931402                            }
    13941403                        );
     
    13971406            };
    13981407
    1399             let onFailureCallback = function (response) {
    1400 
    1401                 let errorMsg = response.responseJSON.errors[0].message;
    1402                 let errorCode = response.responseJSON.errors[0].code;
    1403                 if (errorCode === 422) {
    1404                     self.openModalErrorMessage(self.parseTranslationKey('dialogue_voucher_code_applicable_subscription_unknown'), errorCode);
    1405                 } else if (errorCode === 3600) {
    1406                     self.openModalErrorMessage(self.parseTranslationKey('dialogue_voucher_code_invalid'), errorCode);
    1407                 } else if (errorCode >= 400) {
    1408                     self.openModalErrorMessage(self.parseTranslationKey('dialogue_voucher_code_not_applicable'), errorCode);
    1409                 } else {
    1410                     self.handleApiErrorCallback(event, errorMsg, errorCode);
    1411                 }
    1412 
    1413             };
    1414 
    1415             self.validateVoucherCode($validateButton, voucherCode, 'subscription_id:' + subscriptionId, true, onSuccessCallback, onFailureCallback);
     1408            self.validateVoucherCode($validateButton, voucherCode, '[]', onSuccessCallback, onFailureCallback);
    14161409        },
    14171410
     
    17071700        parseTranslationKey: function (key, vars) {
    17081701            return this.parseTranslation(this.CONFIG.translations[key], vars);
     1702        },
     1703
     1704        parseErrorCodeTranslationKey: function (errorCode, fallbackTranslation) {
     1705            return this.ERROR_CODE_TRANSLATIONS[errorCode] ?
     1706                this.ERROR_CODE_TRANSLATIONS[errorCode] :
     1707                (fallbackTranslation = fallbackTranslation ? fallbackTranslation.trim() : '');
     1708        },
     1709
     1710        parseGraphqlErrorResponse: function (response) {
     1711
     1712            let errorMessage = response.statusText;
     1713            let errorCode = response.status;
     1714
     1715            if (response.responseJSON && response.responseJSON.errors) {
     1716                errorMessage = response.responseJSON.errors[0].message;
     1717                errorCode = response.responseJSON.errors[0].code;
     1718            } else if (response.data['UserPurchaseIntentAcquire'] && response.data['UserPurchaseIntentAcquire'].validation_messages.length) {
     1719                errorMessage = response.data['UserPurchaseIntentAcquire'].validation_messages[0].message;
     1720                errorCode = response.data['UserPurchaseIntentAcquire'].validation_messages[0].code;
     1721            }
     1722
     1723            return {
     1724                message: errorMessage,
     1725                code: errorCode,
     1726            };
    17091727        }
    17101728
  • audienceplayer/tags/6.0.0/vendor/autoload.php

    r3048935 r3298867  
    2323require_once __DIR__ . '/composer/autoload_real.php';
    2424
    25 return ComposerAutoloaderInit5cfc594734f281b302e98f3d5dfebf3e::getLoader();
     25return ComposerAutoloaderInita6d20a7c9bc887ce3cb59346b319f6dd::getLoader();
  • audienceplayer/tags/6.0.0/vendor/composer/InstalledVersions.php

    r2945999 r3298867  
    3232     */
    3333    private static $installed;
     34
     35    /**
     36     * @var bool
     37     */
     38    private static $installedIsLocalDir;
    3439
    3540    /**
     
    310315        self::$installed = $data;
    311316        self::$installedByVendor = array();
     317
     318        // when using reload, we disable the duplicate protection to ensure that self::$installed data is
     319        // always returned, but we cannot know whether it comes from the installed.php in __DIR__ or not,
     320        // so we have to assume it does not, and that may result in duplicate data being returned when listing
     321        // all installed packages for example
     322        self::$installedIsLocalDir = false;
    312323    }
    313324
     
    323334
    324335        $installed = array();
     336        $copiedLocalDir = false;
    325337
    326338        if (self::$canGetVendors) {
     339            $selfDir = strtr(__DIR__, '\\', '/');
    327340            foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
     341                $vendorDir = strtr($vendorDir, '\\', '/');
    328342                if (isset(self::$installedByVendor[$vendorDir])) {
    329343                    $installed[] = self::$installedByVendor[$vendorDir];
     
    331345                    /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
    332346                    $required = require $vendorDir.'/composer/installed.php';
    333                     $installed[] = self::$installedByVendor[$vendorDir] = $required;
    334                     if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
    335                         self::$installed = $installed[count($installed) - 1];
     347                    self::$installedByVendor[$vendorDir] = $required;
     348                    $installed[] = $required;
     349                    if (self::$installed === null && $vendorDir.'/composer' === $selfDir) {
     350                        self::$installed = $required;
     351                        self::$installedIsLocalDir = true;
    336352                    }
     353                }
     354                if (self::$installedIsLocalDir && $vendorDir.'/composer' === $selfDir) {
     355                    $copiedLocalDir = true;
    337356                }
    338357            }
     
    351370        }
    352371
    353         if (self::$installed !== array()) {
     372        if (self::$installed !== array() && !$copiedLocalDir) {
    354373            $installed[] = self::$installed;
    355374        }
  • audienceplayer/tags/6.0.0/vendor/composer/autoload_real.php

    r3048935 r3298867  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInit5cfc594734f281b302e98f3d5dfebf3e
     5class ComposerAutoloaderInita6d20a7c9bc887ce3cb59346b319f6dd
    66{
    77    private static $loader;
     
    2525        require __DIR__ . '/platform_check.php';
    2626
    27         spl_autoload_register(array('ComposerAutoloaderInit5cfc594734f281b302e98f3d5dfebf3e', 'loadClassLoader'), true, true);
     27        spl_autoload_register(array('ComposerAutoloaderInita6d20a7c9bc887ce3cb59346b319f6dd', 'loadClassLoader'), true, true);
    2828        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
    29         spl_autoload_unregister(array('ComposerAutoloaderInit5cfc594734f281b302e98f3d5dfebf3e', 'loadClassLoader'));
     29        spl_autoload_unregister(array('ComposerAutoloaderInita6d20a7c9bc887ce3cb59346b319f6dd', 'loadClassLoader'));
    3030
    3131        require __DIR__ . '/autoload_static.php';
    32         call_user_func(\Composer\Autoload\ComposerStaticInit5cfc594734f281b302e98f3d5dfebf3e::getInitializer($loader));
     32        call_user_func(\Composer\Autoload\ComposerStaticInita6d20a7c9bc887ce3cb59346b319f6dd::getInitializer($loader));
    3333
    3434        $loader->register(true);
  • audienceplayer/tags/6.0.0/vendor/composer/autoload_static.php

    r3048935 r3298867  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInit5cfc594734f281b302e98f3d5dfebf3e
     7class ComposerStaticInita6d20a7c9bc887ce3cb59346b319f6dd
    88{
    99    public static $prefixLengthsPsr4 = array (
     
    3838    {
    3939        return \Closure::bind(function () use ($loader) {
    40             $loader->prefixLengthsPsr4 = ComposerStaticInit5cfc594734f281b302e98f3d5dfebf3e::$prefixLengthsPsr4;
    41             $loader->prefixDirsPsr4 = ComposerStaticInit5cfc594734f281b302e98f3d5dfebf3e::$prefixDirsPsr4;
    42             $loader->classMap = ComposerStaticInit5cfc594734f281b302e98f3d5dfebf3e::$classMap;
     40            $loader->prefixLengthsPsr4 = ComposerStaticInita6d20a7c9bc887ce3cb59346b319f6dd::$prefixLengthsPsr4;
     41            $loader->prefixDirsPsr4 = ComposerStaticInita6d20a7c9bc887ce3cb59346b319f6dd::$prefixDirsPsr4;
     42            $loader->classMap = ComposerStaticInita6d20a7c9bc887ce3cb59346b319f6dd::$classMap;
    4343
    4444        }, null, ClassLoader::class);
  • audienceplayer/tags/6.0.0/vendor/composer/installed.php

    r3093691 r3298867  
    44        'pretty_version' => 'dev-master',
    55        'version' => 'dev-master',
    6         'reference' => '29f460d6d43eb9169464315fc26de985a96e91dd',
     6        'reference' => '3374afa17e8b39c6498b92b0a5aa363da5ac162b',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    2323            'pretty_version' => 'dev-master',
    2424            'version' => 'dev-master',
    25             'reference' => '29f460d6d43eb9169464315fc26de985a96e91dd',
     25            'reference' => '3374afa17e8b39c6498b92b0a5aa363da5ac162b',
    2626            'type' => 'wordpress-plugin',
    2727            'install_path' => __DIR__ . '/../../',
  • audienceplayer/trunk/audienceplayer.php

    r3093691 r3298867  
    99Description: AudiencePlayer integration
    1010Author: AudiencePlayer
    11 Version: 5.0.2
     11Version: 6.0.0
    1212Author URI: https://www.audienceplayer.com
    1313Text Domain: audienceplayer
  • audienceplayer/trunk/composer.lock

    r3093691 r3298867  
    6767        {
    6868            "name": "phpstan/phpstan",
    69             "version": "1.11.2",
     69            "version": "1.12.27",
    7070            "source": {
    7171                "type": "git",
    7272                "url": "https://github.com/phpstan/phpstan.git",
    73                 "reference": "0d5d4294a70deb7547db655c47685d680e39cfec"
     73                "reference": "3a6e423c076ab39dfedc307e2ac627ef579db162"
    7474            },
    7575            "dist": {
    7676                "type": "zip",
    77                 "url": "https://api.github.com/repos/phpstan/phpstan/zipball/0d5d4294a70deb7547db655c47685d680e39cfec",
    78                 "reference": "0d5d4294a70deb7547db655c47685d680e39cfec",
     77                "url": "https://api.github.com/repos/phpstan/phpstan/zipball/3a6e423c076ab39dfedc307e2ac627ef579db162",
     78                "reference": "3a6e423c076ab39dfedc307e2ac627ef579db162",
    7979                "shasum": ""
    8080            },
     
    121121                }
    122122            ],
    123             "time": "2024-05-24T13:23:04+00:00"
     123            "time": "2025-05-21T20:51:45+00:00"
    124124        }
    125125    ],
    126126    "aliases": [],
    127127    "minimum-stability": "stable",
    128     "stability-flags": [],
     128    "stability-flags": {},
    129129    "prefer-stable": false,
    130130    "prefer-lowest": false,
     
    134134        "ext-json": "*"
    135135    },
    136     "platform-dev": [],
     136    "platform-dev": {},
    137137    "plugin-api-version": "2.6.0"
    138138}
  • audienceplayer/trunk/languages/audienceplayer-wordpress-plugin.pot

    r3093691 r3298867  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: 5.0.2\n"
     5"Project-Id-Version: 6.0.0\n"
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/audienceplayer\n"
    77"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
  • audienceplayer/trunk/readme.txt

    r3093691 r3298867  
    11=== AudiencePlayer ===
    22Contributors: audienceplayer
    3 Stable tag: 5.0.2
    4 Tested up to: 6.5
     3Stable tag: 6.0.0
     4Tested up to: 6.8
    55Requires at least: 5.5
    66Requires PHP: 7.1
     
    2222This plugin relies on the following external AudiencePlayer libraries, via which user profile data is exchanged with the AudiencePlayer Backend:
    2323
    24 1. **AudiencePlayer Ap wrapper library for PHP**
     241. **AudiencePlayer API wrapper library for PHP**
    2525  * link: [https://github.com/AudiencePlayer/audienceplayer-api-client-php](https://github.com/AudiencePlayer/audienceplayer-api-client-php)
    2626  * license: [https://github.com/AudiencePlayer/audienceplayer-api-client-php/blob/master/LICENSE](https://github.com/AudiencePlayer/audienceplayer-api-client-php/blob/master/LICENSE)
  • audienceplayer/trunk/src/AudiencePlayer/AudiencePlayerWordpressPlugin/AudiencePlayerWordpressPlugin.php

    r3068993 r3298867  
    664664            'dialogue_user_subscription_will_switch_at_renewal' => '→ At the next renewal date, your subscription will switch to "{{ subscription_title }}"',
    665665            'dialogue_video_not_available_in_region' => 'The content is not available in your current country or region.',
    666             'dialogue_voucher_code_invalid' => 'Voucher code is not valid.',
    667             'dialogue_voucher_code_not_applicable' => 'Voucher code is not valid or cannot be applied on current subscription.',
    668             'dialogue_voucher_code_applicable_subscription_unknown' => 'This voucher can only be applied to an already existing subscription or when purchasing a new subscription.',
     666            'dialogue_voucher_code_applicable_subscription_unknown' => 'This voucher code can only be applied to an already existing subscription or when purchasing a new subscription.',
     667            'dialogue_voucher_code_claim_limit_overflow' => 'The voucher code cannot not be claimed, the allowed maximum number of claims has been exceeded.',
     668            'dialogue_voucher_code_invalid' => 'The voucher code is invalid.',
     669            'dialogue_voucher_code_not_applicable' => 'The voucher code can only be redeemed on a new subscription or product.',
     670            'dialogue_voucher_code_not_claimed' => 'The voucher code cannot not be claimed, likely it has already been used.',
     671            'dialogue_voucher_code_product_intersect_not_allowed' => 'The voucher code cannot be applied to all of the selected products.',
     672            'dialogue_voucher_code_product_not_allowed' => 'The voucher code cannot be claimed in combination with selected products.',
     673            'dialogue_voucher_code_product_type_not_allowed' => 'The voucher code cannot be applied to the type of one or more selected products.',
     674            'dialogue_voucher_code_subscription_not_allowed' => 'The voucher code cannot be claimed in combination with selected subscription.',
     675            'dialogue_voucher_code_usage_not_allowed' => 'Usage of this voucher code is not allowed',
     676            'dialogue_voucher_code_user_email_not_allowed' => 'The voucher code cannot be claimed in combination with your current e-mail address.',
     677            'dialogue_voucher_code_user_subscription_not_allowed' => 'The voucher code cannot be claimed in combination with your already existing subscription.',
     678
    669679            'form_toggle_off' => 'Off',
    670680            'form_toggle_on' => 'On',
  • audienceplayer/trunk/src/AudiencePlayer/AudiencePlayerWordpressPlugin/Config/Constants.php

    r3093691 r3298867  
    3939
    4040        // Main plugin version number here and in main plugin file header are automatically overwritten in gulp-build script
    41         PLUGIN_VERSION = '5.0.2',
     41        PLUGIN_VERSION = '6.0.0',
    4242
    4343        // DB migration version number is maintained here
  • audienceplayer/trunk/static/html/admin_help_release_notes.html

    r3093691 r3298867  
    22
    33    <h3>Release notes</h3>
     4
     5    <div class="audienceplayer-release-note">
     6        <h5>v6.0.0</h5>
     7        <p class="date">2025-05-22</p>
     8        <p class="content">
     9            <br/>
     10        <u>☞ WARNING: major version update, observe possible breaking changes and as always, test thoroughly!</u>
     11        <ul>
     12            <li>
     13                Refactored all the deprecated AudiencePlayer API mutations and queries related to voucher validation and
     14                Product/Subscription acquisition (single new mutation: "UserPurchaseStackAcquire").
     15            </li>
     16            <li>
     17                Affected functions (argument changes):
     18                <ul>
     19                    <li>audienceplayer-core.js::openModalPurchase()</li>
     20                    <li>audienceplayer-core.js::validateVoucherCode()</li>
     21                    <li>audienceplayer-core.js::redeemUserAccountVoucherCode()</li>
     22                </ul>
     23            </li>
     24            <li>
     25                Affected shortcodes (which trigger the functions mentioned above):
     26                <ul>
     27                    <li>[audienceplayer_article_detail]</li>
     28                    <li>[audienceplayer_purchase_product_button]</li>
     29                    <li>[audienceplayer_purchase_subscriptions]</li>
     30                    <li>[audienceplayer_user_account]</li>
     31                </ul>
     32            </li>
     33            <li>
     34                New default translations were added to cover all known voucher error codes.
     35                If you overwrite translations in your own template (e.g. using
     36                "$AudiencePlayerWordpressPlugin->setTranslations([...])"), you might want to add the translations keys
     37                as well if necessary:
     38                <ul>
     39                    <li>'dialogue_voucher_code_claim_limit_overflow' : 'The voucher code cannot not be claimed, the
     40                        allowed maximum number of claims has been exceeded.'
     41                    </li>
     42                    <li>'dialogue_voucher_code_not_claimed' => 'The voucher code cannot not be claimed, likely it has
     43                        already been used.'
     44                    </li>
     45                    <li>'dialogue_voucher_code_product_intersect_not_allowed' => 'The voucher code cannot be applied to
     46                        all of the selected products.'
     47                    </li>
     48                    <li>'dialogue_voucher_code_product_not_allowed' => 'The voucher code cannot be claimed in
     49                        combination with selected products.'
     50                    </li>
     51                    <li>'dialogue_voucher_code_product_type_not_allowed' => 'The voucher code cannot be applied to the
     52                        type of one or more selected products.'
     53                    </li>
     54                    <li>'dialogue_voucher_code_subscription_not_allowed' => 'The voucher code cannot be claimed in
     55                        combination with selected subscription.'
     56                    </li>
     57                    <li>'dialogue_voucher_code_usage_not_allowed' => 'Usage of this voucher code is not allowed'</li>
     58                    <li>'dialogue_voucher_code_user_email_not_allowed' => 'The voucher code cannot be claimed in
     59                        combination with your current e-mail address.'
     60                    </li>
     61                    <li>'dialogue_voucher_code_user_subscription_not_allowed' => 'The voucher code cannot be claimed in
     62                        combination with your already existing subscription.'
     63                    </li>
     64                </ul>
     65            </li>
     66        </ul>
     67        </p>
     68    </div>
    469
    570    <div class="audienceplayer-release-note">
  • audienceplayer/trunk/templates/audienceplayer-shortcode-purchase-product-button.php

    r2875369 r3298867  
    1515            'call_to_action_tag',
    1616            'price',
     17            'currency',
    1718            'currency_symbol',
    1819            'articles {id}'
     
    4546            $args['product_id'] . ',' .
    4647            "'" . $productDescription . "'," .
     48            "'" . ($product->currency ?: 'EUR') . "'," .
    4749            "'" . $productPrice . "'," .
     50            "1," .
    4851            (($args['show_voucher_validation'] ?? false) ? 'true' : 'false') . ',' .
    4952            $actionAuthentication . ',' .
  • audienceplayer/trunk/templates/audienceplayer-shortcode-purchase-subscriptions.php

    r2916756 r3298867  
    5252                $subscription->id . ',' .
    5353                "'" . $AudiencePlayerWordpressPlugin->helper->sanitiseJsString($subscription->description_short ?: $subscription->description) . "'," .
     54                "'" . ($subscription->currency ?: 'EUR') . "'," .
    5455                "'" . $price . "'," .
     56                "1," .
    5557                (($args['show_voucher_validation'] ?? false) ? 'true' : 'false') . ',' .
    5658                $actionAuthentication . ',' .
  • audienceplayer/trunk/templates/audienceplayer-shortcode-user-account.php

    r3048935 r3298867  
    2424                is_account_method_changeable
    2525                is_switchable
    26                 subscription {id title description_short}
     26                subscription {id title description_short currency currency_symbol}
    2727                account {id method method_details}
    2828            }
     
    235235            $content .= '<script>jQuery(function($){' .
    236236                '$("#audienceplayer-user-account-validate-voucher-button").click(function(){' .
    237                 'window.AudiencePlayerCore.redeemUserAccountVoucherCode(' .
    238                 'this,' .
    239                 '$("#audienceplayer-user-account-validate-voucher-input").val(),' .
    240                 $AudiencePlayerWordpressPlugin->fetchPaymentProviderId() . ',' .
    241                 ($validUserSubscription ? $validUserSubscription->subscription->id : 0) . ',' .
    242                 ($validUserSubscription ? $validUserSubscription->id : 0) .
    243                 ');' .
     237                'window.AudiencePlayerCore.redeemUserAccountVoucherCode(this, $("#audienceplayer-user-account-validate-voucher-input").val());' .
    244238                '});' .
    245239                '});</script>';
     
    315309                    '<div><a href="javascript:void(0);" onclick="window.AudiencePlayerCore.openModalPurchase(this, \'payment_method\',' .
    316310                    $validUserSubscription->account->id . ',' .
    317                     'window.AudiencePlayerCore.CONFIG.translations.dialogue_payment_method_change_cost_explanation,' .
    318                     'false' .
     311                    'window.AudiencePlayerCore.CONFIG.translations.dialogue_payment_method_change_cost_explanation' .
    319312                    ');">' . $AudiencePlayerWordpressPlugin->fetchTranslations('dialogue_payment_method_change') . '</a></div>';
    320313
     
    325318                    '<div><a href="javascript:void(0);" onclick="window.AudiencePlayerCore.openModalPurchase(this, \'payment_method\',' .
    326319                    $validUserSubscription->account->id . ',' .
    327                     'window.AudiencePlayerCore.CONFIG.translations.dialogue_payment_method_change_cost_explanation,' .
    328                     'false' .
     320                    'window.AudiencePlayerCore.CONFIG.translations.dialogue_payment_method_change_cost_explanation' .
    329321                    ');">' . $AudiencePlayerWordpressPlugin->fetchTranslations('dialogue_payment_method_add') . '</a></div>';
    330322            }
  • audienceplayer/trunk/templates/js/audienceplayer-core.js

    r3068993 r3298867  
    2222                operation: 'query{UserDetails{id,nomadic_articles{id,appr},history_articles{id,appr},entitled_articles{id},user_subscriptions{id,subscription_id,is_valid}}}'
    2323            },
     24        },
     25
     26        ERROR_CODE_TRANSLATIONS: {
     27            3600: 'dialogue_voucher_code_invalid',
     28            3601: 'dialogue_general_payment_error',
     29            3602: 'dialogue_voucher_code_not_applicable',
     30            3603: 'dialogue_voucher_code_applicable_subscription_unknown',
     31            3604: 'dialogue_voucher_code_not_applicable',
     32            3605: 'dialogue_voucher_code_usage_not_allowed',
     33            3606: 'dialogue_amount_balance_usage_not_allowed',
     34            3607: 'dialogue_voucher_code_claim_limit_overflow',
     35            3608: 'dialogue_voucher_code_user_email_not_allowed',
     36            3609: 'dialogue_voucher_code_subscription_not_allowed',
     37            3610: 'dialogue_voucher_code_user_subscription_not_allowed',
     38            3611: 'dialogue_voucher_code_product_not_allowed',
     39            3612: 'dialogue_voucher_code_product_intersect_not_allowed',
     40            3613: 'dialogue_voucher_code_product_type_not_allowed'
    2441        },
    2542
     
    375392         * @param resourceId
    376393         * @param message
     394         * @param currency
    377395         * @param price
     396         * @param purchaseNum
    378397         * @param isVoucherValidation
    379          */
    380         openModalPurchase: function (event, type, resourceId, message, price, isVoucherValidation) {
    381 
    382             let self = this;
     398         * @returns {boolean}
     399         */
     400        openModalPurchase: function (event, type, resourceId, message, currency, price, purchaseNum, isVoucherValidation) {
     401
     402            let self = this;
     403            purchaseNum = parseInt(purchaseNum) ? parseInt(purchaseNum) : 1;
    383404
    384405            // Check browser support before opening modal
     
    419440
    420441                let onSuccessCallback = function (response) {
    421                     if (response.data.PaymentArgumentsValidate) {
     442                    if (response.data.UserPurchaseIntentAcquire) {
    422443                        $validationResult.removeClass('error');
    423                         $validationResult.html(response.data.PaymentArgumentsValidate.voucher_description);
    424                         $price.html(response.data.PaymentArgumentsValidate.currency_symbol + ' ' + response.data.PaymentArgumentsValidate.total_price_after);
     444                        $validationResult.html(response.data['UserPurchaseIntentAcquire'].description);
     445                        $price.html(response.data['UserPurchaseIntentAcquire'].currency_symbol + ' ' + response.data['UserPurchaseIntentAcquire'].printable_price);
    425446                    }
    426447                };
    427448
    428449                let onFailureCallback = function (response) {
    429                     let errorMsg = response.responseJSON.errors[0].message;
    430                     let errorCode = response.responseJSON.errors[0].code;
    431                     if (errorCode === 400) {
    432                         errorMsg = self.parseTranslationKey('dialogue_voucher_code_invalid');
    433                     }
     450                    let errorResponse = self.parseGraphqlErrorResponse(response);
     451                    let errorMsg = self.parseErrorCodeTranslationKey(errorResponse.code, 'dialogue_voucher_code_invalid') ?
     452                        self.parseTranslationKey(self.parseErrorCodeTranslationKey(errorResponse.code, 'dialogue_voucher_code_invalid')) :
     453                        errorResponse.message;
     454
    434455                    // show validation result inline
    435456                    $validationResult.addClass('error');
     
    437458                };
    438459
    439                 let argsString = 'product_stack:[{purchase_num:1,id:' + resourceId + '}]';
    440 
    441                 if (type === 'subscription') {
    442                     argsString = 'subscription_id:' + resourceId;
    443                 }
    444 
    445460                $validateButton.click(function () {
    446461                    self.validateVoucherCode(
    447462                        $validateButton,
    448463                        $voucherCodeInput.val(),
    449                         argsString,
    450                         false,
     464                        '[{id:' + resourceId + ',currency:' + currency + ',resource_type:' + type + ',purchase_num:' + purchaseNum + '}]',
    451465                        onSuccessCallback,
    452466                        onFailureCallback
     
    467481                }
    468482
    469                 let voucherCodeOperation = $voucherCodeInput.val() ?
    470                     ',voucher_code:"' + $voucherCodeInput.val() + '"' :
    471                     '';
    472 
    473483                let operation = '';
    474484                let responseProperty = '';
     485                let voucherCodeOperation = $voucherCodeInput.val() ?
     486                    'voucher_code:"' + $voucherCodeInput.val() + '"' :
     487                    '';
    475488
    476489                switch (type) {
    477490
    478491                    case 'product':
    479                         operation = 'mutation{UserProductAcquire(' +
    480                             'payment_provider_id:' + self.CONFIG.paymentProviderId +
    481                             ',product_stack:[{purchase_num:1,id:' + resourceId + '}]' +
     492                    case 'subscription':
     493                        operation = 'mutation{UserPurchaseIntentAcquire(' +
    482494                            voucherCodeOperation +
     495                            ',is_execute_dry_run:false' +
     496                            ',operator_context:web' +
     497                            ',purchase_intent_stack:' + '[{id:' + resourceId + ',currency:' + currency + ',resource_type:' + type + ',purchase_num:' + purchaseNum + '}]' +
    483498                            ',redirect_url_path:"' + self.fetchCurrentUrl({product_id: resourceId}, afterPurchaseRedirectAction, ['purchase_product_id', 'purchase_subscription_id']) + '"' +
    484499                            '){payment_url}}';
    485                         responseProperty = 'UserProductAcquire';
    486                         break;
    487 
    488                     case 'subscription':
    489                         operation = 'mutation{UserSubscriptionAcquire(' +
    490                             'payment_provider_id:' + self.CONFIG.paymentProviderId +
    491                             ',subscription_id:' + resourceId +
    492                             voucherCodeOperation +
    493                             ',redirect_url_path:"' + self.fetchCurrentUrl({subscription_id: resourceId}, afterPurchaseRedirectAction, ['purchase_product_id', 'purchase_subscription_id']) + '"' +
    494                             '){payment_url}}';
    495                         responseProperty = 'UserSubscriptionAcquire';
     500                        responseProperty = 'UserPurchaseIntentAcquire';
    496501                        break;
    497502
     
    519524                        if (response.data[responseProperty].payment_url) {
    520525                            // redirect to payment provider
     526                            self.closeModal();
    521527                            window.location.replace(response.data[responseProperty].payment_url);
    522528                        } else {
     
    536542                        self.toggleElementIsWorking([$acceptButton], false);
    537543
    538                         let errorMsg = response.responseJSON.errors[0].message;
    539                         let errorCode = response.responseJSON.errors[0].code;
    540                         if (errorCode === 3600) {
    541                             errorMsg = self.parseTranslationKey('dialogue_voucher_code_invalid');
    542                         }
     544                        let errorResponse = self.parseGraphqlErrorResponse(response);
     545                        let errorMsg = self.parseErrorCodeTranslationKey(errorResponse.code) ?
     546                            self.parseTranslationKey(self.parseErrorCodeTranslationKey(errorResponse.code)) :
     547                            errorResponse.message;
    543548
    544549                        self.handleApiErrorCallback(
    545550                            event,
    546551                            errorMsg,
    547                             errorCode,
     552                            errorResponse.code,
    548553                            callbackNonAuthenticated,
    549554                            callbackNonAuthorised,
     
    808813         * @param $validateButton
    809814         * @param voucherCode
    810          * @param argsString
    811          * @param isSoloValidation
     815         * @param purchaseIntentStack
    812816         * @param onSuccessCallback
    813817         * @param onFailureCallback
    814818         */
    815         validateVoucherCode: function ($validateButton, voucherCode, argsString, isSoloValidation, onSuccessCallback, onFailureCallback) {
     819        validateVoucherCode: function ($validateButton, voucherCode, purchaseIntentStack, onSuccessCallback, onFailureCallback) {
    816820
    817821            let self = this;
     
    823827            }
    824828
    825             if (isSoloValidation) {
    826                 argsString = argsString ? argsString + ',is_solo_validation:true' : 'is_solo_validation:true';
    827             } else {
    828                 argsString = argsString ? argsString + ',is_solo_validation:false' : 'is_solo_validation:false';
    829             }
     829            voucherCode = voucherCode ? voucherCode.trim() : '';
    830830
    831831            if (voucherCode) {
    832832
    833                 let operation = 'query{PaymentArgumentsValidate(' +
    834                     'voucher_code:"' + voucherCode + '",' + argsString +
    835                     '){voucher_validity,voucher_description,total_price_after,currency,currency_symbol}}';
     833                let operation = 'mutation{UserPurchaseIntentAcquire(' +
     834                    'is_execute_dry_run:true' +
     835                    ',operator_context:web' +
     836                    ',purchase_intent_stack:' + (purchaseIntentStack ? purchaseIntentStack : '[]') +
     837                    ',voucher_code:"' + voucherCode + '"' +
     838                    '){' +
     839                    'validation_messages{message,code}' +
     840                    ',description,price,printable_price,price_before,price_voucher_diff,validation_status,currency,currency_symbol}' +
     841                    '}';
    836842
    837843                self.callApi(
     
    841847                    function (response) {
    842848                        self.toggleElementIsWorking([$validateButton], false);
    843                         // Acquisition was successful
    844                         onSuccessCallback(response);
     849                        if (response.data['UserPurchaseIntentAcquire'].validation_messages.length) {
     850                            // Validation messages detected on dry-run, mark as failure
     851                            onFailureCallback(response);
     852                        } else {
     853                            // Acquisition was successful
     854                            onSuccessCallback(response);
     855                        }
    845856                    },
    846857                    function (response) {
     
    13181329         * @param event
    13191330         * @param voucherCode
    1320          * @param paymentProviderId
    1321          * @param subscriptionId
    1322          * @param userSubscriptionId
    1323          */
    1324         redeemUserAccountVoucherCode: function (event, voucherCode, paymentProviderId, subscriptionId, userSubscriptionId) {
     1331         */
     1332        redeemUserAccountVoucherCode: function (event, voucherCode) {
    13251333
    13261334            let self = this;
    13271335            let $validateButton = $(event);
    1328 
    1329             voucherCode = voucherCode.trim();
     1336            voucherCode = voucherCode ? voucherCode.trim() : '';
     1337
     1338            let onFailureCallback = function (response) {
     1339
     1340                let errorResponse = self.parseGraphqlErrorResponse(response);
     1341                if (self.parseErrorCodeTranslationKey(errorResponse.code)) {
     1342                    self.openModalErrorMessage(self.parseTranslationKey(self.parseErrorCodeTranslationKey(errorResponse.code, 'dialogue_voucher_code_invalid')), errorResponse.code);
     1343                } else if (errorResponse.code === 422) {
     1344                    self.openModalErrorMessage(self.parseTranslationKey('dialogue_voucher_code_applicable_subscription_unknown'), errorResponse.code);
     1345                } else {
     1346                    self.handleApiErrorCallback(event, errorResponse.message, errorResponse.code);
     1347                }
     1348
     1349            };
    13301350
    13311351            let onSuccessCallback = function (response) {
     
    13331353                self.openModalAlert(
    13341354                    null,
    1335                     response.data['PaymentArgumentsValidate'].voucher_description,
     1355                    response.data['UserPurchaseIntentAcquire'].description,
    13361356                    self.parseTranslationKey('button_payment_accept_complete'),
    13371357                    function (event, $modalButton) {
     
    13431363                        }
    13441364
    1345                         let operation = 'mutation{UserPaymentVoucherRedeem(' +
    1346                             'code:"' + voucherCode + '",' +
    1347                             'payment_provider_id:' + paymentProviderId + ',' +
    1348                             'subscription_id:' + subscriptionId + ',' +
    1349                             'user_subscription_id:' + userSubscriptionId + ',' +
    1350                             'redirect_url_path:"' + self.fetchCurrentUrl() + '"' +
     1365                        let operation = 'mutation{UserPurchaseIntentAcquire(' +
     1366                            'is_execute_dry_run:false' +
     1367                            ',operator_context:web' +
     1368                            ',purchase_intent_stack:[]' +
     1369                            ',voucher_code:"' + voucherCode + '"' +
     1370                            ',redirect_url_path:"' + self.fetchCurrentUrl() + '"' +
    13511371                            '){payment_url}}';
    13521372
     
    13621382
    13631383                                // Acquisition was successful
    1364                                 if (response.data['UserPaymentVoucherRedeem'].payment_url) {
     1384                                if (response.data['UserPurchaseIntentAcquire'].payment_url) {
    13651385                                    // redirect to payment provider
    1366                                     window.location.replace(response.data['UserPaymentVoucherRedeem'].payment_url);
     1386                                    window.location.replace(response.data['UserPurchaseIntentAcquire'].payment_url);
    13671387                                } else {
    13681388                                    // payment is not necessary
     
    13791399                            function (response) {
    13801400                                self.toggleElementIsWorking([$modalButton], false);
    1381 
    1382                                 let errorMsg = response.responseJSON.errors[0].message;
    1383                                 let errorCode = response.responseJSON.errors[0].code;
    1384                                 if (errorCode === 422) {
    1385                                     self.openModalErrorMessage(self.parseTranslationKey('dialogue_voucher_code_applicable_subscription_unknown'), errorCode);
    1386                                 } else if (errorCode === 3600) {
    1387                                     self.openModalErrorMessage(self.parseTranslationKey('dialogue_voucher_code_invalid'), errorCode);
    1388                                 } else if (errorCode >= 400) {
    1389                                     self.openModalErrorMessage(self.parseTranslationKey('dialogue_voucher_code_not_applicable'), errorCode);
    1390                                 } else {
    1391                                     self.handleApiErrorCallback(event, errorMsg, errorCode);
    1392                                 }
     1401                                onFailureCallback(response);
    13931402                            }
    13941403                        );
     
    13971406            };
    13981407
    1399             let onFailureCallback = function (response) {
    1400 
    1401                 let errorMsg = response.responseJSON.errors[0].message;
    1402                 let errorCode = response.responseJSON.errors[0].code;
    1403                 if (errorCode === 422) {
    1404                     self.openModalErrorMessage(self.parseTranslationKey('dialogue_voucher_code_applicable_subscription_unknown'), errorCode);
    1405                 } else if (errorCode === 3600) {
    1406                     self.openModalErrorMessage(self.parseTranslationKey('dialogue_voucher_code_invalid'), errorCode);
    1407                 } else if (errorCode >= 400) {
    1408                     self.openModalErrorMessage(self.parseTranslationKey('dialogue_voucher_code_not_applicable'), errorCode);
    1409                 } else {
    1410                     self.handleApiErrorCallback(event, errorMsg, errorCode);
    1411                 }
    1412 
    1413             };
    1414 
    1415             self.validateVoucherCode($validateButton, voucherCode, 'subscription_id:' + subscriptionId, true, onSuccessCallback, onFailureCallback);
     1408            self.validateVoucherCode($validateButton, voucherCode, '[]', onSuccessCallback, onFailureCallback);
    14161409        },
    14171410
     
    17071700        parseTranslationKey: function (key, vars) {
    17081701            return this.parseTranslation(this.CONFIG.translations[key], vars);
     1702        },
     1703
     1704        parseErrorCodeTranslationKey: function (errorCode, fallbackTranslation) {
     1705            return this.ERROR_CODE_TRANSLATIONS[errorCode] ?
     1706                this.ERROR_CODE_TRANSLATIONS[errorCode] :
     1707                (fallbackTranslation = fallbackTranslation ? fallbackTranslation.trim() : '');
     1708        },
     1709
     1710        parseGraphqlErrorResponse: function (response) {
     1711
     1712            let errorMessage = response.statusText;
     1713            let errorCode = response.status;
     1714
     1715            if (response.responseJSON && response.responseJSON.errors) {
     1716                errorMessage = response.responseJSON.errors[0].message;
     1717                errorCode = response.responseJSON.errors[0].code;
     1718            } else if (response.data['UserPurchaseIntentAcquire'] && response.data['UserPurchaseIntentAcquire'].validation_messages.length) {
     1719                errorMessage = response.data['UserPurchaseIntentAcquire'].validation_messages[0].message;
     1720                errorCode = response.data['UserPurchaseIntentAcquire'].validation_messages[0].code;
     1721            }
     1722
     1723            return {
     1724                message: errorMessage,
     1725                code: errorCode,
     1726            };
    17091727        }
    17101728
  • audienceplayer/trunk/vendor/autoload.php

    r3048935 r3298867  
    2323require_once __DIR__ . '/composer/autoload_real.php';
    2424
    25 return ComposerAutoloaderInit5cfc594734f281b302e98f3d5dfebf3e::getLoader();
     25return ComposerAutoloaderInita6d20a7c9bc887ce3cb59346b319f6dd::getLoader();
  • audienceplayer/trunk/vendor/composer/InstalledVersions.php

    r2945999 r3298867  
    3232     */
    3333    private static $installed;
     34
     35    /**
     36     * @var bool
     37     */
     38    private static $installedIsLocalDir;
    3439
    3540    /**
     
    310315        self::$installed = $data;
    311316        self::$installedByVendor = array();
     317
     318        // when using reload, we disable the duplicate protection to ensure that self::$installed data is
     319        // always returned, but we cannot know whether it comes from the installed.php in __DIR__ or not,
     320        // so we have to assume it does not, and that may result in duplicate data being returned when listing
     321        // all installed packages for example
     322        self::$installedIsLocalDir = false;
    312323    }
    313324
     
    323334
    324335        $installed = array();
     336        $copiedLocalDir = false;
    325337
    326338        if (self::$canGetVendors) {
     339            $selfDir = strtr(__DIR__, '\\', '/');
    327340            foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
     341                $vendorDir = strtr($vendorDir, '\\', '/');
    328342                if (isset(self::$installedByVendor[$vendorDir])) {
    329343                    $installed[] = self::$installedByVendor[$vendorDir];
     
    331345                    /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
    332346                    $required = require $vendorDir.'/composer/installed.php';
    333                     $installed[] = self::$installedByVendor[$vendorDir] = $required;
    334                     if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
    335                         self::$installed = $installed[count($installed) - 1];
     347                    self::$installedByVendor[$vendorDir] = $required;
     348                    $installed[] = $required;
     349                    if (self::$installed === null && $vendorDir.'/composer' === $selfDir) {
     350                        self::$installed = $required;
     351                        self::$installedIsLocalDir = true;
    336352                    }
     353                }
     354                if (self::$installedIsLocalDir && $vendorDir.'/composer' === $selfDir) {
     355                    $copiedLocalDir = true;
    337356                }
    338357            }
     
    351370        }
    352371
    353         if (self::$installed !== array()) {
     372        if (self::$installed !== array() && !$copiedLocalDir) {
    354373            $installed[] = self::$installed;
    355374        }
  • audienceplayer/trunk/vendor/composer/autoload_real.php

    r3048935 r3298867  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInit5cfc594734f281b302e98f3d5dfebf3e
     5class ComposerAutoloaderInita6d20a7c9bc887ce3cb59346b319f6dd
    66{
    77    private static $loader;
     
    2525        require __DIR__ . '/platform_check.php';
    2626
    27         spl_autoload_register(array('ComposerAutoloaderInit5cfc594734f281b302e98f3d5dfebf3e', 'loadClassLoader'), true, true);
     27        spl_autoload_register(array('ComposerAutoloaderInita6d20a7c9bc887ce3cb59346b319f6dd', 'loadClassLoader'), true, true);
    2828        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
    29         spl_autoload_unregister(array('ComposerAutoloaderInit5cfc594734f281b302e98f3d5dfebf3e', 'loadClassLoader'));
     29        spl_autoload_unregister(array('ComposerAutoloaderInita6d20a7c9bc887ce3cb59346b319f6dd', 'loadClassLoader'));
    3030
    3131        require __DIR__ . '/autoload_static.php';
    32         call_user_func(\Composer\Autoload\ComposerStaticInit5cfc594734f281b302e98f3d5dfebf3e::getInitializer($loader));
     32        call_user_func(\Composer\Autoload\ComposerStaticInita6d20a7c9bc887ce3cb59346b319f6dd::getInitializer($loader));
    3333
    3434        $loader->register(true);
  • audienceplayer/trunk/vendor/composer/autoload_static.php

    r3048935 r3298867  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInit5cfc594734f281b302e98f3d5dfebf3e
     7class ComposerStaticInita6d20a7c9bc887ce3cb59346b319f6dd
    88{
    99    public static $prefixLengthsPsr4 = array (
     
    3838    {
    3939        return \Closure::bind(function () use ($loader) {
    40             $loader->prefixLengthsPsr4 = ComposerStaticInit5cfc594734f281b302e98f3d5dfebf3e::$prefixLengthsPsr4;
    41             $loader->prefixDirsPsr4 = ComposerStaticInit5cfc594734f281b302e98f3d5dfebf3e::$prefixDirsPsr4;
    42             $loader->classMap = ComposerStaticInit5cfc594734f281b302e98f3d5dfebf3e::$classMap;
     40            $loader->prefixLengthsPsr4 = ComposerStaticInita6d20a7c9bc887ce3cb59346b319f6dd::$prefixLengthsPsr4;
     41            $loader->prefixDirsPsr4 = ComposerStaticInita6d20a7c9bc887ce3cb59346b319f6dd::$prefixDirsPsr4;
     42            $loader->classMap = ComposerStaticInita6d20a7c9bc887ce3cb59346b319f6dd::$classMap;
    4343
    4444        }, null, ClassLoader::class);
  • audienceplayer/trunk/vendor/composer/installed.php

    r3093691 r3298867  
    44        'pretty_version' => 'dev-master',
    55        'version' => 'dev-master',
    6         'reference' => '29f460d6d43eb9169464315fc26de985a96e91dd',
     6        'reference' => '3374afa17e8b39c6498b92b0a5aa363da5ac162b',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    2323            'pretty_version' => 'dev-master',
    2424            'version' => 'dev-master',
    25             'reference' => '29f460d6d43eb9169464315fc26de985a96e91dd',
     25            'reference' => '3374afa17e8b39c6498b92b0a5aa363da5ac162b',
    2626            'type' => 'wordpress-plugin',
    2727            'install_path' => __DIR__ . '/../../',
Note: See TracChangeset for help on using the changeset viewer.