Below are the instructions to insert the unlock code for your Samsung device and the steps to do in case code is not accepted

Samsung unlock code instructions:

Turn off phone; insert in your phone an SIM card from a different carrier that the one was locked to,
turn it on and when it asks to insert the network unlock code/pin insert the unlock code provided

Note: If asks for "SIM pin" ,then it needs a code specific to the SIM inserted, not to the phone.
If is a new SIM card, the SIM pin should be written on the SIM card package.

Samsung troubleshooting instructions:

A.Your Samsung mobile phone displays "Code Error" or "Sim Network Unlock Unsuccessful" after inserting the unlock code

Solution1

Method A (for models like Galaxy S2, S3, Note , Note 2,Blaze etc but can try it on any phone if needed )

a. Go to the Dial pad and dial *#197328640#
b. Please click on number [1] UMTS > [1] Debugging screen > [8] Phone Control > [6] NETWORK LOCK
c. You will see 3 options
d. Please click on number [1] Perso Sha256 INFO, the screen will change slightly
e. Please hit the MENU button then when the menu pops up please carefully hit BACK to return to the previous screen
f. Please click on number [2] Perso Sha256 ON, the screen will change again to a one line message
g. Restart the phone on the screen by holding the power button and click RESTART
h. When the phone prompts for the unlock code simply enter the unlock code
i. Your phone is now permanently unlocked!

Method B (for models like Galaxy S4 and other new models but can try it on any phone if needed )

a. Go to the Dial pad and dial *#0011#
b. Please click your MENU button (Bottom LEFT button) and click BACK on the menu that appears, nothing will happen do not worry please move to the next step
c. Please click your MENU button AGAIN and this time, click KEY INPUT
d. When the Key input box appears please input the number "1" and hit OK
e. You will see a number 1 for a while, please wait until it changes into the SERVICE MENU
f. Please click [1] UMTS > [1] DEBUGGING SCREEN > [6] Phone Control > [6] Network LOCK
g. You will see 3 OPTIONS within Network LOCK
h. Please click on number [1] Perso Sha256 INFO, the screen will change slightly
i. Please hit the MENU button then when the menu pops up please carefully hit BACK to return to the previous screen
j. Next Please click on number [2] Perso Sha256 ON, the screen will change again to a one line message
k. Restart the phone on the screen by holding the power button and click RESTART
l. When the phone prompts for the unlock code simply enter the unlock code provided to you

Solution 2

1. Power off and on your phone with different network sim card. "SIM network unlock PIN" or "Enter Network Lock Control Key" screen will appear.
2. Type your Unfreeze code (MCK code) and hit Unlock button. You will get "unsuccessful message" again but don't worry.
3. Now type the Unlock code (Network or NCK code) and hit Unlock button.

*If phone say "Network Lock Successful" it worked, but if not, proceed to step 4.
4. If you get "unsuccessful" again then hit Dismiss button and type *2767*3855# 
on the phone keypad.   (This will delete all your data,so make a backup if something you do not want to loose!).If code is not working do a factory reset from Settings/Backup and reset
5. After phone restarts, type the Unfreeze code (MCK code) when prompted to enter "SIM network unlock PIN" or "Enter Network Lock Control Key" screen and hit unlock button.

It will say "unsuccessful" again, don't worry!
6. Type the Unlock code (Network or NCK code) and hit Unlock button.
7. Your phone should now give you the message "Network Lock Successful"

Solution 3

1. Turn off the Wi-Fi on your phone and then turn device ON without SIM card.
2.Once it's on go to phone dial screen and DIAL: *7465625*638*#
3.It will bring you to the NETWORK LOCK screen.
4.In MCC/MNC field enter code for the service provider your phone is originally from (eg 31026 for T-Mobile USA)
check here for list of codes: http://en.wikipedia.org/wiki/Mobile_Network_Code

