Skip to content

Commit 5e87f1a

Browse files
committed
결제진행시 에러처리 개선
1 parent edc760c commit 5e87f1a

File tree

6 files changed

+105
-4
lines changed

6 files changed

+105
-4
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@
2929
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
3030
import retrofit2.converter.gson.GsonConverterFactory;
3131
import retrofit2.http.Body;
32+
import retrofit2.http.DELETE;
3233
import retrofit2.http.Field;
3334
import retrofit2.http.FormUrlEncoded;
3435
import retrofit2.http.GET;
3536
import retrofit2.http.Header;
3637
import retrofit2.http.POST;
38+
import retrofit2.http.Path;
3739

3840
public class ApiService {
3941
private Context context;
@@ -136,5 +138,12 @@ Observable<ResponseBody> postEasyConfirm(
136138
@Field("receipt_id") String receipt_id
137139
);
138140

141+
@DELETE("/app/easy/card/wallet/{wallet_id}")
142+
Observable<ResDefault> deleteCardWalletID(
143+
@Header("BOOTPAY-DEVICE-UUID") String deviceUUID,
144+
@Header("BOOTPAY-USER-TOKEN") String userToken,
145+
@Path("wallet_id") String wallet_id
146+
);
147+
139148
}
140149
}

bootpay/src/main/java/kr/co/bootpay/bio/BootpayBioDialog.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import kr.co.bootpay.model.res.ResWalletList;
4545
import kr.co.bootpay.pref.UserInfo;
4646
import kr.co.bootpay.rest.BootpayBioRestImplement;
47+
import kr.co.bootpay.rest.model.ResDefault;
4748

