Browse Author: nilesh.borse

Docusign Salesforce Field Mapping

In this tutorial i am going to explain how we can map docusign fields with salesforce object fields.

Most of the time we need the user data to be writtneback to the salesforce. Once user finish it’s docusign document. At that time we need to create the custom fields on docusign. I hope you already have installed and setup docusign manage package in salesforce .

Login to the docusign and select your uploaded template, you will see the following screen.

docusign_field_screen1

You can see there are two sections for field one is standard section which is provided by docusign and other one is custom. We’ll use custom. In order to create (or you can edit existing) custom field click on Edit button in in custom field section. You’ll see the screen for adding a new field.

docusign_field_screen2

In order to map field with salesforce you need to check on Relate to salesforce checkbox and select the object and it’s field you want to map. If you want field data enter by user should be writeback to the salesforce then check writeback checkbox. Once you map this field just click on Done button you will see your field in custom field section in docusign. Like this you can add one or more fields(try to map all the fields with the same or related object in salesforce).

Great!!..Now that you have mapped field, the next step is you’ll drag and drop those added custom fields on docusign document. Now send docusign document from salesforce to your email id, finish the document and check if data is writeback or not back to the salesforce.

Make future payment using Braintree payment gateway

This tutorial is for those who are developing a mobile application and they want to charge a customer(one or more time) in future. In this tutorial I am going to explain backend functionality in details.

Most of the time we need charge to  customer  in future. Some developers may store details in the database but this is not the best way when it comes to security. Fortunately this feature is provided by braintree and stripe payment gateways. Following tutorial will explain you how we can use braintree API.

Before we start a tutorial make sure that you have a braintree(Sandbox/Production) account, if you don’t have an account  you can open your braintree sandbox account from here Sandbox Account. Mobile developers need to install braintree provided sdk from here Mobile SDK
Braintree payment screen

Once you installed SDK successfully you can see the above screen and fields like card Number, Expiration Date and CVV Number which is provided by braintree you don’t need to do any code for that.

If you using sandbox account enter following Card details for testing purpose.

Sandbox Card Number: 4242 4242 4242 4242

Card Exp: Any future expiry month/Year

CVV: 123

When user click “Buy Now” button braintree SDK returns you paymentMethodNonce .  What you’ll do next step. Simply you’ll send paymentMethodNonce to your server through webservice.

Now the actual backend functionality start here.

Suppose you are sending the parameter paymentMethodNonce to the API YourServer.com/add_card_token.php

In add_card_token.php i will use the method provided by braintree (make sure you have downloaded PHP braintree library if not then click here)

<?php

require_once ‘lib/Braintree.php’; //installed braintree php library and include over here

Braintree_Configuration::environment(‘sandbox’);

Braintree_Configuration::merchantId(‘your_account_merchant_id’);

Braintree_Configuration::publicKey(‘public_key’);

Braintree_Configuration::privateKey(‘private_key’);

$paymentMethodNonce = $_POST[‘paymentMethodNonce ‘];//Getting parameters from mobile dev

$result = Braintree_Customer::create( array( ‘firstName’ => ‘abc’, ‘lastName’ => ‘efg’, ‘company’ => ‘Nanostuffs’, ‘paymentMethodNonce’ => $paymentMethodNonce ));

$customerid = $result->customer->id; //Store this info into the database

$card_token = $result->customer->paymentMethods[0]->token;//Store this info into the database

?>

The method (Braintree_Customer::create) will returns you all the basic information about the card like expiry, last four…

You will get customer id $result->customer->id and card_token in response $result->customer->paymentMethods[0]->token

You will store this information into the database for that particular customer.

Great, now you are ready to charge a customer in future anytime. Suppose i want to charge that customer now i will use the following method.

<?php

require_once ‘lib/Braintree.php’; //installed braintree php library and include over here

Braintree_Configuration::environment(‘sandbox’);

Braintree_Configuration::merchantId(‘your_account_merchant_id’);

Braintree_Configuration::publicKey(‘public_key’);

Braintree_Configuration::privateKey(‘private_key’);