*If your network has more than one mcc/mnc please try all of them this is very important
5.In CONTROL KEY field enter the UNLOCK code
6.Hit OK and you should get a message: LOCK SUCCESSFUL
Power phone down, insert SIM card you want your phone to work with and power on.

Solution 4 (for phones that show “Phone freeze "when turning on with non-accepted SIM)

1. Turn phone on with an unaccepted sim card
2. Screen will display “Phone is freeze / SOS”
3. Type the Unfreeze code (MCK code) (Nothing will show on screen)
4. Hit the “Enter Button”
5. Phone will ask for the Network lock code
6. Enter the 8 digit unlock code (Network or NCK code)
7. Phone will be unfreeze and unlocked

Solution 5

Sometimes the problem is the phone firmware,if you tried all above solutions and the phone still not accepting the codes update the samsung software or restore the firmware using Odin.If you have a custom firmware that might be the cause why is not accepted so should restore to stock firmware and try again.

B.The Samsung device asks for  “Sim PIN”  or “PUK”

Those are codes specific to your SIM card and should be written on your SIM package if is a new SIM.The SIM pin is either set by the Sim owner or if is a new card should be written on the SIM instructions papers. For most Sim cards the default PIN is either 0000 or 1234 ,but you only have 3 tries so would recommend to try finding the exact Pin before trying those.If asks for PUK you can find it by calling to your carrier support or look on the original SIM package.

C.In case the  Samsung phone does not ask for unlock code (for older phones can use the solution bellow, for newer phones normally means that your Samsung is either unlocked already or hard locked-DO NOT USE THIS FOR TROUBLESHOOTING,WHEN THE CODE IS NOT ACCEPTED,BUT ONLY FOR OLDER PHONE WHEN IS NOT ASKING FOR UNLOCK CODE)

Method 1 : Go to the dial screen on your phone as if you are going to make a call and press: #7465625*638*UNLOCKCODE# (replace UNLOCKCODE with your specific unlock code that you received from us)
Method 2: Go to the dial screen on your phone as if you are going to make a call and press: #0111*UNLOCKCODE# (replace UNLOCKCODE with your specific unlock code that you received from us)
Method 3: Go to the dial screen on your phone as if you are going to make a call and press #7465625*638*# Once prompted for code, enter the 8 digit Unlock Code.

D.Your Samsung asks for  “Phone Password”/"Security Pin"/"User code" or other user lock like pattern lock/Gmail account

Most likely your Samsung has a user lock. To be sure that’s the problem turn on the phone without a SIM inside or with the original SIM. If asks the same thing then for sure the user lock is the problem.  The fix for this is a hardreset. To do a hard reset on android phones go into “Recovery mode” by turning the phone off then holding in same time “Home”, “Power” and “Vol  up” buttons, then select “Wipe data/Factory reset”

E.After turning on your Samsung smartphone with the new sim inside it displays "No SIM"

It means the Samsung mobile cannot detect the sim card at all.Most usual reason is that the SIM card is not inserted correctly, so verify what’s the right way to insert the SIM card and reinsert it.If you still you get the same message there may be a problem with your SIM card, either SIM is broken or not supported by the phone at all , so verify if you get the same message with other SIM  card or there might be a problem with the sim card reader.

F.The Samsung phone accepted the code but still displays "No service"

This can be caused by many things, here are the most common reasons :

-The SIM card is not registered, not activated or not supported by the phone. So should either try with other SIM, or should verify to see if this SIM works in another phone to exclude this possible issue
-Your phone can be blacklisted because was declared lost/stolen or for not played contract. To verify if that’s the problem try with the original sim to see if works or contact the network help service. If phone works fine with the original SIM than this is not the problem
-A settings or firmware problem. Can fix that by selecting the network manually ,doing a factory reset, update or firmware restore
-Phone has a hardware problem. If any of the above fixes do not work your phone may have a hardware problem and should send it for repairs, hopefully using the warranty if still available