Skip to content

Commit

Permalink
Merge pull request #50 from iamport/feat/card-direct
Browse files Browse the repository at this point in the history
feat : 카드사 다이렉트 추가 [PCM-437]
  • Loading branch information
kjh5833 authored Jan 12, 2022
2 parents 7134439 + 0821338 commit 44e66da
Show file tree
Hide file tree
Showing 19 changed files with 246 additions and 36 deletions.
7 changes: 5 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ dependencies {
//// Koin AndroidX Experimental features
// implementation "io.insert-koin:koin-androidx-ext:$Versions.koin_version"

implementation project(':sdk')
// implementation 'com.github.iamport:iamport-android:v1.1.0-hotfix04'
implementation project(':sdk') // 가맹점은 이 코드가 아닌 아래와 같은 "버전"을 통한 implementation 으로 반영해주세요
// implementation 'com.github.iamport:iamport-android:1.2.0'
// implementation 'com.github.iamport:iamport-android:fix~custom_data-SNAPSHOT'


}

36 changes: 32 additions & 4 deletions app/src/main/java/com/iamport/sampleapp/ViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ package com.iamport.sampleapp

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.iamport.sdk.data.sdk.IamPortRequest
import com.iamport.sdk.data.sdk.IamPortResponse
import com.iamport.sdk.data.sdk.PG
import com.iamport.sdk.data.sdk.PayMethod
import com.iamport.sdk.data.sdk.*
import com.iamport.sdk.domain.core.Iamport
import com.iamport.sdk.domain.utils.Event
import java.util.*
Expand All @@ -18,6 +15,7 @@ class ViewModel : ViewModel() {
var paymentName: String = ""
var merchantUid: String = ""
var amount: String = ""
var cardDirectCode: String = ""

val resultCallback = MutableLiveData<Event<IamPortResponse>>()
override fun onCleared() {
Expand All @@ -29,13 +27,43 @@ class ViewModel : ViewModel() {
* SDK 에 결제 요청할 데이터 구성
*/
fun createIamPortRequest(): IamPortRequest {
val card = if (cardDirectCode.isNotEmpty()) Card(Direct(code = cardDirectCode)) else null

return IamPortRequest(
pg = pg.makePgRawName(pgId = ""), // PG 사
pay_method = payMethod.name, // 결제수단
name = paymentName, // 주문명
merchant_uid = merchantUid, // 주문번호
amount = amount, // 결제금액
buyer_name = "남궁안녕",
card = card, // 카드사 다이렉트
custom_data = """
{
"employees": {
"employee": [
{
"id": "1",
"firstName": "Tom",
"lastName": "Cruise",
"photo": "https://jsonformatter.org/img/tom-cruise.jpg",
"cuppingnote": "[\"일\",\"이\",\"삼\",\"사\",\"오\",\"육\",\"칠\"]"
},
{
"id": "2",
"firstName": "Maria",
"lastName": "Sharapova",
"photo": "https://jsonformatter.org/img/Maria-Sharapova.jpg"
},
{
"id": "3",
"firstName": "Robert",
"lastName": "Downey Jr.",
"photo": "https://jsonformatter.org/img/Robert-Downey-Jr.jpg"
}
]
}
}
""".trimIndent()
// customer_uid = getRandomCustomerUid() // 정기결제
)
}
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/com/iamport/sampleapp/ui/PaymentFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ class PaymentFragment : BaseFragment<PaymentFragmentBinding>() {
viewModel.amount = it.toString()
}
viewDataBinding.amount.setText("1000")

viewDataBinding.cardDirectCode.doAfterTextChanged {
viewModel.cardDirectCode = it.toString()
}
}

override fun onStart() {
Expand Down
17 changes: 17 additions & 0 deletions app/src/main/res/layout/payment_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,23 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/merchant_uid" />



<EditText
android:id="@+id/card_direct_code"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginTop="15dp"
android:background="@color/white_12"
android:hint="카드사 다이렉트"
android:paddingStart="10dp"
android:textSize="16sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/amount" />



<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cert_parent"
android:layout_width="match_parent"
Expand Down
6 changes: 3 additions & 3 deletions buildSrc/src/main/java/Dependencies.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// 디펜던시 업데이트 확인 ./gradlew dependencyUpdates -Drevision=release
object Versions {
const val versionCode = 211108002 // yymmdd000
const val versionName = "1.2.0" // https://www.notion.so/chaifinance/QA-Process-d1a4be396337493b81c6e85fff2d5cd6
const val versionCode = 220112001 // yymmdd000
const val versionName = "1.3.0" // https://www.notion.so/chaifinance/QA-Process-d1a4be396337493b81c6e85fff2d5cd6

const val gradle_versions_plugin = "0.39.0"
const val gradle_version = "4.1.1"

const val multidex = "2.0.1"
const val kotlin_stdlib_jdk = "1.5.0"
const val kotlin_stdlib_jdk = "1.6.0"
const val core_ktx = "1.6.0"
const val appcompat = "1.3.1"

Expand Down
2 changes: 1 addition & 1 deletion sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ android {
buildToolsVersion "30.0.3"

defaultConfig {
minSdkVersion 16
minSdkVersion 21
targetSdkVersion 30
versionCode Versions.versionCode // yymmdd000
versionName Versions.versionName // prod(x.y.z), dev(x.y.z-dev00), poc(x.y.z-poc00)
Expand Down
60 changes: 57 additions & 3 deletions sdk/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,65 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

<!-- CHAI 앱 버전 가져오는 로직으로 인해 추가 -->
<queries>
<package android:name="finance.chai.app" />
<!--간편결제-->
<package android:name="finance.chai.app" /> <!--차이페이-->
<package android:name="com.nhnent.payapp" /> <!--페이코-->
<package android:name="com.lottemembers.android" /> <!--LPAY-->
<package android:name="com.ssg.serviceapp.android.egiftcertificate" /> <!--SSGPAY-->
<package android:name="com.inicis.kpay" /> <!--KPAY-->
<package android:name="com.tmoney.tmpay" /> <!--티머니페이-->
<package android:name="viva.republica.toss" /> <!--토스페이-->
<package android:name="com.samsung.android.spay" /> <!--삼성페이-->
<package android:name="com.kakao.talk" /> <!--카카오페이-->
<package android:name="com.nhn.android.search" /> <!--네이버-->
<package android:name="com.mysmilepay.app" /> <!--스마일페이-->
<!--카드-->
<package android:name="kvp.jjy.MispAndroid320" /> <!--ISP페이북-->
<package android:name="com.kbcard.cxh.appcard" /> <!--KBPay-->
<package android:name="com.kbstar.liivbank" /> <!--liivbank-->
<package android:name="com.kbstar.reboot" /> <!--newliiv-->
<package android:name="com.samsung.android.spaylite" /> <!--삼성페이니-->
<package android:name="com.nhnent.payapp" /> <!--페이코-->
<package android:name="com.lge.lgpay" /> <!--엘지페이-->
<package android:name="com.hanaskcard.paycla" /> <!--하나-->
<package android:name="kr.co.hanamembers.hmscustomer" /> <!--하나멤버스-->
<package android:name="com.hanaskcard.rocomo.potal" /> <!--하나공인인증-->
<package android:name="com.citibank.cardapp" /> <!--씨티-->
<package android:name="kr.co.citibank.citimobile" /> <!--씨티모바일-->
<package android:name="com.lcacApp" /> <!--롯데-->
<package android:name="kr.co.samsungcard.mpocket" /><!--삼성-->
<package android:name="com.shcard.smartpay" /> <!--신한-->
<package android:name="com.shinhancard.smartshinhan" /> <!--신한(ARS/일반/smart)-->
<package android:name="com.hyundaicard.appcard" /> <!--현재-->
<package android:name="nh.smart.nhallonepay" /> <!--농협-->
<package android:name="kr.co.citibank.citimobile" /> <!--씨티-->
<package android:name="com.wooricard.smartapp" /> <!--우리WON카드-->
<package android:name="com.wooribank.smart.npib" /> <!--우리WON뱅킹-->
<!--백신-->
<package android:name="com.TouchEn.mVaccine.webs" /> <!--TouchEn-->
<package android:name="com.ahnlab.v3mobileplus" /> <!--V3-->
<package android:name="kr.co.shiftworks.vguardweb" /> <!--vguard-->
<!--신용카드 공인인증-->
<package android:name="com.hanaskcard.rocomo.potal" /> <!--하나-->
<package android:name="com.lumensoft.touchenappfree" /> <!--현대-->
<!--계좌이체-->
<package android:name="com.kftc.bankpay.android" /> <!--뱅크페이-->
<package android:name="kr.co.kfcc.mobilebank" /> <!--MG 새마을금고-->
<package android:name="com.kbstar.liivbank" /> <!--뱅크페이-->
<package android:name="com.nh.cashcardapp" /> <!--뱅크페이-->
<package android:name="com.knb.psb" /> <!--BNK경남은행-->
<package android:name="com.lguplus.paynow" /> <!--페이나우-->
<package android:name="com.kbankwith.smartbank" /> <!--케이뱅크-->
<!--해외결제-->
<package android:name="com.eg.android.AlipayGphone" /> <!--페이나우-->
<!--기타-->
<package android:name="com.sktelecom.tauth" /> <!--PASS-->
<package android:name="com.lguplus.smartotp" /> <!--PASS-->
<package android:name="com.kt.ktauth" /> <!--PASS-->
<package android:name="kr.danal.app.damoum" /> <!--다날 다모음-->
</queries>

<application
Expand Down
18 changes: 18 additions & 0 deletions sdk/src/main/assets/iamportcdn.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,24 @@
IMP.request_pay(JSON.parse(impRequest), callback);
}


function requestPayWithCustomData(impRequest, customData) {
var data = JSON.parse(impRequest)

var decodeCustom = decodeURIComponent(escape(window.atob(customData)))
dLog(decodeCustom)

try {
data.custom_data = JSON.parse(decodeCustom)
} catch (error) {
dLog(error.message)
data.custom_data = decodeCustom
}

IMP.request_pay(data, callback);
}


function certification(impCertification) {
dLog("certification :: " + impCertification)
IMP.certification(JSON.parse(impCertification), callback);
Expand Down
18 changes: 18 additions & 0 deletions sdk/src/main/java/com/iamport/sdk/data/sdk/Card.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.iamport.sdk.data.sdk

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

/**
* for naverpay
*/

@Parcelize
data class Card(
val direct: Direct
) : Parcelable


@Parcelize
data class Direct(var code: String, var quota: Int? = null
) : Parcelable
1 change: 0 additions & 1 deletion sdk/src/main/java/com/iamport/sdk/data/sdk/CardQuota.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import kotlinx.parcelize.Parcelize
import kotlinx.serialization.Serializable

@Parcelize
@Serializable
data class CardQuota(val card_quota : List<Int>?) : Parcelable
//if (method === 'card' && cardQuota !== 0) {
// params.display = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import kotlinx.serialization.Serializable
* https://docs.iamport.kr/tech/mobile-authentication
*/
@Parcelize
@Serializable
data class IamPortCertification(
val merchant_uid: String,
val min_age: Int? = null,
Expand Down
10 changes: 5 additions & 5 deletions sdk/src/main/java/com/iamport/sdk/data/sdk/IamPortRequest.kt
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
package com.iamport.sdk.data.sdk

import android.os.Parcelable
import com.iamport.sdk.domain.utils.CONST
import com.iamport.sdk.domain.utils.Util
import kotlinx.parcelize.IgnoredOnParcel
import kotlinx.parcelize.Parcelize
import kotlinx.serialization.Serializable

/**
* SDK 에 결제 요청할 데이터
* https://docs.iamport.kr/tech/imp?lang=ko#param
*/

@Parcelize
@Serializable
data class IamPortRequest(
val pg: String,
val pay_method: String = PayMethod.card.name, // default card
Expand All @@ -22,6 +19,7 @@ data class IamPortRequest(
val customer_uid: String? = null, // 정기결제용
val name: String? = null,
val amount: String,
@Transient
val custom_data: String? = null,
val tax_free: Float? = null,
val currency: String? = null, // default KRW, 페이팔은 USD 이어야 함
Expand Down Expand Up @@ -52,10 +50,12 @@ data class IamPortRequest(
val cultureBenefit: Boolean? = null,
val naverInterface: NaverInterface? = null,

val card: Card? = null// 카드사 다이렉트 호출

) : Parcelable {

private var m_redirect_url: String? = Platform.native.redirectUrl // 콜백
private val niceMobileV2 : Boolean = true
private val niceMobileV2: Boolean = true

/**
* string pg 으로 enum PG 가져옴
Expand Down Expand Up @@ -115,7 +115,7 @@ data class IamPortRequest(
var app_scheme: String? = null // 명세상 nullable 이나, RN 에서 필수
var biz_num: String? = null
var popup: Boolean? = null // 명세상 없으나, RN 에 있음
private val niceMobileV2 : Boolean = true
private val niceMobileV2: Boolean = true

// 네이버 관련
var naverPopupMode: Boolean? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ https://docs.iamport.kr/tech/imp?lang=ko#param
// 모두 명세상 필수인지 모르겠음
// 이니시스 실시간 계좌이체 -> imp_success, success 없음?
@Parcelize
@Serializable
data class IamPortResponse(
val imp_success: Boolean? = false,
val success: Boolean? = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import kotlinx.serialization.Serializable
*/

@Parcelize
@Serializable
data class NaverInterface(
val cpaInflowCode: String?,
val naverInflowCode: String?,
Expand Down
Loading

0 comments on commit 44e66da

Please sign in to comment.