try{

$result = Braintree_Transaction::sale(array(  ‘amount’ => ‘100’,

‘paymentMethodToken’ => $customer_id,

‘options’ => [ ‘submitForSettlement’ => True  ] )

);

if($result->success) {

$transactionId = $result->transaction->id;

}else{

$err = ”;

foreach($result->errors->deepAll() AS $error) { $err.= $error->message.” “; }

echo $err;

}

}catch(Exception $e)

{}

?>

Check and parse proper response returned by braintree. You have charged to the customer successfully. If you run the same method again you can see the charge successfully. Without entering user card details again.

You can achieve this using any sever side langauge. I am familiar with PHP only.

Let us know if this tutorial really help you 🙂

Laravel introduction

What is Laravel ?

Laravel is a free, open source PHP web application framework, designed for the development of model–view–controller (MVC) web applications. Laravel is released under the MIT license, with its source code hosted on GitHub.

Tutorial Details
Name : Laravel – PHP Framework
Type : PHP Framewrok
Language : PHP
Level : Beginner
Estimated Time : 40 Minuets
Comments : Next generation PHP Framework

Hello,
Today I am going to introduce a new PHP Framework called Laravel. It’s a young PHP framework. Before starting this tuts, lets go to know why you have to learn framework?

Yes, definitely, there is so much PHP framework (like zend, cake, codeigintor, yii etc.) available. But why need new framework? There are some difference between conventional framework and LARAVEL.

WHY YOU LEARN?
1. Very Light framework
2. Powerful and Flexible
3. Elegance and Simplicity
4. Programming (i.e. framework) doesn’t have painful
5. Well decorated Documents.
6. No need to configure
7. CURD & PHP template system support
8. Migration System
9. and more…

History and Author:
It’s developed in April 2011 by Taylor Otwell. He is Software Engineer at UserScape, where he works on the next generation of HelpSpot. Previously, he developed Microsoft .NET solutions for one of the largest freight carriers in the nation.

Well, if some interest has grown in your mind to know more about the LARAVEL, then let’s go to know more about this.

Requirements:
1. Localhost (WAMP/XAMPP/MAMP etc.)
2. PHP 5.3
3. MySql

Let’s go to start our Journey…
1. Go to Laravel website [www.laravel.com]
2. Click download and download the latest version of laravel

3. Extract this zip into your web root. Currently I am using XAMPP in windows. For xampp, go to xampp/htdocs/ and I have created a new folder called ‘laravel‘. After then, I copied all the file and folder from extracted zip and paste into laravel folder. So, my directory is now like this- http://localhost/laravel/

4. Now, go to browser and type your laravel directory to access. Our url should be http://localhost/laravel and finally type the public folder after that. The url like http://localhost/laravel/public/. Oky, now you are seeing your first laravel application home page.

 

 

 

 

 

 

 

 

 

 

 

 

 

5. Our application is almost done. To ensure more security, then we have to set the application key. For this, go to your laravel directory and find the applicaiton/config/application.php. Open this file and find the ‘key’ => ‘YourSecretKeyGoesHere!‘ line. Its a 32 hashing security key. You can generate any random key by yourself.

 

 

 

 

 

 

 

 

 

 

 

 

 

6. Now browse your application laravel and you may seeing some error in your apps. OK, its a common problem for all, Now, clear your browser history and cookies. After doing this, browse again. I think, it’s working properly now.

7. Some other configuration can be, but I think it is no needed for now. So, save this file.

 

Now 1 thing is left. Database configuration. Lets, go to for this-

1. Go to your laravel directory and open this file ‘application/config/database.php’ for database configuration.

2. After open this file, find out the ‘default’ => ‘mysql’, I am going to use mysql database so that I am keeping this data.

3.
Now find out the below link for database configuration.

‘mysql’ => array(
‘driver’   => ‘mysql’,
‘host’     => ‘localhost’,
‘database’ => ‘database’,
‘username’ => ‘root’,
‘password’ => ”,
‘charset’  => ‘utf8′,
‘prefix’   => ”,
),

