<commit_before>angular.module('ordercloud-payment-authorizeNet', [])
    .factory('AuthorizeNet', AuthorizeNet)
;

function AuthorizeNet( $q, $resource) {
    return {
        'CreateCreditCard': _createCreateCard,
        'UpdateCreditCard': _updateUpdateCreditCard(),
        'DeleteCreditCard' : _deleteCreditCard(),
        'AuthAndCapture' : _authAndCapture()

    };

    function _createCreateCard(creditCard) {
          console.log(creditCard);
        // makeApiCall('POST',{} )
        // return  a;
    }

    function _updateUpdateCreditCard() {

    }
    function _deleteCreditCard() {

    }
    function _authAndCapture() {

    }


    function makeApiCall(method, requestBody) {
        var apiUrl = 'https://api.ordercloud.io/v1/nativeintegrationproxy/authorizenet';
        var d = $q.defer();
        $resource(apiUrl, null, {
            callApi: {
                method: method,
                headers: {
                    'Authorization': 'Bearer ' + Auth().ReadToken()
                }
            }
        }).callApi(requestBody).$promise
            .then(function(data) {
                d.resolve(data);<commit_msg>CCN-38 Create CreditCard AuthNet service setup<commit_after>angular.module('ordercloud-payment-authorizeNet', [])
    .factory('AuthorizeNet', AuthorizeNet)
;

function AuthorizeNet( $q, $resource, OrderCloud) {
    return {
        'CreateCreditCard': _createCreateCard,
        'UpdateCreditCard': _updateUpdateCreditCard(),
        'DeleteCreditCard' : _deleteCreditCard(),
        'AuthAndCapture' : _authAndCapture()

    };

    // function _update(orderID, lineItemID, lineItem, buyerID) {
    //     return makeApiCall('PUT', '/v1/buyers/:buyerID/orders/:orderID/lineitems/:lineItemID', {
    //         'buyerID': buyerID ? buyerID : BuyerID().Get(),
    //         'orderID': orderID,
    //         'lineItemID': lineItemID
    //     }, lineItem);
    // }

    function _createCreateCard(creditCard, buyerID) {
          console.log(creditCard);
          var year = creditCard.ExpirationYear.toString().substring(2,4);
            var ExpirationDate = creditCard.ExpirationMonth.concat(year);

        return makeApiCall('POST',{
            'buyerID' : buyerID ? buyerID : OrderCloud.BuyerID.Get(),
            'TransactionType' : "createCreditCard",
            'CardDetails' : {
                'CardholderName' : creditCard.CardholderName,
                'CardType' : creditCard.CardType,
                'CardNumber' : creditCard.CardNumber,
                'ExpirationDate' : ExpirationDate,
                'CardCode' : creditCard.CardCode
            }
        });
        // return  a;
    }

    function _updateUpdateCreditCard() {

    }
    function _deleteCreditCard() {

    }
    function _authAndCapture() {

    }


    function makeApiCall(method, requestBody) {
        var apiUrl = 'https://api.ordercloud.io/v1/integrationproxy/authorizenettest';
        var d = $q.defer();
        $resource(apiUrl, null, {
            callApi: {
                method: method,
                headers: {
                    'Authorization': 'Bearer ' + OrderCloud.Auth.ReadToken()
                }
            }
        }).callApi(requestBody).$promise
            .then(function(data) {
                console.log(data);
                d.resolve(data);
{'fraction_non_alphanumeric': 0.12428700090063044, 'fraction_numerical': 0.0021014710297208045, 'mean_word_length': 2.085185185185185, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '243445', 'n_tokens_mistral': 990, 'n_tokens_neox': 929, 'n_words': 146}