Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Peter 27 posts 192 karma points
    Nov 11, 2016 @ 13:30
    Peter
    0

    Problems getting/saving custom paymentprovider settings

    Hello,

    I am developing a custom payment provider, but I have some problems populating $scope.dialogData.provider.extendedData.items, which means that I cannot save/get any custom settings.

    I have been looking at the implementation of different payment providers (braintree, quickpay, sage), but as I am fairly new to angularjs, I find it difficult to wrap my head around.

    My two javascript files look like this:

    payment.epay.module.js:

    (function () {
        angular.module('merchello.plugins.epay', [
            'merchello.models',
            'merchello.services',
            'merchello.providers.models',
            'merchello.providers.directives',
            'merchello.providers.resources'
        ]);
    
        angular.module('merchello.providers.models', []);
        angular.module('merchello.providers.directives', []);
        angular.module('merchello.providers.resources', ['merchello.providers.models']);
        angular.module('merchello.plugins').requires.push('merchello.plugins.epay');
    }());
    

    payment.epay.providersettings.controller.js:

    angular.module("merchello.plugins.epay")
        .controller("Merchello.Providers.Dialogs.EPayProviderSettingsController", ["$scope",
            function ($scope) {
                $scope.init = function () {
                    if ($scope.dialogData.provider.extendedData.items.length > 0) {
                        var settingsString = items[0].value;
                        $scope.epaySettings = JSON.parse(settingsString);
                    }
    
                    $scope.$watch(function () {
                        return $scope.epaySettings;
                    }, function (newValue, oldValue) {
                        $scope.dialogData.provider.extendedData.items[0].value = angular.toJson(newValue);
                    }, true);
                };
                $scope.init();
            }
        ]);
    

    In my controller I get an error when I try to access the first element of extendedData.items, which occurs when I click the 'edit' button on the providers page in the backoffice.

    Can anybody tell me what I might be missing here, and how exactly is data transferred between my C# models/methods and angular modules?

    Br Peter

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Nov 11, 2016 @ 20:53
    Rusty Swayne
    100

    Hey Peter

    You should use the setValue('myAlias', settingsJson) and getValue('myAlias') instead of working with the JS array directly

  • Peter 27 posts 192 karma points
    Nov 16, 2016 @ 07:14
    Peter
    1

    Hello again,

    I got the code working - I made a lot of changes at once, and kind of lost track of what exactly the crucial bit was. I think it was partly my providersettings model and some GatewayProvider attributes, but as Rusty mentioned, setValue() and getValue() was definitely a nice touch once the object had been populated with data.

    BR Peter

Please Sign in or register to post replies

Write your reply to:

Draft