And then set your host name. Create a database entitled ‘laravel‘ by using browser. Then put the database name and save the file.

Oky, now you have completed your first laravel configuration into your localhost. That’s the best way to configure laravel framework into your server.

How to create form in Laravel

Form is a most expected elements in website as well as web based application. Each and every interactive web apps must have a form option to communicate between users and administrator. Whatever you want to write in website, there is not alternative about form. It could be in chat, message, as well as comments.

In laravel 4, you have huge flexibility to create HTML form easily. Today I will gonna to show you how to create a simple form in laravel. Let’s open route.php file to change our routing.

Route::get('/createform', function()
{
return View::make('createform');
});

Just change the view file name and write new file name that is ‘createform’. Save and close this file. Open apps/views directory and create a new file. File name should createform.blade.php that we defined in route.php file.

<?php

{{ Form::open() }}

{{ Form::label(‘name’, ‘Full Name: ‘) }}

{{ Form::text(‘name’) }}

{{ Form::label(‘email’, ‘Email Address: ‘) }}

{{ Form::email(‘email’) }}

{{ Form::label(‘password’, ‘Password: ‘) }}

{{ Form::password(‘password’) }}

{{ Form::submit(‘Save Data’) }}

{{ Form::close() }}

Now save your file and browse your site (http://localhost/createform). Hope you will get very simple form that will take name, email and password. Its not fancy but still work.

 

But one problem here still, if you want to submit this form, it goes to you current controller, isn’t it? You can fix this issue by 2 ways. Either by routing or controller. Let’s check two methods. Change something in createform.blade.php as follows-

by routing

{{ Form::open(array('route' => 'createform.NameOfYourMethod')) }}
by Controller

{{ Form::open(array('action' => 'YourControllerName@NameOfControllerMethodWhereYouRedirectIt')) }}

Now save it and run your page again. Hope, if you submit your page, its redirect to your desired method properly.

Remove index.php from codeigniter framework

Hi all,
Today I am going to show you, how to remove the index.php part from your codeigniter URL. There are many ways to do it, but based on my previous experience, I got it is the best way to do so. To do so, create a .htaccess file in your directory and copy the following code in your created file.

 

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

 

Now, save this file and run your codeigniter apps. Hopefully, it will work perfectly.

Thanks for reading.

How to install laravel on windows wamp server

Following are the steps to install laravel on windows local wampserver

Steps

Before installing laravel please check following services are on or not ?

a.Enable openssl

b.Click on wamp icon->Apache->Apache Modules and enable ssl_module

c.check php_sockets is enable wamp icon->PHP->Extension->php_socket

Restart all services.

1.For installing laravel on windows PHP >= 5.4  required.

2.Download Laravel from: https://github.com/laravel/laravel/archive/master.zip.

3.Extract Laravel into the www folder for WAMP.

4.Download Composer from: https://getcomposer.org/Composer-Setup.exe

5.Install Composer into the same directory where the php.exe is located.e.g my php.exe is located at wampbinphpphp5.5.12

6.Open command prompt

7.Change into the directory where you extracted Laravel e.g: cd C:wampwwwlaravel

8.Type the command: composer install.

9.Copy and paste all public folder files into WAMP’s www folder.

10.Open index.php in laravel directory edit both lines to include the installation .Directory .e.g: ‘/../bootstrap/autoload.php’ to ‘/laravel/bootstrap/autoload.php’.

11.Open bootstrappaths.php and edit the line ‘public’ => __DIR__.’/../public’, to ‘public’ => __DIR__.’/../..’

12.Open your browser and run URL : localhost/laravel/public, you will be see below output.(You have arrived on the screen)

Roles and permissions of user in wordpress

WordPress is a free and open source blogging tool and a content management system (CMS) based on PHP and MySQL, which runs on a web hosting service.

WordPress is the most popular blogging system in use on the Web, at more than 60 million websites. WordPress having a set of User groups roles and permission. They are

  1. Super Admin – somebody with access to the site network administration features and all other features. See the Create a Network article.
  2. Administrator – somebody who has access to all the administration features within a single site.
  3. Editor – somebody who can publish and manage posts including the posts of other users.
  4. Author – somebody who can publish and manage their own posts.
  5. Contributor – somebody who can write and manage their own posts but cannot publish them.
  6. Subscriber – somebody who can only manage their profile.

MySQL Database Backup Using PHP

If your site is live and using Database then it is very important to take backup of you Database in regular time interval. But it is not possible to take the backup manually every time. So lets create a simple PHP function to do this job for us and we can call that function using Cron Job in regular time interval.

Here is the sample of php code

<?php
include("config.php");
function backup_db(){
/* Store All Table name in an Array */
$allTables = array();
$result = mysql_query('SHOW TABLES');
while($row = mysql_fetch_row($result)){
     $allTables[] = $row[0];
}

foreach($allTables as $table){
$result = mysql_query('SELECT * FROM '.$table);
$num_fields = mysql_num_fields($result);

$return.= 'DROP TABLE IF EXISTS '.$table.';';
$row2 = mysql_fetch_row(mysql_query('SHOW CREATE TABLE '.$table));
$return.= "nn".$row2[1].";nn";

for ($i = 0; $i < $num_fields; $i++) {
while($row = mysql_fetch_row($result)){
   $return.= 'INSERT INTO '.$table.' VALUES(';
     for($j=0; $j<$num_fields; $j++){
       $row[$j] = addslashes($row[$j]);
       $row[$j] = str_replace("n","\n",$row[$j]);
       if (isset($row[$j])) { $return.= '"'.$row[$j].'"' ; }
       else { $return.= '""'; }
       if ($j<($num_fields-1)) { $return.= ','; }
     }
   $return.= ");n";
}
}
$return.="nn";
}

//Generate Backup Folder
$folder = 'DB_Backup/';
if (!is_dir($folder))
mkdir($folder, 0777, true);
chmod($folder, 0777);

$date = date('m-d-Y-H-i-s', time());
$filename = $folder."db-backup-".$date; 

$handle = fopen($filename.'.sql','w+');
fwrite($handle,$return);
fclose($handle);
}

// Call the function
backup_db();
?>

config.php file
<?php
  $host="hostname";
  $uname="uname";
  $pass="password";
  $database = "databasename";
$connection=mysql_connect($host,$uname,$pass);
or die("Database Connection Failed");
$selectdb=mysql_select_db($database) or die("Database could not be selected");
$result=mysql_select_db($database)
or die("database cannot be selected <br>");
?>

Save the above code in a PHP file and upload the file to your web server
then run the file. And check if it create a folder called DB_Backup  and
create the backup .sql  file  inside DB_Backup folder. If the file  works
fine then  you can assign the file to your Cron Job.

PHP Security: HTTP Authentication

You possible have found a web page that you want to open, sudden peep out a dialog window asking for username and password. common example is early page at cpanel (control panel to manage the web server use web based). It use HTTP Authentication.

In protecting web page with HTTP authentication, you have to deliver two header. header WWW-AUTHENTICATE tell to browser that an username and password needed.

Example, create a file named “protectHTTP.php” within wwwphpsecurity.php. Enter following code:

<?php
  // test for username/password
  if(($_SERVER['PHP_AUTH_USER'] == "mia") AND
    ($_SERVER['PHP_AUTH_PW'] == "secret"))
  {
    echo("successfully!<br>n");
  }
  else
  {
    //Send headers to cause a browser to request
    //username and password from user
    header("WWW-Authenticate: " .
    "Basic realm="PHPEveryDay's Protected Area"");

	header("HTTP/1.0 401 Unauthorized");

    //Show failure text, which browsers usually
    //show only after several failed attempts
    print("This page is protected by HTTP ");
  }
?>

PHP creates the PHP_AUTH_USER and PHP_AUTH_PW  elements of the _SERVER array automatically if the browser passes a  username and password.

Need more help?

Hi there, was your problem or query resolved? If not & need more assistance, please do reach out to us at info@nanostuffs.com, we'll be more than delighted to help. Nanostuffs has 7+ years of extensive Salesforce & iOS/Android experience.
Holler Box