Skip to content

Commit a7c9c9a

Browse files
committed
support onestore pay
1 parent eae3ec2 commit a7c9c9a

28 files changed

+730
-104
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import com.google.android.gms.ads.identifier.AdvertisingIdClient;
1515

16+
import kr.co.bootpay.model.BootUser;
1617
import kr.co.bootpay.pref.UserInfo;
1718

1819
public class Bootpay {
@@ -28,6 +29,9 @@ public static void useOnestoreApi(Context context) {
2829
useOnestoreApi(context, true);
2930
}
3031

32+
33+
34+
3135
public static void useOnestoreApi(Context context, Boolean enable) {
3236
if(enable == false) {
3337
UserInfo.getInstance(context).setEnableOneStore(enable);

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

Lines changed: 50 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import com.google.gson.Gson;
1010

11+
import java.util.ArrayList;
1112
import java.util.List;
1213

1314
import kr.co.bootpay.api.ApiPresenter;
@@ -46,6 +47,7 @@ public class BootpayBuilder {
4647
private ConfirmListener confirm;
4748
private BootpayDialog dialog;
4849
private ApiPresenter presenter;
50+
// private String
4951

5052

5153
private BootpayBuilder() {}
@@ -130,6 +132,10 @@ public BootpayBuilder setPG(PG pg) {
130132
case PAYCO:
131133
request.setPG("payco");
132134
break;
135+
case ONESTORE:
136+
request.setPG("onestore");
137+
break;
138+
133139
}
134140
return this;
135141
}
@@ -272,48 +278,56 @@ public BootpayBuilder setMethods(List<String> methods) {
272278
// }
273279

274280
public BootpayBuilder setMethod(Method method) {
281+
request.setMethod(getMethodString(method));
282+
return this;
283+
}
284+
285+
public BootpayBuilder setMethodList(List<Method> methods) {
286+
List<String> methodList = new ArrayList<>();
287+
for(Method method : methods) {
288+
methodList.add(getMethodString(method));
289+
}
290+
291+
request.setMethods(methodList);
292+
return this;
293+
}
294+
295+
private String getMethodString(Method method) {
296+
275297
switch (method) {
276298
case CARD:
277-
request.setMethod("card");
278-
break;
299+
return "card";
279300
case CARD_SIMPLE:
280-
request.setMethod("card_simple");
281-
break;
301+
return "card_simple";
282302
case BANK:
283-
request.setMethod("bank");
284-
break;
303+
return "bank";
285304
case VBANK:
286-
request.setMethod("vbank");
287-
break;
305+
return "vbank";
288306
case PHONE:
289-
request.setMethod("phone");
290-
break;
307+
return "phone";
291308
case SELECT:
292-
request.setMethod("");
293-
break;
309+
return "";
294310
case SUBSCRIPT_CARD:
295-
request.setMethod("card_rebill");
296-
break;
311+
return "card_rebill";
297312
case SUBSCRIPT_PHONE:
298-
request.setMethod("phone_rebill");
299-
break;
313+
return "phone_rebill";
300314
case AUTH:
301-
request.setMethod("auth");
302-
break;
315+
return "auth";
303316
case EASY:
304-
request.setMethod("easy");
305-
break;
317+
return "easy";
306318
case PAYCO:
307-
request.setMethod("payco");
308-
break;
319+
return "payco";
309320
case KAKAO:
310-
request.setMethod("kakao");
311-
break;
321+
return "kakao";
312322
case NPAY:
313-
request.setMethod("npay");
314-
break;
323+
return "npay";
324+
case EASY_CARD:
325+
return "easy_card";
326+
case EASY_BANK:
327+
return "easy_bank";
328+
315329
}
316-
return this;
330+
return "";
317331
}
318332

319333
public BootpayBuilder setAccountExpireAt(String account_expire_at) {
@@ -402,6 +416,11 @@ public BootpayBuilder setUX(UX ux) {
402416
return this;
403417
}
404418

419+
public BootpayBuilder setEasyPayUserToken(String userToken) {
420+
request.setEasyPayUserToken(userToken);
421+
return this;
422+
}
423+
405424
// public BootpayBuilder setAppScheme(String appScheme) {
406425
// request.setExtra_app_scheme(appScheme);
407426
// return this;
@@ -462,6 +481,8 @@ public void request() {
462481
UserInfo.getInstance(context).update();
463482

464483
Bootpay.builder.request = ValidRequest.validUXAvailablePG(context, Bootpay.builder.request);
484+
485+
465486
UX ux = request.getUX();
466487
if(PGAvailable.isUXPGDefault(ux)) requestDialog();
467488
else if(PGAvailable.isUXPGSubscript(ux)) {
@@ -574,4 +595,6 @@ private boolean isEmpty(String value) {
574595
private void error(String message) {
575596
throw new RuntimeException(message);
576597
}
598+
599+
577600
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import android.util.Log;
99
import android.widget.Toast;
1010

11-
import kr.co.bootpay.app2app.payapp.Payload;
11+
import kr.co.bootpay.app2app.payapp.IntentPayload;
1212
import kr.co.bootpay.model.Request;
1313
import kr.co.bootpay.pref.UserInfo;
1414

@@ -47,8 +47,8 @@ void startApp2App() {
4747

4848
void startPayapp() {
4949
try {
50-
Payload payload = new Payload(this, Bootpay.builder.request);
51-
Intent intent = new Intent(Intent.ACTION_VIEW, payload.toIntentUri());
50+
IntentPayload intentPayload = new IntentPayload(this, Bootpay.builder.request);
51+
Intent intent = new Intent(Intent.ACTION_VIEW, intentPayload.toIntentUri());
5252
startActivityForResult(intent, 1);
5353
} catch (Exception e) {
5454
Log.d("intent", e.getMessage());

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ private static void pgHashInit() {
2222
pgHash.put("TPAY", "tpay");
2323
pgHash.put("페이레터", "payletter");
2424
pgHash.put("KICC", "easypay");
25+
pgHash.put("원스토어", "onestore");
2526

2627
}
2728

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

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import android.webkit.WebView;
2626
import android.webkit.WebViewClient;
2727
import android.widget.FrameLayout;
28-
import android.widget.LinearLayout;
2928

3029
import java.net.URISyntaxException;
3130
import java.util.List;
@@ -37,7 +36,7 @@
3736
import kr.co.bootpay.pref.UserInfo;
3837

3938
public class BootpayWebView extends WebView {
40-
private static final String BOOTPAY = "https://inapp.bootpay.co.kr/3.2.1/production.html";
39+
private static final String BOOTPAY = "https://inapp.bootpay.co.kr/3.2.3/production.html";
4140

4241
private Dialog dialog;
4342
// private ConnectivityManager connManager;
@@ -124,13 +123,14 @@ public void onPageFinished(WebView view, String url) {
124123
setAnalyticsData();
125124

126125
// setDevelopMode();
127-
useOneStoreApi();
126+
// useOneStoreApi();
128127

129128
Log.d("bootpay", "onPageFinished");
130129

131130
loadParams(
132131
request(
133132
price(),
133+
easyPayUserToken(),
134134
applicationId(),
135135
name(),
136136
pg(),
@@ -160,6 +160,8 @@ public void onPageFinished(WebView view, String url) {
160160
public boolean shouldOverrideUrlLoading(WebView view, String url) {
161161
Intent intent = parse(url);
162162

163+
Log.d("bootpay url", url);
164+
163165
if (isIntent(url)) {
164166
if (isExistInfo(intent, view.getContext()) || isExistPackage(intent, view.getContext()))
165167
return start(intent, view.getContext());
@@ -319,15 +321,18 @@ private void setDevelopMode() {
319321
}
320322

321323

322-
private void useOneStoreApi() {
323-
if(UserInfo.getInstance(this.getContext()).getEnableOneStore()) {
324-
load(String.format(Locale.KOREA,
325-
"window.BootPay.useOnestoreApi({ad_id: '%s', sim_operation: '%s', installerPackageName: '%s'});"
326-
, UserInfo.getInstance(this.getContext()).getAdId()
327-
, UserInfo.getInstance(this.getContext()).getSimOperator()
328-
, UserInfo.getInstance(this.getContext()).getInstallPackageMarket()));
329-
}
330-
}
324+
// private void useOneStoreApi() {
325+
// if(request != null && "onestore".equals(request.getPG())) {
326+
327+
// }
328+
// if(UserInfo.getInstance(this.getContext()).getEnableOneStore()) {
329+
// load(String.format(Locale.KOREA,
330+
// "window.BootPay.useOnestoreApi({ad_id: '%s', sim_operation: '%s', installerPackageName: '%s'});"
331+
// , UserInfo.getInstance(this.getContext()).getAdId()
332+
// , UserInfo.getInstance(this.getContext()).getSimOperator()
333+
// , UserInfo.getInstance(this.getContext()).getInstallPackageMarket()));
334+
// }
335+
// }
331336

332337
private boolean startMarket(Intent intent) {
333338
Intent market = new Intent(Intent.ACTION_VIEW);
@@ -365,6 +370,11 @@ private String price() {
365370
return "price:" + request.getPrice();
366371
}
367372

373+
private String easyPayUserToken() {
374+
return String.format(Locale.KOREA, "user_token:'%s'", request.getEasyPayUserToken());
375+
376+
}
377+
368378
private String applicationId() { return String.format(Locale.KOREA, "application_id:'%s'", request.getApplicationId()); }
369379

370380
private String name() {
@@ -414,8 +424,8 @@ private String userJson() {
414424
}
415425

416426
private String extraJson() {
417-
if(request.getBoot_extra() == null) return "";
418-
if(request.getBoot_extra().toJson().length() == 0) return "";
427+
if(request.getBootExtra(getContext()) == null) return "";
428+
if(request.getBootExtra(getContext()).toJson().length() == 0) return "";
419429
return String.format(Locale.KOREA, "extra: %s", request.getBoot_extra().toJson());
420430
}
421431

@@ -477,7 +487,9 @@ private void loadParams(String... script) {
477487
for (String s : script) builder.append(s);
478488
builder.append(";");
479489
String request = builder.toString();
480-
Log.d("params", request);
490+
491+
// Log.d("params", request);
492+
481493
load(request);
482494
}
483495

0 commit comments

Comments
 (0)