Skip to content

Commit dfdaca9

Browse files
committed
생체인식 결제 배포
1 parent b013256 commit dfdaca9

File tree

13 files changed

+211
-64
lines changed

13 files changed

+211
-64
lines changed

bootpay/src/main/java/kr/co/bootpay/BootpayBuilder.java

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -447,18 +447,28 @@ public void requestBio() {
447447
if(context == null) {
448448
throw new IllegalStateException("context cannot be null from " + request.getUX().toString());
449449
}
450-
final long current = System.currentTimeMillis();
451-
CurrentBioRequest.getInstance().start_window_time = current;
452-
Handler handler = new Handler(Looper.getMainLooper());
453-
handler.post(new Runnable() {
454-
@Override
455-
public void run() {
456-
457-
if(current - CurrentBioRequest.getInstance().start_window_time > 2000) {
450+
long current = System.currentTimeMillis();
451+
if(current - CurrentBioRequest.getInstance().start_window_time > 2000) {
452+
CurrentBioRequest.getInstance().start_window_time = current;
453+
Handler handler = new Handler(Looper.getMainLooper());
454+
handler.post(new Runnable() {
455+
@Override
456+
public void run() {
458457
requestBioDialog();
459458
}
460-
}
461-
});
459+
});
460+
}
461+
// Handler handler = new Handler(Looper.getMainLooper());
462+
// handler.post(new Runnable() {
463+
// @Override
464+
// public void run() {
465+
// long current = System.currentTimeMillis();
466+
// if(current - CurrentBioRequest.getInstance().start_window_time > 2000) {
467+
// CurrentBioRequest.getInstance().start_window_time = current;
468+
// requestBioDialog();
469+
// }
470+
// }
471+
// });
462472

463473
}
464474

bootpay/src/main/java/kr/co/bootpay/BootpayWebView.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.util.Locale;
3232

3333
import kr.co.bootpay.listener.EventListener;
34+
import kr.co.bootpay.model.BootExtra;
3435
import kr.co.bootpay.model.Item;
3536
import kr.co.bootpay.model.Request;
3637
import kr.co.bootpay.pref.UserInfo;
@@ -172,6 +173,7 @@ public void onPageFinished(WebView view, String url) {
172173
public boolean shouldOverrideUrlLoading(WebView view, String url) {
173174
Intent intent = parse(url);
174175

176+
175177
// Log.d("bootpay url", url);
176178

177179
if (isIntent(url)) {
@@ -449,7 +451,21 @@ private String userJson() {
449451
private String extraJson() {
450452
if(request.getBootExtra(getContext()) == null) return "";
451453
if(request.getBootExtra(getContext()).toJson().length() == 0) return "";
452-
return String.format(Locale.KOREA, "extra: %s", request.getBoot_extra().toJson());
454+
BootExtra extra = request.getBoot_extra();
455+
if("danal".equals(request.getPG())) {
456+
List<Integer> quotas = extra.getQuotas();
457+
int index = quotas.indexOf(1);
458+
if(index <= -1) return String.format(Locale.KOREA, "extra: %s", extra.toJson());
459+
quotas.remove(index);
460+
461+
int[] arr = new int[quotas.size()];
462+
for(int i = 0; i < quotas.size(); i++) {
463+
arr[i] = quotas.get(i);
464+
}
465+
466+
extra.setQuotas(arr);
467+
}
468+
return String.format(Locale.KOREA, "extra: %s", extra.toJson());
453469
}
454470

455471
private String listToString(List<String> array) {

bootpay/src/main/java/kr/co/bootpay/api/ApiService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public ApiService(Context context) {
5757
.create();
5858

5959
api = new Retrofit.Builder()
60-
.baseUrl("https://dev-api.bootpay.co.kr")
60+
.baseUrl("https://api.bootpay.co.kr")
6161
.client(client)
6262
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
6363
.addConverterFactory(GsonConverterFactory.create(gson))

bootpay/src/main/java/kr/co/bootpay/bio/activity/BootpayBioActivity.java

Lines changed: 110 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
package kr.co.bootpay.bio.activity;
22

33
import android.app.AlertDialog;
4+
import android.app.ProgressDialog;
45
import android.content.Context;
56
import android.content.DialogInterface;
67
import android.content.Intent;
8+
import android.graphics.PorterDuff;
79
import android.graphics.Typeface;
10+
import android.graphics.drawable.Drawable;
11+
import android.os.Build;
812
import android.os.Bundle;
913
import android.os.Handler;
1014
import android.os.Looper;
1115
import android.os.PersistableBundle;
1216
import android.os.Vibrator;
1317
import android.util.Log;
1418
import android.util.TypedValue;
19+
import android.view.Gravity;
1520
import android.view.View;
1621
import android.widget.HorizontalScrollView;
1722
import android.widget.LinearLayout;
23+
import android.widget.ProgressBar;
1824
import android.widget.TextView;
1925
import android.widget.Toast;
2026

@@ -59,7 +65,6 @@
5965
import kr.co.bootpay.pref.UserInfo;
6066
import kr.co.bootpay.rest.BootpayBioRestImplement;
6167

62-
import static android.view.View.TEXT_ALIGNMENT_TEXT_END;
6368

6469
public class BootpayBioActivity extends FragmentActivity implements BootpayBioRestImplement {
6570

@@ -91,6 +96,8 @@ public class BootpayBioActivity extends FragmentActivity implements BootpayBioRe
9196
View quota_line;
9297
int currentIndex = 0;
9398

99+
ProgressDialog progress;
100+
94101
@Override
95102
protected void onCreate(@Nullable Bundle savedInstanceState) {
96103
super.onCreate(savedInstanceState);
@@ -101,6 +108,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
101108
this.presenter = new BioApiPresenter(new ApiService(this.context), this);
102109
request = CurrentBioRequest.getInstance().request;
103110
if(request != null) bioPayload = request.getBioPayload();
111+
initProgressCircle();
104112

105113
CurrentBioRequest.getInstance().bioActivity = this;
106114

@@ -112,6 +120,20 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
112120
setQuotaValue();
113121
}
114122

123+
void initProgressCircle() {
124+
progress = new ProgressDialog(context, R.style.BootpayDialogStyle);
125+
126+
progress.setIndeterminate(true);
127+
progress.setCancelable(false);
128+
129+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
130+
Drawable drawable = new ProgressBar(this).getIndeterminateDrawable().mutate();
131+
drawable.setColorFilter(ContextCompat.getColor(this, R.color.colorAccent),
132+
PorterDuff.Mode.SRC_IN);
133+
progress.setIndeterminateDrawable(drawable);
134+
}
135+
}
136+
115137
void setQuotaValue() {
116138
if(request == null) return;
117139
quota_layout.setVisibility(request.getPrice() < 50000 ? View.GONE : View.VISIBLE);
@@ -216,7 +238,8 @@ private void setNameViews() {
216238
for(String name : bioPayload.getNames()) {
217239
TextView text = new TextView(context);
218240
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
219-
text.setTextAlignment(TEXT_ALIGNMENT_TEXT_END);
241+
// text.setTextAlignment(TEXT_ALIGNMENT_TEXT_END);
242+
text.setGravity(Gravity.RIGHT);
220243
text.setLayoutParams(params);
221244
text.setText(name);
222245
text.setTextColor(getResources().getColor(R.color.black, null));
@@ -244,7 +267,8 @@ private void setPriceViews() {
244267
TextView right = new TextView(context);
245268
LinearLayout.LayoutParams params2 = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1.0f);
246269
right.setLayoutParams(params2);
247-
right.setTextAlignment(TEXT_ALIGNMENT_TEXT_END);
270+
right.setGravity(Gravity.RIGHT);
271+
// right.setTextAlignment(TEXT_ALIGNMENT_TEXT_END);
248272
right.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
249273
right.setText(getComma(bioPrice.getPrice()));
250274
right.setTextColor(getResources().getColor(R.color.black, null));
@@ -270,7 +294,8 @@ private void setPriceViews() {
270294
TextView right = new TextView(context);
271295
LinearLayout.LayoutParams params2 = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1.0f);
272296
right.setLayoutParams(params2);
273-
right.setTextAlignment(TEXT_ALIGNMENT_TEXT_END);
297+
right.setGravity(Gravity.RIGHT);
298+
// right.setTextAlignment(TEXT_ALIGNMENT_TEXT_END);
274299
right.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
275300
right.setTypeface(left.getTypeface(), Typeface.BOLD);
276301
right.setText(getComma(request.getPrice()));
@@ -336,9 +361,22 @@ void goBioPayRequest(String passwordToken) {
336361
}
337362
otp = getOTPValue(key);
338363
}
364+
365+
showProgress("결제 요청중");
339366
presenter.postEasyCardRequest(uuid, userToken, otp, passwordToken, bioWallet.wallet_id, "", CurrentBioRequest.getInstance().request.getPayload());
340367
}
341368

369+
void showProgress(final String msg) {
370+
Handler handler = new Handler(Looper.getMainLooper());
371+
handler.post(new Runnable() {
372+
@Override
373+
public void run() {
374+
progress.setMessage(msg);
375+
progress.show();
376+
}
377+
});
378+
}
379+
342380
String getOTPValue(String key) {
343381
CodeGenerator generator = new DefaultCodeGenerator(HashingAlgorithm.SHA512, 8);
344382
long time = Long.valueOf(server_unixtime) / 30;
@@ -359,6 +397,7 @@ void goRegisterBiometricRequest() {
359397
if(uuid == null || "".equals(uuid)) { Log.d("bootpay", "uuid 값이 없습니다"); return; }
360398
if(userToken == null || "".equals(userToken)) { Log.d("bootpay", "userToken 값이 없습니다"); return; }
361399

400+
showProgress("결제권한 추가중");
362401
presenter.postEasyBiometric(uuid, userToken, passwordToken);
363402
}
364403

@@ -373,17 +412,21 @@ void goAuthRegisterBiometricOTP() {
373412
if("".equals(otp)) return;
374413
String uuid = UserInfo.getInstance(context).getBootpayUuid();
375414
String userToken = request.getEasyPayUserToken();
415+
416+
showProgress("결제 요청중");
376417
presenter.postEasyBiometricRegister(uuid, userToken, otp);
377418
}
378419

379420

380421

381422
@Override
382423
public void callbackEasyBiometric(ResEasyBiometric res) {
424+
progress.dismiss();
383425
if(res.code != 0) {
384426
goPopUpError(res.message);
385427
return;
386428
}
429+
387430
easyBiometric = res;
388431
server_unixtime = res.data.server_unixtime;
389432
saveBiometricKey();
@@ -415,6 +458,8 @@ public void transactionConfirm(String data) {
415458

416459
String uuid = UserInfo.getInstance(context).getBootpayUuid();
417460
String userToken = request.getEasyPayUserToken();
461+
462+
showProgress("결제 승인중");
418463
presenter.postEasyConfirm(uuid, userToken, res.data.receipt_id);
419464
} catch (Exception e) {
420465
e.printStackTrace();
@@ -423,6 +468,7 @@ public void transactionConfirm(String data) {
423468

424469
@Override
425470
public void callbacktEasyBiometricRegister(ResEasyBiometric res) {
471+
progress.dismiss();
426472
if(res.code != 0) {
427473
goPopUpError(res.message);
428474
return;
@@ -442,13 +488,14 @@ public void callbackEasyCardWallet(ResWalletList res) {
442488
server_unixtime = res.data.user.server_unixtime;
443489
setCardPager(res.data);
444490
if(CurrentBioRequest.getInstance().type == CurrentBioRequest.REQUEST_TYPE_REGISTER_CARD) {
445-
goBiometricAuth();
491+
goPopup("이 기기에서 결제할 수 있도록 설정합니다. (최초 1회)");
446492
}
447493
}
448494

449495

450496
@Override
451497
public void callbackEasyCardRequest(ResReceiptID res) {
498+
progress.dismiss();
452499
if(res.code != 0) {
453500
goPopUpError(res.message);
454501
return;
@@ -460,6 +507,7 @@ public void callbackEasyCardRequest(ResReceiptID res) {
460507

461508
@Override
462509
public void callbackEasyTransaction(String data) {
510+
progress.dismiss();
463511
DoneListener done = CurrentBioRequest.getInstance().done;
464512
if(done != null) done.onDone(data);
465513
}
@@ -513,7 +561,13 @@ public void onAuthenticationFailed() {
513561
}
514562

515563
void goBiometricAuth() {
516-
biometricPrompt.authenticate(promptInfo);
564+
Handler handler = new Handler(Looper.getMainLooper());
565+
handler.post(new Runnable() {
566+
@Override
567+
public void run() {
568+
biometricPrompt.authenticate(promptInfo);
569+
}
570+
});
517571
}
518572

519573
void goPopUpVerifyForPay() {
@@ -522,7 +576,6 @@ void goPopUpVerifyForPay() {
522576
handler.post(new Runnable() {
523577
@Override
524578
public void run() {
525-
526579
isBioFailPopUp = true;
527580
AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.AlertDialogStyle);
528581
builder.setMessage("지문인식에 여러 번 실패하여, 비밀번호로 결제합니다.");
@@ -575,23 +628,58 @@ public void startBioPay(BioDeviceUse user, BioWallet bioWallet) {
575628
}
576629

577630

578-
void goPopup(String msg) {
579-
AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.AlertDialogStyle);
580-
// builder.se
581-
builder.setMessage(msg);
582-
builder.setPositiveButton("확인", new DialogInterface.OnClickListener() {
583-
@Override
584-
public void onClick(DialogInterface dialogInterface, int i) {
585-
CurrentBioRequest.getInstance().type = CurrentBioRequest.REQUEST_TYPE_ENABLE_DEVICE;
586-
goVeiryPassword();
587-
}
588-
}).setNegativeButton("취소", new DialogInterface.OnClickListener() {
631+
void goPopup(final String msg) {
632+
Handler handler = new Handler(Looper.getMainLooper());
633+
handler.post(new Runnable() {
589634
@Override
590-
public void onClick(DialogInterface dialogInterface, int i) {
591-
dialogInterface.dismiss();
635+
public void run() {
636+
AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.AlertDialogStyle);
637+
builder.setMessage(msg);
638+
builder.setPositiveButton("확인", new DialogInterface.OnClickListener() {
639+
@Override
640+
public void onClick(DialogInterface dialogInterface, int i) {
641+
CurrentBioRequest.getInstance().type = CurrentBioRequest.REQUEST_TYPE_ENABLE_DEVICE;
642+
goVeiryPassword();
643+
}
644+
}).setNegativeButton("취소", new DialogInterface.OnClickListener() {
645+
@Override
646+
public void onClick(DialogInterface dialogInterface, int i) {
647+
dialogInterface.dismiss();
648+
}
649+
});
650+
AlertDialog alertDialog = builder.create();
651+
alertDialog.show();
592652
}
593653
});
594-
AlertDialog alertDialog = builder.create();
595-
alertDialog.show();
654+
}
655+
656+
@Override
657+
public void onActivityResult(int requestCode, int resultCode, Intent data) {
658+
super.onActivityResult(requestCode, resultCode, data);
659+
660+
if(requestCode == 9999 && resultCode > 0) {
661+
//wallet 재갱신
662+
if(CurrentBioRequest.getInstance().type == CurrentBioRequest.REQUEST_TYPE_VERIFY_PASSWORD) {
663+
//지문인식 후
664+
goRegisterBiometricRequest();
665+
} else if(CurrentBioRequest.getInstance().type == CurrentBioRequest.REQUEST_TYPE_ENABLE_DEVICE) {
666+
//지문인식 후
667+
goRegisterBiometricRequest();
668+
//otp 등록해야함
669+
} else if(CurrentBioRequest.getInstance().type == CurrentBioRequest.REQUEST_TYPE_VERIFY_PASSWORD_FOR_PAY) {
670+
//비밀번호로 결제
671+
if(CurrentBioRequest.getInstance().token != null) goBioPayRequest(CurrentBioRequest.getInstance().token);
672+
} else if(CurrentBioRequest.getInstance().type == CurrentBioRequest.REQUEST_TYPE_REGISTER_CARD) {
673+
//카드를 등록 했음
674+
getEasyCardWalletList();
675+
} else if(CurrentBioRequest.getInstance().type == CurrentBioRequest.REQUEST_TYPE_PASSWORD_CHANGE) {
676+
//카드를 등록 했음
677+
getEasyCardWalletList();
678+
} else if(CurrentBioRequest.getInstance().type == CurrentBioRequest.REQUEST_TYPE_OTHER) {
679+
Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
680+
vibrator.vibrate(10);
681+
finish();
682+
}
683+
}
596684
}
597685
}

bootpay/src/main/java/kr/co/bootpay/bio/activity/BootpayBioWebView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public void onPageFinished(WebView view, String url) {
221221
isLoaded = true;
222222
setDevice();
223223
setAnalyticsData();
224-
setDevelopMode();
224+
// setDevelopMode();
225225
// useOneStoreApi();
226226
// if(extraJson())
227227

bootpay/src/main/java/kr/co/bootpay/bio/activity/BootpayBioWebviewActivity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ protected void onCreate(Bundle savedInstanceState) {
2222

2323
CurrentBioRequest.getInstance().listener = this;
2424

25+
2526
setContentView(R.layout.layout_bio_activity);
2627
webView = findViewById(R.id.webview);
2728
}

0 commit comments

Comments
 (0)