4849
public class BootpayBioDialog extends androidx.fragment.app.DialogFragment implements BootpayBioRestImplement {
4950

@@ -197,6 +198,11 @@ public void callbackEasyTransaction(String data) {
197198
if(listener != null) listener.onDone(data);
198199
}
199200

201+
@Override
202+
public void callbackDeleteWalletID(ResDefault res) {
203+
204+
}
205+
200206
public void transactionConfirm(String data) {
201207
try {
202208
ResReceiptID res = new Gson().fromJson(data, ResReceiptID.class);

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

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
import kr.co.bootpay.model.res.ResWalletList;
6868
import kr.co.bootpay.pref.UserInfo;
6969
import kr.co.bootpay.rest.BootpayBioRestImplement;
70+
import kr.co.bootpay.rest.model.ResDefault;
7071

7172
import static androidx.biometric.BiometricManager.BIOMETRIC_SUCCESS;
7273

@@ -174,7 +175,7 @@ List<String> getQuotaList() {
174175
if(request.getBootExtra(this) == null || request.getBootExtra(this).getQuotas() == null) return null;
175176
for(Integer i : request.getBootExtra(this).getQuotas()) {
176177
if(i == 0) result.add("일시불");
177-
else result.add((i+1) + "개월");
178+
else result.add((i) + "개월");
178179
}
179180
return result;
180181
}
@@ -444,10 +445,21 @@ void goRegisterBiometricRequest() {
444445
if(uuid == null || "".equals(uuid)) { Log.d("bootpay", "uuid 값이 없습니다"); return; }
445446
if(userToken == null || "".equals(userToken)) { Log.d("bootpay", "userToken 값이 없습니다"); return; }
446447

447-
showProgress("권한 추가중");
448+
showProgress("보안 추가중");
448449
presenter.postEasyBiometric(uuid, userToken, passwordToken);
449450
}
450451

452+
void goCardDeleteWalletIDRequest() {
453+
String uuid = UserInfo.getInstance(context).getBootpayUuid();
454+
String userToken = request.getEasyPayUserToken();
455+
String wallet_id = bioWallet.wallet_id;
456+
if(uuid == null || "".equals(uuid)) { Log.d("bootpay", "uuid 값이 없습니다"); return; }
457+
if(userToken == null || "".equals(userToken)) { Log.d("bootpay", "userToken 값이 없습니다"); return; }
458+
459+
showProgress("초기화 진행중");
460+
presenter.deleteCardWalletID(uuid, userToken, wallet_id);
461+
}
462+
451463
void goAuthRegisterBiometricOTP() {
452464
// if(easyBiometric == null || easyBiometric.data == null) return;
453465
String key = UserInfo.getInstance(context).getBiometricSecretKey();
@@ -501,6 +513,29 @@ public void onClick(DialogInterface dialogInterface, int i) {
501513
});
502514
}
503515

516+
void goPopupCardDeleteAll(final ResReceiptID res) {
517+
Handler handler = new Handler(Looper.getMainLooper());
518+
handler.post(new Runnable() {
519+
@Override
520+
public void run() {
521+
AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.AlertDialogStyle);
522+
builder.setTitle("에러코드: " + res.code);
523+
builder.setMessage(res.message + " 등록된 결제수단을 초기화 합니다.");
524+
builder.setPositiveButton("확인", new DialogInterface.OnClickListener() {
525+
@Override
526+
public void onClick(DialogInterface dialogInterface, int i) {
527+
goCardDeleteWalletIDRequest();
528+
// ErrorListener error = CurrentBioRequest.getInstance().error;
529+
// if(error != null) error.onError(msg);
530+
// finish();
531+
}
532+
});
533+
AlertDialog alertDialog = builder.create();
534+
alertDialog.show();
535+
}
536+
});
537+
}
538+
504539
public void transactionConfirm(String data) {
505540
try {
506541
ResReceiptID res = new Gson().fromJson(data, ResReceiptID.class);
@@ -546,7 +581,7 @@ public void callbackEasyCardWallet(ResWalletList res) {
546581
public void callbackEasyCardRequest(ResReceiptID res) {
547582
progress.dismiss();
548583
if(res.code != 0) {
549-
goPopUpError(res.message);
584+
goPopupCardDeleteAll(res);
550585
return;
551586
}
552587
receiptID = res;
@@ -561,6 +596,16 @@ public void callbackEasyTransaction(String data) {
561596
if(done != null) done.onDone(data);
562597
}
563598

599+
@Override
600+
public void callbackDeleteWalletID(ResDefault res) {
601+
progress.dismiss();
602+
if(res.code != 0) {
603+
goPopUpError(res.message);
604+
return;
605+
}
606+
getEasyCardWalletList();
607+
}
608+
564609
private Executor executor;
565610
private BiometricPrompt biometricPrompt;
566611
private BiometricPrompt.PromptInfo promptInfo;

bootpay/src/main/java/kr/co/bootpay/bio/api/BioApiPresenter.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public class BioApiPresenter {
3131
ResWalletList walletList;
3232
ResReceiptID receiptID;
3333
ResponseBody easyConfirm;
34+
ResDefault deleteWalletID;
3435

3536
public BioApiPresenter(ApiService service, BootpayBioRestImplement callback) {
3637
this.service = service;
@@ -235,4 +236,42 @@ public void onError(Throwable e) {
235236
}
236237
});
237238
}
239+
240+
public void deleteCardWalletID(String deviceUUID, String userToken, String wallet_id) {
241+
final BioApiPresenter scope = this;
242+
243+
service.getApi().deleteCardWalletID(deviceUUID, userToken, wallet_id)
244+
.retry(1)
245+
.subscribeOn(Schedulers.from(Executors.newCachedThreadPool()))
246+
.subscribe(
247+
new Observer<ResDefault>() {
248+
@Override
249+
public void onComplete() {
250+
try {
251+
scope.parent.callbackDeleteWalletID(deleteWalletID);
252+
} catch (Exception ee) {
253+
ee.printStackTrace();
254+
}
255+
}
256+
257+
@Override
258+
public void onSubscribe(Disposable d) {
259+
260+
}
261+
262+
@Override
263+
public void onNext(ResDefault res) {
264+
deleteWalletID = res;
265+
}
266+
267+
@Override
268+
public void onError(Throwable e) {
269+
try {
270+
scope.parent.callbackDeleteWalletID(deleteWalletID);
271+
} catch (Exception ee) {
272+
ee.printStackTrace();
273+
}
274+
}
275+
});
276+
}
238277
}

bootpay/src/main/java/kr/co/bootpay/rest/BootpayBioRestImplement.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import kr.co.bootpay.model.res.ResEasyBiometric;
44
import kr.co.bootpay.model.res.ResReceiptID;
55
import kr.co.bootpay.model.res.ResWalletList;
6+
import kr.co.bootpay.rest.model.ResDefault;
67
import kr.co.bootpay.rest.model.RestEasyPayUserTokenData;
78
import kr.co.bootpay.rest.model.RestTokenData;
89

@@ -12,4 +13,5 @@ public interface BootpayBioRestImplement {
1213
void callbackEasyCardWallet(ResWalletList res);
1314
void callbackEasyCardRequest(ResReceiptID res);
1415
void callbackEasyTransaction(String data);
16+
void callbackDeleteWalletID(ResDefault res);
1517
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public void callbackEasyPayUserToken(RestEasyPayUserTokenData userToken) {
112112
BioPayload bioPayload = new BioPayload();
113113
bioPayload.setPg(PG.PAYAPP)
114114
.setName("bootpay test")
115-
.setPrice(89000.0) //최종 결제 금액
115+
.setPrice(1000.0) //최종 결제 금액
116116
.setOrder_id(String.valueOf(System.currentTimeMillis())) //개발사에서 관리하는 주문번호
117117
.setName("플리츠레이어 카라숏원피스")
118118
.setNames(Arrays.asList("플리츠레이어 카라숏원피", "블랙 (COLOR)", "55 (SIZE)")) //결제창에 나타날 상품목록

0 commit comments

Comments
 (0)