Thursday, 15 March 2012

php - Submitting Magento form on page load -



php - Submitting Magento form on page load -

i working on extension integrate 3rd party api magento. steps included fill out form on our site. when user clicks submit api pre-fills form on site user approves. few string variables sent on page on our site, trigger sec api phone call (behind scenes) retrieves token. 1 time token created saving token sec hidden form , submitting via function:

function submitaccount() { var formid = 'form-payment-submit'; var myform = new varienform(formid, true); var posturl = '<?php echo $this->geturl('marketplacepayment/marketplaceaccount/paymentsetup/') ?>'; if (myform.validator.validate()) { new ajax.updater( { success:console.log("form success") }, posturl, { method:'post', asynchronous:false, evalscripts:false, oncomplete:function(request, json) { //submitbuttonon(); alert('success!'); }, parameters: $(formid).serialize(true), } ); } }

the function in module handles saving values database:

public function paymentsetupaction(){ if(!(empty($_post['access']))){ // save tokens db $collection = mage::getmodel('marketplace/userprofile')->getcollection(); $collection->addfieldtofilter('mageuserid',array('eq'=>$_post['userid'])); foreach($collection $row){ $id=$row->getautoid(); } $collectionload = mage::getmodel('marketplace/userprofile')->load($id); $collectionload->setaccesstoken($_post['access']); $collectionload->setrefreshtoken($_post['refresh']); $collectionload->setstripekey($_post['key']); $collectionload->save(); mage::getsingleton('core/session')->addsuccess( mage::helper('marketplace')->__('your payment info has been sucessfully saved.')); $this->_redirect('marketplacepayment/marketplaceaccount/payment'); } }

the problem tokens not beingness saved no errors appearing. can't write of info page since submit via ajax @ loss how debug. see wrong paymentsetupaction? or there easier way me see why not working?

the problem $collection section - using wrong database column names:

$collectionload = mage::getmodel('marketplace/userprofile')->load($id); $collectionload->setaccess_token($_post['access']); $collectionload->setrefresh_token($_post['refresh']); $collectionload->setstripe_key($_post['key']); $collectionload->save();

sorry random non of import question.

php jquery forms magento

No comments:

Post a Comment