Auth.net CIM Token over API

Discussion in 'Payments processing' started by bfritton, Dec 12, 2012.

  1. bfritton

    bfritton Certified aMember Developer

    Joined:
    Oct 26, 2009
    Messages:
    54
    Hello all,
    I'm reaching out here as I'm building a plugin for Magento (eCommerce platform) which will create a subscription plan, invoice and user when the visitor buys a specific product off of the site. The aMember product needs to rebill.

    I use Authorize.NET's CIM offering for which Member stores the CIM profile token ID for rebilling. My question is, how do I get that CIM token over from Magento to aMember. I've been reading through the RESTful API documentation related to adding the user, billing plans, payments, etc but haven't yet seen where I could possibly store this token in aMember so that aMember can standalone rebill by itself.

    Any suggestions? Thank you in advance.
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,274
    Current version of API doesn't allow to do this.
    You need an access to am_data table where amember stores custom fields and that access is not available through API.

    For this task you should create plugin in aMember and use aMember built-in API in order to add user and payments (this is more correct way because aMember will trigger hooks which will not happen when you add users through REST API).

    Your plugin should accept POST from your magento installation and add user/invoice depends on this post.

    Here is how you can set AuthorizeCIM profile fields:
    PHP:
    $user Am_Di::getInstance()->userTable->load('USER_ID');
    $user->data()->set(Am_Paysystem_AuthorizeCim::USER_PROFILE_KEY'USER_KEY')->update();
    $user->data()->set(Am_Paysystem_AuthorizeCim::PAYMENT_PROFILE_KEY'PAYMENT_KEY')->update();
  3. bfritton

    bfritton Certified aMember Developer

    Joined:
    Oct 26, 2009
    Messages:
    54
    Thank you for the reply, Alexander. Sounds doable. I will start planning this route. In all honesty, I wanted to avoid an aMember plugin this time as I haven't seen a whole lot of tutorial or documentation material on the creation of them for v4. I know how to do everything in Magento without a hitch.

    Do you have additional resources you could point me and others to that give a better idea of where things belong in the new plugin structure?
  4. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,274
    Unfortunately there is not much resources available yet.
    All we have can be found here: http://www.amember.com/docs/Main_Page
    Here is example of misc plugin which can accept POST:
    /amember/application/default/plugins/misc/test.php
    PHP:
    <?php

    class Am_Plugin_Test extends Am_Plugin
    {

        const 
    PLUGIN_STATUS self::STATUS_DEV;
        const 
    PLUGIN_REVISION '@@VERSION@@';
        
        protected 
    $_configPrefix 'misc.';

        function 
    init()
        {
            
    parent::init();
            
    ////// Things need to be done on Plugin init. 
        
    }


        function 
    _initSetupForm(Am_Form_Setup $form)
        {
    /// Key which will be checked on POST from magento
             
    $form->addText('security_key')->setLabel('Security key');
        }

        function 
    isConfigured()
        {
            return 
    $this->getConfig('security_key');
        }

        function 
    directAction(Am_Request $requestZend_Controller_Response_Http $response, array $invokeArgs)
        {
            if (
    $request->get('security_key') != $this->getConfig('key'))
                throw new 
    Am_Exception_InputError('Security check failed!');
            
    /// This action will be executed when you access http://www.yoursite.com/amember/misc/test url
        
    }


    }

    ?>
  5. bfritton

    bfritton Certified aMember Developer

    Joined:
    Oct 26, 2009
    Messages:
    54
    Thanks, Alexander. This is helpful.

    I'm completed a specification document and working through to build a bilateral Magento <=> aMember SSO and protection plugin. May have more questions, others dealing with Magento, please ask questions or submit ideas / code.

Share This Page