 <p>First of all you need to tell where are you writing this code. Don't mind but your code looks like not as it should be: 1- Which version are you using (Yii1 | Yii2)? I guess Yii1</p> <p>if you are using yii1 and you want to perform this stuff under profile update Action. </p> <p>so lets consider "profile/update" Action. so there will be some thing like below under "ProfileController". </p> <pre><code>public function actionUpdate(){ //some thing will be placed here.... } </code></pre> <p>There are 2 ways to do it. one just do it along with the controller or user Hooks (recommended) so it will be under "Model afterSave" hook. some thing like that. you can use any extension / component / widget.</p> <p><a href="http://www.yiiframework.com/extension/paypal/" rel="nofollow">Paypal Extension</a> can tell you how you can do it .</p>