Skip to content

Commit 880e9af

Browse files
author
ehowlsla
committed
added error msg friendly
1 parent bc50678 commit 880e9af

File tree

6 files changed

+77
-34
lines changed

6 files changed

+77
-34
lines changed

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package kr.co.bootpay;
22

3+
import android.app.AlertDialog;
34
import android.app.FragmentManager;
45
import android.content.Context;
56
import android.content.DialogInterface;
@@ -447,7 +448,7 @@ public void request() {
447448
validCheck();
448449
UserInfo.getInstance(context).update();
449450

450-
Bootpay.builder.request = ValidRequest.validUXAvailablePG(Bootpay.builder.request);
451+
Bootpay.builder.request = ValidRequest.validUXAvailablePG(context, Bootpay.builder.request);
451452
UX ux = request.getUX();
452453
if(PGAvailable.isUXPGDefault(ux)) requestDialog();
453454
else if(PGAvailable.isUXPGSubscript(ux)) {
@@ -456,10 +457,23 @@ else if(PGAvailable.isUXPGSubscript(ux)) {
456457
}
457458
else if(PGAvailable.isUXBootpayApi(ux)) requestApi();
458459
else if(PGAvailable.isUXApp2App(ux)) requestApp2App();
459-
else throw new IllegalStateException(ux.toString() + " is not supported!");
460+
else {
461+
final String msg = ux.toString() + " is not supported!";
462+
new AlertDialog.Builder(context)
463+
.setTitle("Bootpay Android Dev Error")
464+
.setMessage(msg)
465+
.setCancelable(true)
466+
.setPositiveButton("종료",
467+
new DialogInterface.OnClickListener() {
468+
public void onClick(
469+
DialogInterface dialog, int id) {
470+
// 프로그램을 종료한다
471+
throw new IllegalStateException(msg);
472+
}
473+
}).create().show();
474+
}
460475
}
461476

462-
// public
463477

464478
private void requestDialog() {
465479
dialog = new BootpayDialog().setRequest(request)

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,7 @@ public BootpayWebView(Context context, AttributeSet attrs, int defStyleAttr) {
106106
requestFocus();
107107
setting(context);
108108

109-
110-
111109
setWebViewClient(new WebViewClient() {
112-
113110
@Override
114111
public void onPageFinished(WebView view, String url) {
115112
super.onPageFinished(view, url);

bootpay/src/main/java/kr/co/bootpay/enums/Method.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ public enum Method {
66
BANK,
77
VBANK,
88
PHONE,
9-
AUTH,
9+
AUTH, // 본인인증
1010
// CARD_REBILL,
11-
SUBSCRIPT_CARD,
12-
SUBSCRIPT_PHONE,
13-
EASY,
11+
SUBSCRIPT_CARD, // 정기결제
12+
SUBSCRIPT_PHONE, // 정기결제
13+
EASY, // 간편결제
1414
SELECT
1515
}

bootpay/src/main/java/kr/co/bootpay/enums/UX.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ public enum UX {
44
PG_DIALOG, // 일반 PG 결제
55
PG_SUBSCRIPT, // 일반 PG사 정기결제
66
PG_SUBSCRIPT_RESERVE, // 일반 PG사 정기결제지만 예약결제처럼 사용할 때 사용
7-
BOOTPAY_DIALOG, // 부트페이 통합 결제창
8-
BOOTPAY_ROCKET, // 부트페이 로켓결제
9-
BOOTPAY_ROCKET_TEMPORARY, // 부트페이 로켓결제 - 카드수기처럼 쓸 수 있는 형태
7+
// BOOTPAY_DIALOG, // 부트페이 통합 결제창
8+
// BOOTPAY_ROCKET, // 부트페이 로켓결제
9+
// BOOTPAY_ROCKET_TEMPORARY, // 부트페이 로켓결제 - 카드수기처럼 쓸 수 있는 형태
1010
BOOTPAY_REMOTE_LINK, // 결제링크 바로 생성
1111
BOOTPAY_REMOTE_ORDER, // 결제폼 생성
1212
BOOTPAY_REMOTE_PRE, // 사전예약 생성

bootpay/src/main/java/kr/co/bootpay/valid/ValidRequest.java

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package kr.co.bootpay.valid;
22

3+
import android.app.AlertDialog;
4+
import android.content.Context;
5+
import android.content.DialogInterface;
6+
import android.content.Intent;
37
import android.os.Build;
48

59
import java.util.Arrays;
@@ -11,16 +15,16 @@
1115
import kr.co.bootpay.model.Request;
1216

1317
public class ValidRequest {
14-
public static Request validUXAvailablePG(Request request) {
18+
public static Request validUXAvailablePG(Context context, Request request) {
1519
UX ux = request.getUX();
16-
if(PGAvailable.isUXPGDefault(ux)) return validPGDialog(request);
17-
if(PGAvailable.isUXPGSubscript(ux)) return validPGSubscript(request);
18-
else if(PGAvailable.isUXBootpayApi(ux)) return validPGDialog(request);
19-
else if(PGAvailable.isUXApp2App(ux)) return validBootpayUX(request);
20+
if(PGAvailable.isUXPGDefault(ux)) return validPGDialog(context, request);
21+
if(PGAvailable.isUXPGSubscript(ux)) return validPGSubscript(context, request);
22+
else if(PGAvailable.isUXBootpayApi(ux)) return validPGDialog(context, request);
23+
else if(PGAvailable.isUXApp2App(ux)) return validBootpayUX(context, request);
2024
return request;
2125
}
2226

23-
private static Request validPGDialog(Request request) {
27+
private static Request validPGDialog(Context context, Request request) {
2428
if(request.getPG().length() == 0) return request; // 통합결제창
2529
if(request.getMethods() != null && request.getMethods().size() > 0) return request; // 통합결제창
2630

@@ -36,15 +40,22 @@ private static Request validPGDialog(Request request) {
3640
break;
3741
}
3842
}
39-
if(!contain) throw new IllegalStateException(request.getPG() + "'s " + request.getMethod() + " is not supported");
43+
if(!contain) {
44+
final String string = request.getPG() + "'s " + request.getMethod() + " is not supported";
45+
errorDialog(context, string);
46+
}
4047
}
4148
return request;
4249
}
4350

44-
private static Request validPGSubscript(Request request) {
51+
private static Request validPGSubscript(Context context, Request request) {
4552
if("nicepay".equals(request.getPG().toLowerCase())) throw new IllegalStateException(request.getPG() + " 정기결제는 클라이언트 UI 연동방식이 아닌, REST API를 통해 진행해주셔야 합니다.");
4653
List<String> rebill = Arrays.asList("card_rebill", "phone_rebill");
47-
if(!rebill.contains(request.getMethod())) throw new IllegalStateException(request.getMethod() + " is not supported in " + request.getUX());
54+
if(!rebill.contains(request.getMethod())) {
55+
final String string = request.getMethod() + " is not supported in " + request.getUX() + ". select in " + rebill.toString();
56+
errorDialog(context, string);
57+
}
58+
4859
List<Method> methodList = PGAvailable.getDefaultMethods(request);
4960
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
5061
boolean contain = false;
@@ -55,12 +66,15 @@ private static Request validPGSubscript(Request request) {
5566
break;
5667
}
5768
}
58-
if(!contain) throw new IllegalStateException(request.getPG() + "'s " + request.getMethod() + " is not supported");
69+
if(!contain) {
70+
final String string = request.getPG() + "'s " + request.getMethod() + " is not supported";
71+
errorDialog(context, string);
72+
}
5973
}
6074
return request;
6175
}
6276

63-
private static Request validBootpayUX(Request request) {
77+
private static Request validBootpayUX(Context context, Request request) {
6478
List<PG> pgList = PGAvailable.getBootpayUX(request);
6579
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
6680
boolean contain = false;
@@ -70,8 +84,28 @@ private static Request validBootpayUX(Request request) {
7084
break;
7185
}
7286
}
73-
if(!contain) throw new IllegalStateException(request.getUX() + "'s " + request.getPG() + " is not supported");
87+
88+
if(!contain) {
89+
final String string = request.getPG() + "'s " + request.getMethod() + " is not supported";
90+
errorDialog(context, string);
91+
}
7492
}
7593
return request;
7694
}
95+
96+
private static void errorDialog(Context context, final String msg) {
97+
// 친절히 알려주자
98+
new AlertDialog.Builder(context)
99+
.setTitle("Bootpay Android Dev Error")
100+
.setMessage(msg)
101+
.setCancelable(true)
102+
.setPositiveButton("종료",
103+
new DialogInterface.OnClickListener() {
104+
public void onClick(
105+
DialogInterface dialog, int id) {
106+
// 프로그램을 종료한다
107+
throw new IllegalStateException(msg);
108+
}
109+
}).create().show();
110+
}
77111
}

sample/src/main/java/bootpay/co/kr/samplepayment/NativeActivity.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ public class NativeActivity extends Activity {
2828
private int stuck = 1;
2929
//5b9f51264457636ab9a07cdc
3030
// private String application_id = "5b9f51264457636ab9a07cdc";
31-
// private String application_id = "5b14c0ffb6d49c40cda92c4e";
31+
private String application_id = "5b14c0ffb6d49c40cda92c4e";
3232

33-
private String application_id = "5ab306a4396fa616d1ba3e69";
3433

3534

3635
@Override
@@ -70,22 +69,21 @@ public void startTrace() {
7069
public void onClick_request(View v) {
7170
BootUser bootUser = new BootUser().setPhone("010-1234-5678");
7271
BootExtra bootExtra = new BootExtra().setQuotas(new int[] {0,2,3});
72+
// bootExtra.setStartAt()
7373

7474
Bootpay.init(getFragmentManager())
7575
.setContext(this)
76-
.setApplicationId("5b14c0ffb6d49c40cda92c4e") // 해당 프로젝트(안드로이드)의 application id 값
77-
.setPG(PG.INICIS) // 결제할 PG 사
76+
.setApplicationId(application_id) // 해당 프로젝트(안드로이드)의 application id 값
77+
.setPG(PG.JTNET) // 결제할 PG 사
7878
// .setUserPhone("010-1234-5678") // 구매자 전화번호
79-
// .setUX(UX.PG_SUBSCRIPT)
80-
.setMethod(Method.BANK) // 결제수단
79+
.setUX(UX.PG_SUBSCRIPT)
80+
.setMethod(Method.CARD) // 결제수단
8181
//.isShowAgree(true)
82-
.setName("맥북프로임다") // 결제할 상품명
82+
.setName("bootpay kb card test") // 결제할 상품명
8383
.setOrderId("1234") // 결제 고유번호
8484
.setPrice(1000) // 결제할 금액
85-
8685
.addItem("마우스", 1, "ITEM_CODE_MOUSE", 100) // 주문정보에 담길 상품정보, 통계를 위해 사용
8786
.addItem("키보드", 1, "ITEM_CODE_KEYBOARD", 200, "패션", "여성상의", "블라우스") // 주문정보에 담길 상품정보, 통계를 위해 사용
88-
8987
.request();
9088

9189
// 결제호출

0 commit comments

Comments
 (0)