Skip to content

Commit a6cb3bd

Browse files
author
ehowlsla
committed
인앱 충돌 현상 제거를 위한 기존 작업 커밋
1 parent d9bab74 commit a6cb3bd

File tree

21 files changed

+668
-125
lines changed

21 files changed

+668
-125
lines changed

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import kr.co.bootpay.model.RemoteLink;
2828
import kr.co.bootpay.model.Request;
2929
import kr.co.bootpay.model.BootUser;
30+
import kr.co.bootpay.model.SMSPayload;
3031
import kr.co.bootpay.pref.UserInfo;
3132
import kr.co.bootpay.valid.PGAvailable;
3233
import kr.co.bootpay.valid.ValidRequest;
@@ -201,6 +202,13 @@ public BootpayBuilder setRemoteLinkInfo(RemoteLink remoteLink) {
201202
// return this;
202203
// }
203204

205+
public BootpayBuilder setSMSPayload(SMSPayload smsPayload) {
206+
request.setSmsPayload(smsPayload);
207+
return this;
208+
}
209+
210+
// public BootpayBuild
211+
204212
public BootpayBuilder setMethod(String method) {
205213
request.setMethod(method);
206214
return this;
@@ -211,6 +219,11 @@ public BootpayBuilder setMethods(List<String> methods) {
211219
return this;
212220
}
213221

222+
public BootpayBuilder setSmsUse(Integer sms_use) {
223+
request.setSmsUse(sms_use);
224+
return this;
225+
}
226+
214227

215228

216229
// public BootpayBuilder setExtraStartAt(String startAt) {
@@ -366,8 +379,8 @@ private void validCheck() {
366379
if (isEmpty(request.getOrder_id()))
367380
error("Order id is not configured.");
368381

369-
if (listener == null && (error == null || cancel == null || confirm == null || done == null))
370-
error("Must to be required to handel events.");
382+
// if (listener == null && (error == null || cancel == null || confirm == null || done == null))
383+
// error("Must to be required to handel events.");
371384

372385
UX ux = request.getUX();
373386
if(ux == null || ux == UX.NONE) { request.setUx(UX.PG_DIALOG.name()); }

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ internal class BootpayWebView @JvmOverloads constructor(context: Context, attrs:
202202
// private fun userPhone() = request?.bootUser?.phone?.takeIf(String::isNotEmpty)?.let { "phone: '$it'" } ?: ""
203203
private fun userJson() = request?.bootUser?.let { "user_info: ${it.toJson()}" } ?: ""
204204
private fun extraJson() = request?.bootExtra?.let { "bootExtra: ${it.toJson()}" } ?: ""
205-
private fun remoteLinkJson() = request?.remote_link?.let { "remte_link_info: ${it.toJson()}" } ?: ""
205+
private fun remoteLinkJson() = request?.remoteLink?.let { "remte_link_info: ${it.toJson()}" } ?: ""
206206

207207

208208

@@ -255,7 +255,7 @@ internal class BootpayWebView @JvmOverloads constructor(context: Context, attrs:
255255
private fun methods() = request?.methods?.let { "methods: ${listToString(it)}"} ?:""
256256

257257
private fun items() = "items:${
258-
request?.items?.map { "{item_name:'${it.name.replace("\"", "'").replace("'", "\\'")}',qty:${it.qty},unique:'${it.unique}',price:${it.price},cat1:'${it.cat1.replace("\"", "'").replace("'", "\\'")}',cat2:'${it.cat2.replace("\"", "'").replace("'", "\\'")}',cat3:'${it.cat3.replace("\"", "'").replace("'", "\\'")}'}" }
258+
request?.items?.map { "{item_name:'${it.item_name.replace("\"", "'").replace("'", "\\'")}',qty:${it.qty},unique:'${it.unique}',price:${it.price},cat1:'${it.cat1.replace("\"", "'").replace("'", "\\'")}',cat2:'${it.cat2.replace("\"", "'").replace("'", "\\'")}',cat3:'${it.cat3.replace("\"", "'").replace("'", "\\'")}'}" }
259259
}"
260260

261261
private fun orderId() = request?.order_id?.let { "order_id:'$it'" } ?: ""

bootpay/src/main/java/kr/co/bootpay/api/BootpayPresenter.kt

Lines changed: 132 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package kr.co.bootpay.api
33
import android.content.Context
44
import android.util.Log
55
import com.google.gson.Gson
6+
import kr.co.bootpay.enums.UX
7+
import kr.co.bootpay.model.RemoteOrderForm
68
import kr.co.bootpay.model.Request
79
import kr.co.bootpay.pref.UserInfo
810
import rx.Scheduler
@@ -15,66 +17,161 @@ internal class BootpayPresenter(context: Context) {
1517
private val executor: Scheduler by lazy { Schedulers.from(Executors.newCachedThreadPool()) }
1618

1719
fun request(request: Request) {
18-
// rest.
19-
20-
// rest.api.purchase()
20+
var ux = request.getUX()
21+
request.bootExtra?.setUX(ux.name)
22+
if(ux == UX.BOOTPAY_REMOTE_LINK) {
23+
request_link(request)
24+
} else if(ux == UX.BOOTPAY_REMOTE_ORDER) {
25+
request_form(request)
26+
} else if(ux == UX.BOOTPAY_REMOTE_PRE) {
27+
request_pre(request)
28+
}
29+
}
2130

31+
fun request_link(request: Request) {
2232
// var phone: String = request.bootUser?.getPhone() ?: ""
23-
var userJson = request.bootUser?.toJson() ?: ""
24-
var extraJson = request.bootExtra?.toJson() ?: ""
25-
var remoteLinkJson = request.remote_link?.toJson() ?: ""
26-
27-
28-
// var userInfo = userInfo(
29-
// userName(request),
30-
// userEmail(request),
31-
// userAddr(request),
32-
// userPhone(request)
33-
// )
34-
// var bootExtra = bootExtra(
35-
// extraExpireMonth(request),
36-
// extraVBankResult(request),
37-
// extraQuota(request),
38-
// extraAppScheme(request)
39-
// )
40-
41-
42-
rest.api.request(
33+
var userJson = request.bootUser?.toGson() ?: ""
34+
var extraJson = request.bootExtra?.toGson() ?: ""
35+
var remoteLinkJson = request.remoteLink?.toGson() ?: ""
36+
var methods = request.methods ?: mutableListOf()
37+
var sms_payload = request.smsPayload?.toGson() ?: ""
38+
39+
// Log.d("print", Gson().toJson(methods))
40+
rest.api.request_link(
4341
request.application_id,
4442
"2", // Android
4543
request.method,
46-
request.methods ?: listOf(),
44+
Gson().toJson(methods),
4745
request.pg,
4846
request.price,
4947
request.tax_free,
5048
request.name,
51-
request.items,
49+
Gson().toJson(request.items),
5250
request.is_show_agree,
53-
// phone,
5451
UserInfo.bootpay_uuid,
5552
UserInfo.bootpay_sk,
5653
System.currentTimeMillis(),
57-
userJson ?: "",
54+
userJson,
5855
UserInfo.bootpay_user_id,
5956
request.boot_key,
6057
params(request),
6158
request.order_id,
6259
request.use_order_id,
6360
request.account_expire_at,
64-
extraJson ?: "",
65-
remoteLinkJson
61+
extraJson,
62+
remoteLinkJson,
63+
request.smsUse,
64+
sms_payload
6665
)
67-
.retry(3)
68-
.subscribeOn(executor)
69-
.subscribe({
70-
Log.d("Success------", it.toString())
71-
// System.out.println(it)
72-
}, Throwable::printStackTrace)
66+
.retry(3)
67+
.subscribeOn(executor)
68+
.subscribe({
69+
Log.d("Success------", it.toString())
70+
}, Throwable::printStackTrace)
71+
}
72+
73+
fun request_form(request: Request) {
74+
var userJson = request.bootUser?.toGson() ?: ""
75+
var extraJson = request.bootExtra?.toGson() ?: ""
76+
var remoteFormJson = request.remote_form?.toGson() ?: ""
77+
var methods = request.methods ?: mutableListOf()
78+
var sms_payload = request.smsPayload?.toGson() ?: ""
79+
80+
if(remoteFormJson.length == 0) {
81+
var form = RemoteOrderForm().setName(request.name).setItemPrice(request.price).setPG(request.pg)
82+
request.methods?.let { form.setMethods(it) }
83+
remoteFormJson = form.toGson()
84+
} else {
85+
request.remote_form?.let {
86+
if(it.pg.isEmpty()) { it.pg = request.pg }
87+
if(it.fm.size == 0) { request.methods?.let { methods -> it.fm = methods }}
88+
if(it.ip == 0.0) { it.ip = request.price }
89+
if(it.n.isEmpty()) { it.n = request.name }
90+
remoteFormJson = it.toGson()
91+
}
92+
}
93+
7394

95+
rest.api.request_form(
96+
request.application_id,
97+
"2", // Android
98+
request.method,
99+
Gson().toJson(methods),
100+
request.pg,
101+
request.price,
102+
request.tax_free,
103+
request.name,
104+
Gson().toJson(request.items),
105+
request.is_show_agree,
106+
UserInfo.bootpay_uuid,
107+
UserInfo.bootpay_sk,
108+
System.currentTimeMillis(),
109+
userJson,
110+
UserInfo.bootpay_user_id,
111+
request.boot_key,
112+
params(request),
113+
request.order_id,
114+
request.use_order_id,
115+
request.account_expire_at,
116+
extraJson,
117+
remoteFormJson,
118+
request.smsUse,
119+
sms_payload
120+
)
121+
.retry(3)
122+
.subscribeOn(executor)
123+
.subscribe({
124+
Log.d("Success------", it.toString())
125+
}, Throwable::printStackTrace)
74126
}
75127

128+
fun request_pre(request: Request) {
129+
var userJson = request.bootUser?.toGson() ?: ""
130+
var extraJson = request.bootExtra?.toGson() ?: ""
131+
var remotePreJson = request.remote_pre?.toGson() ?: ""
132+
var methods = request.methods ?: mutableListOf()
133+
var sms_payload = request.smsPayload?.toGson() ?: ""
134+
135+
136+
rest.api.request_pre(
137+
request.application_id,
138+
"2", // Android
139+
request.method,
140+
Gson().toJson(methods),
141+
request.pg,
142+
request.price,
143+
request.tax_free,
144+
request.name,
145+
Gson().toJson(request.items),
146+
request.is_show_agree,
147+
UserInfo.bootpay_uuid,
148+
UserInfo.bootpay_sk,
149+
System.currentTimeMillis(),
150+
userJson,
151+
UserInfo.bootpay_user_id,
152+
request.boot_key,
153+
params(request),
154+
request.order_id,
155+
request.use_order_id,
156+
request.account_expire_at,
157+
extraJson,
158+
remotePreJson,
159+
request.smsUse,
160+
sms_payload
161+
)
162+
.retry(3)
163+
.subscribeOn(executor)
164+
.subscribe({
165+
Log.d("Success------", it.toString())
166+
}, Throwable::printStackTrace)
167+
168+
}
169+
170+
76171
fun params(request: Request) = request?.params?.takeIf(String::isNotEmpty)?.let {Gson().toJson(it)} ?: ""
77172
fun userInfo(vararg info: String) = "{${info.filter(String::isNotEmpty).joinToString()}}"
173+
174+
78175
// fun userName(request: Request) = request?.user_name?.takeIf(String::isNotEmpty)?.let { "username: '$it'" } ?: ""
79176
// fun userEmail(request: Request) = request?.user_email?.takeIf(String::isNotEmpty)?.let { "email: '$it'" } ?: ""
80177
// fun userAddr(request: Request) = request?.user_addr?.takeIf(String::isNotEmpty)?.let { "addr: '$it'" } ?: ""

bootpay/src/main/java/kr/co/bootpay/api/BootpayRestApi.kt

Lines changed: 64 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,77 @@ import retrofit2.http.*
77
import rx.Observable
88

99
internal interface BootpayRestApi {
10+
@FormUrlEncoded
11+
@POST("/app/rest/remote_link")
12+
fun request_link(
13+
@Field("application_id") application_id: String,
14+
@Field("device_type") device_type: String,
15+
@Field("method") method: String,
16+
@Field("methods") methods: String,
17+
@Field("pg") pg: String,
18+
@Field("price") price: Double, // 결제금액
19+
@Field("tax_free") tax_free: Double, // 비과세 금액
20+
@Field("name") name: String, // 상품명
21+
@Field("items") items: String,
22+
@Field("show_agree_window") show_agree_window: Boolean,
23+
@Field("uuid") uuid: String,
24+
@Field("sk") sk: String,
25+
@Field("time") time: Long,
26+
@Field("user_info") user_info: String,
27+
@Field("user_id") user_id: String,
28+
@Field("boot_key") boot_key: String,
29+
@Field("params") params: String,
30+
@Field("order_id") order_id: String,
31+
@Field("use_order_id") use_order_id: Int,
32+
@Field("account_expire_at") account_expire_at: String,
33+
@Field("bootExtra") extra: String,
34+
@Field("remote_link") remote_link: String,
35+
@Field("sms_use") sms_use: Int,
36+
@Field("sms_payload") sms_payload: String
37+
): Observable<ResDefault>
38+
39+
@FormUrlEncoded
40+
@POST("/app/rest/remote_form")
41+
fun request_form(
42+
@Field("application_id") application_id: String,
43+
@Field("device_type") device_type: String,
44+
@Field("method") method: String,
45+
@Field("methods") methods: String,
46+
@Field("pg") pg: String,
47+
@Field("price") price: Double, // 결제금액
48+
@Field("tax_free") tax_free: Double, // 비과세 금액
49+
@Field("name") name: String, // 상품명
50+
@Field("items") items: String,
51+
@Field("show_agree_window") show_agree_window: Boolean,
52+
@Field("uuid") uuid: String,
53+
@Field("sk") sk: String,
54+
@Field("time") time: Long,
55+
@Field("user_info") user_info: String,
56+
@Field("user_id") user_id: String,
57+
@Field("boot_key") boot_key: String,
58+
@Field("params") params: String,
59+
@Field("order_id") order_id: String,
60+
@Field("use_order_id") use_order_id: Int,
61+
@Field("account_expire_at") account_expire_at: String,
62+
@Field("bootExtra") extra: String,
63+
@Field("remote_form") remote_form: String,
64+
@Field("sms_use") sms_use: Int,
65+
@Field("sms_payload") sms_payload: String
66+
): Observable<ResDefault>
1067

1168
@FormUrlEncoded
12-
@POST("/app/rest")
13-
fun request(
69+
@POST("/app/rest/remote_pre")
70+
fun request_pre(
1471
@Field("application_id") application_id: String,
1572
@Field("device_type") device_type: String,
1673
@Field("method") method: String,
17-
@Field("methods") methods: List<String>,
74+
@Field("methods") methods: String,
1875
@Field("pg") pg: String,
1976
@Field("price") price: Double, // 결제금액
2077
@Field("tax_free") tax_free: Double, // 비과세 금액
2178
@Field("name") name: String, // 상품명
22-
@Field("items") items: List<Item>,
79+
@Field("items") items: String,
2380
@Field("show_agree_window") show_agree_window: Boolean,
24-
// @Field("phone") phone: String,
2581
@Field("uuid") uuid: String,
2682
@Field("sk") sk: String,
2783
@Field("time") time: Long,
@@ -33,6 +89,8 @@ internal interface BootpayRestApi {
3389
@Field("use_order_id") use_order_id: Int,
3490
@Field("account_expire_at") account_expire_at: String,
3591
@Field("bootExtra") extra: String,
36-
@Field("remote_link") remote_link: String
92+
@Field("remote_pre") remote_pre: String,
93+
@Field("sms_use") sms_use: Int,
94+
@Field("sms_payload") sms_payload: String
3795
): Observable<ResDefault>
3896
}

bootpay/src/main/java/kr/co/bootpay/enums/PushPolicyType.kt

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package kr.co.bootpay.enums
2+
3+
4+
class PushType {
5+
companion object {
6+
const val SMS = 1
7+
const val LMS = 2
8+
const val MMS = 3
9+
const val KAKAO_A = 4 // 알림톡
10+
const val KAKAO_C = 5 // 친구톡
11+
const val PUSH = 10
12+
13+
}
14+
}

0 commit comments

Comments
 (0)