anggagewor

Untitled

Oct 5th, 2016
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.59 KB | None | 0 0
  1. <script type="text/javascript">
  2. (function() {
  3. $('select#province').change(function(){
  4. var selected = $(this).find('option:selected');
  5. var extra = selected.data('province');
  6. var dummy = "{{url('/api/v1/city')}}";
  7. console.log(dummy+'/'+extra);
  8. $('#city_id').empty();
  9. $.getJSON(dummy+'/'+extra,function(d){
  10. $.each( d, function( key, value ) {
  11. if(value.type == 'Kota'){
  12. type = "(Kota)";
  13. }else{
  14. type = "";
  15. }
  16. $('#city_id').append('<option value="'+value.city_id+'">'+value.city_name+' '+type+'</option>');
  17. console.log(key + ": " + value.city_name);
  18. });
  19. console.log(d);
  20. });
  21. });
  22.  
  23.  
  24. $('button#CheckPinNope').on('click',function(){
  25. var pin = $('#Pin').val();
  26. var phone = $('#Phone').val();
  27. var APIUrl = "{{url('/api/v1/cek')}}";
  28. //alert('Pin :'+pin+' Phone :'+phone);
  29. $.getJSON(APIUrl+'/'+pin+'/'+phone,function(r){
  30. if(r.success == false){
  31. $('#peringatan').empty();
  32. $('#peringatan').append('<div class="alert alert-danger">'+
  33. '<p>No Hanphone atau Pin Tidak Sesuai!</p>'+
  34. '</div>');
  35. }
  36.  
  37. @if(isset($json))
  38. if(r.success == true){
  39. var nama_merchant = "?nama_merchant={{$json['nama_merchant']}}&";
  40. var nama_pemilik_usaha = "nama_pemilik_usaha={{$json['nama_pemilik_usaha']}}&";
  41. var no_identitas = "no_identitas={{$json['no_identitas']}}&";
  42. var no_tlp = "no_tlp="+phone+"&";
  43. var no_npwp = "no_npwp={{$json['no_npwp']}}&";
  44. var url = "url={{$json['url']}}&";
  45. var user_id = "user_id={{$json['user_id']}}&";
  46. var jenis_kelamin = "jenis_kelamin={{$json['jenis_kelamin']}}";
  47. var ApiSaveUmum = "{{url('/api/v1/saveinfoumum')}}"+nama_merchant+nama_pemilik_usaha+no_identitas+no_tlp+no_npwp+url+user_id+jenis_kelamin;
  48. $('#peringatan').empty();
  49. $('#peringatan').append('<div class="alert alert-info">'+
  50. '<p>telpon dan pin sukses terautentikasi</p>'+
  51. '</div>');
  52. $('NohpLama.close').click();
  53.  
  54. location.href = ApiSaveUmum;
  55.  
  56. }
  57. @endif
  58. console.log(r);
  59. });
  60. });
  61. @if(\Auth::check())
  62. $('a#resetpin').on('click',function(){
  63. var ApiReset = "{{url('/api/v1/resetpin/'.\Auth::User()->email)}}";
  64. //alert('Pin :'+pin+' Phone :'+phone);
  65. $.getJSON(ApiReset,function(h){
  66. if(h.success == true){
  67. $('#peringatan').empty();
  68. $('#peringatan').append('<div class="alert alert-info">'+
  69. '<p>PIN baru berhasil dikirim ke email [email protected]</p>'+
  70. '<p>Silakan buka email dan masukan kembali pin yang baru</p>'+
  71. '</div>');
  72. }
  73. console.log(h);
  74. });
  75. });
  76. @endif
  77.  
  78. })();
  79. </script>
  80.  
  81.  
  82. Route::group(['prefix'=>'api/v1'],function(){
  83. Route::post('/logout', 'App\Addons\Finpay\Controllers\ajaxController@logout');
  84.  
  85. Route::group(['middleware' => 'web'], function() {
  86. Route::get('/unggah', 'App\Addons\Finpay\Controllers\UploadController@index');
  87. Route::get('/upload', 'App\Addons\Finpay\Controllers\ApiLogin@LoginByEmail');
  88. Route::post('/unggah', 'App\Addons\Finpay\Controllers\UploadController@type');
  89. });
  90.  
  91.  
  92. <?php
  93. /**
  94. * @package Finpay
  95. */
  96. namespace App\Addons\Finpay\Controllers;
  97. use App\User;
  98. use Validator;
  99. use App\Http\Requests;
  100. use Illuminate\Http\Request;
  101. use App\Http\Controllers\Controller;
  102. use App\Addons\Base\Models\AddonsModel;
  103. use DB;
  104. use App\Addons;
  105. use App\Addons\Base\Helper\AccessHelper;
  106. use App\Addons\Base\Models\GroupUserModel;
  107. use App\Addons\Finpay\Helper\StepHelper;
  108. use App\Addons\Finpay\Models\FinpaySettingModel as Setting;
  109. use App\Addons\Finpay\Models\FinpayInformasiUmumModel as umum;
  110. class ajaxController extends Controller
  111. {
  112.  
  113. public function index(Request $request)
  114. {
  115. $user = User::where('email','=',$request->header('email'))->first();
  116. if($user):
  117. $respon = [
  118. "finpay" => [
  119. "status" => [
  120. "code" => "200",
  121. "description" => "success"
  122. ],
  123. "results" => [
  124. "user_id" => $user->id,
  125. "user_email" => $user->email
  126. ]
  127. ]
  128. ];
  129. return response()->json($respon);
  130. else:
  131. $respon = [
  132. "finpay" => [
  133. "status" => [
  134. "code" => "404",
  135. "description" => "error"
  136. ],
  137. "results" => []
  138. ]
  139. ];
  140. return response()->json($respon);
  141. endif;
  142. }
  143.  
  144.  
  145.  
  146. public function logout(Request $request)
  147. {
  148. $user = User::where('email','=',$request->header('email'))->first();
  149.  
  150. if($user):
  151.  
  152. $session = DB::table('sessions')
  153. ->where('user_id',$user->id)
  154. ->first();
  155.  
  156. if($session):
  157. \Session::forget($session->id);
  158. $session = DB::table('sessions')
  159. ->where('user_id',$user->id)
  160. ->delete();
  161.  
  162. $respon = [
  163. "finpay" => [
  164. "status" => [
  165. "code" => "200",
  166. "description" => "success"
  167. ],
  168. "results" => [
  169. "user_id" => $user->id,
  170. "user_email" => $user->email,
  171. "is_logout" => "true"
  172. ]
  173. ]
  174. ];
  175. else:
  176.  
  177. $respon = [
  178. "finpay" => [
  179. "status" => [
  180. "code" => "200",
  181. "description" => "success"
  182. ],
  183. "results" => [
  184. "user_id" => $user->id,
  185. "user_email" => $user->email,
  186. "is_logout" => "false"
  187. ]
  188. ]
  189. ];
  190.  
  191. endif;
  192.  
  193. return response()->json($respon);
  194.  
  195. else:
  196. $respon = [
  197. "finpay" => [
  198. "status" => [
  199. "code" => "404",
  200. "description" => "error"
  201. ],
  202. "results" => []
  203. ]
  204. ];
  205. return response()->json($respon);
  206. endif;
  207. }
  208.  
  209. public function GetCity(Request $request)
  210. {
  211.  
  212. $client = new \GuzzleHttp\Client();
  213. $jkota = $client->request('GET', 'http://api.rajaongkir.com/starter/city?province='.$request->province_id,[
  214. 'proxy' => Setting::getSetting("proxy"),
  215. 'headers' => ['key' => '0b6b81bd57e4a9f949ccdc6926806eef']
  216. ]);
  217. $j = json_decode( $jkota->getBody() );
  218. $kota = $j->rajaongkir->results;
  219. return $kota;
  220. }
  221.  
  222.  
  223. public function CekPinNope(Request $request)
  224. {
  225. $client = new \GuzzleHttp\Client();
  226. $method = "POST";
  227. //hash pin
  228. $layer_satu = hash( 'sha256' ,$request->pin);
  229. $layer_dua = sha1($layer_satu);
  230. $hashpin = md5($layer_dua);
  231.  
  232. $datas = [
  233. "phone" => $request->phone,
  234. "pin" => $hashpin,
  235. ];
  236.  
  237. $kirim = $client->request($method,Config('konfigurasi.CekPinNope'),[
  238. 'proxy' => Setting::getSetting("proxy"),
  239. 'json' => $datas,
  240. ]);
  241.  
  242. return $kirim->getBody();
  243. }
  244.  
  245.  
  246. public function ResetPin(Request $request)
  247. {
  248. $client = new \GuzzleHttp\Client();
  249. $method = "POST";
  250.  
  251. $datas = [
  252. "email" => $request->email,
  253. ];
  254.  
  255. $kirim = $client->request($method,Config('konfigurasi.ResetPin'),[
  256. 'proxy' => Setting::getSetting("proxy"),
  257. 'json' => $datas,
  258. ]);
  259.  
  260. return $kirim->getBody();
  261. }
  262.  
  263. public function saveInfoUmum(Request $request)
  264. {
  265. $datas = [
  266. "nama_merchant" => $request->nama_merchant,
  267. "nama_pemilik_usaha"=> $request->nama_pemilik_usaha,
  268. "no_identitas" => $request->no_identitas,
  269. "no_tlp" => $request->no_tlp,
  270. "no_npwp" => $request->no_npwp,
  271. "url" => $request->url,
  272. "user_id" => $request->user_id,
  273. "jenis_kelamin" => $request->jenis_kelamin,
  274. ];
  275. umum::insert([$datas]);
  276. return redirect('daftar/step_dua');
  277. }
  278.  
  279. public function SendOtp(Request $request)
  280. {
  281. $client = new \GuzzleHttp\Client();
  282. $method = "POST";
  283.  
  284. $datas = [
  285. "email" => $request->email,
  286. ];
  287.  
  288. $kirim = $client->request($method,Config('konfigurasi.ResetPin'),[
  289. 'proxy' => Setting::getSetting("proxy"),
  290. 'json' => $datas,
  291. ]);
  292.  
  293. return $kirim->getBody();
  294.  
  295. }
  296.  
  297. }
Advertisement
Add Comment
Please, Sign In to add comment