Skip to content

Commit

Permalink
Showing 4 changed files with 154 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -171,7 +171,7 @@ class PaymentFragment : BaseFragment<PaymentFragmentBinding>() {
}

/**
* TODO 재고확인 등 최종결제를 위한 처리를 해주세요
* TODO: CHAI 결제시 재고확인 등 최종결제를 위한 처리를 해주세요
* CONST.CHAI_FINAL_PAYMENT_TIME_OUT_SEC 만큼 타임아웃 후 결제 데이터가
* 초기화 되기 때문에 타임아웃 시간 안에 Iamport.chaiPayment 함수를 호출해주셔야 합니다.
*/
61 changes: 53 additions & 8 deletions sdk/src/main/java/com/iamport/sdk/data/sdk/IamPortRequest.kt
Original file line number Diff line number Diff line change
@@ -39,10 +39,19 @@ data class IamPortRequest(
val app_scheme: String? = null, // 명세상 nullable 이나, RN 에서 필수
val biz_num: String? = null,
val popup: Boolean? = null,
private val niceMobileV2 : Boolean = true,

// 네이버 관련
val naverPopupMode: Boolean? = null,
val naverUseCfm: String? = null,
val naverProducts: List<ProductItem>? = null,
private val niceMobileV2 : Boolean = true
val naverProducts: List<BaseProductItem>? = null,
val naverCultureBenefit: Boolean? = null,
val naverProductCode: String? = null,
val naverActionType: String? = null,

val cultureBenefit: Boolean? = null,
val naverInterface: NaverInterface? = null,


) : Parcelable {

@@ -103,11 +112,19 @@ 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

// 네이버 관련
var naverPopupMode: Boolean? = null
var naverUseCfm: String? = null
var naverProducts: List<ProductItem>? = null
private val niceMobileV2 : Boolean = true
var naverProducts: List<BaseProductItem>? = null

var naverCultureBenefit: Boolean? = null
var naverProductCode: String? = null
var naverActionType: String? = null

var cultureBenefit: Boolean? = null
var naverInterface: NaverInterface? = null

fun pg(pg: String) = apply {
this.pg = pg
@@ -209,14 +226,35 @@ data class IamPortRequest(
this.naverPopupMode = naverPopupMode
}

fun naverProducts(naverProducts: List<ProductItem>) = apply {
fun naverUseCfm(naverUseCfm: String) = apply {
this.naverUseCfm = naverUseCfm
}

fun naverProducts(naverProducts: List<BaseProductItem>) = apply {
this.naverProducts = naverProducts
}

fun naverUseCfm(naverUseCfm: String) = apply {
this.naverUseCfm = naverUseCfm
fun naverCultureBenefit(naverCultureBenefit: Boolean) = apply {
this.naverCultureBenefit = naverCultureBenefit
}

fun naverProductCode(naverProductCode: String) = apply {
this.naverProductCode = naverProductCode
}

fun naverActionType(naverActionType: String) = apply {
this.naverActionType = naverActionType
}

fun cultureBenefit(cultureBenefit: Boolean) = apply {
this.cultureBenefit = cultureBenefit
}

fun naverInterface(naverInterface: NaverInterface) = apply {
this.naverInterface = naverInterface
}


fun build() = IamPortRequest(
pg,
pay_method,
@@ -242,8 +280,15 @@ data class IamPortRequest(
app_scheme,
biz_num,
popup,
niceMobileV2,
naverPopupMode,
naverUseCfm, naverProducts
naverUseCfm,
naverProducts,
naverCultureBenefit,
naverProductCode,
naverActionType,
cultureBenefit,
naverInterface
)
}
}
19 changes: 19 additions & 0 deletions sdk/src/main/java/com/iamport/sdk/data/sdk/NaverInterface.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.iamport.sdk.data.sdk

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

/**
* for naverpay
*/

@Parcelize
@Serializable
data class NaverInterface(
val cpaInflowCode: String?,
val naverInflowCode: String?,
val saClickId: String?,
val merchantCustomCode1: String?,
val merchantCustomCode2: String?,
) : Parcelable
86 changes: 81 additions & 5 deletions sdk/src/main/java/com/iamport/sdk/data/sdk/ProductItem.kt
Original file line number Diff line number Diff line change
@@ -2,22 +2,98 @@ package com.iamport.sdk.data.sdk

import android.os.Parcelable
import kotlinx.parcelize.Parcelize
import kotlinx.parcelize.RawValue
import kotlinx.serialization.Serializable

/**
* for naverpay
*/
@Parcelize
@Serializable
open class BaseProductItem : Parcelable

// 결제형
// https://github.com/iamport/iamport-manual/blob/master/NAVERPAY/sample/naverpay-pg.md#2-naverproducts-%ED%8C%8C%EB%9D%BC%EB%A9%94%ED%84%B0
// https://developer.pay.naver.com/docs/v1/api/payments
@Parcelize
@Serializable
data class ProductItem(
val categoryType: String,
val categoryId: String,
val uid: String,
val name: String,
val payReferrer: String?,
val startDate: String?,
val endDate: String?,
val sellerId: String?,
val count: Int?,
val payReferrer: String? = null,
val startDate: String? = null,
val endDate: String? = null,
val sellerId: String? = null,
val count: Int? = null,
) : Parcelable, BaseProductItem()

// 주문형
// https://github.com/iamport/iamport-manual/blob/master/NAVERPAY/sample/README.md#21-paramnaverproducts-%EC%9D%98-%EA%B5%AC%EC%A1%B0
@Parcelize
@Serializable
data class ProductItemForOrder(
val id: String, //상품고유ID
val merchantProductId: String? = null, //상품관리ID(필요한 경우만 선언. 정의하지 않으면 id값과 동일한 값을 자동 적용합니다)
val ecMallProductId: String? = null, //지식쇼핑상품관리ID(필요한 경우만 선언. 정의하지 않으면 id값과 동일한 값을 자동 적용합니다)
val name: String, //상품명
val basePrice: Int, //상품가격
val taxType: String? = null, //부가세 부과 여부(TAX or TAX_FREE)
val quantity: Int, //상품구매수량
val infoUrl: String, //상품상세페이지 URL
val imageUrl: String, //상품 Thumbnail 이미지 URL
val giftName: String? = null, //해당상품 구매시 제공되는 사은품 명칭(없으면 정의하지 않음)
val options: List<Option>? = null, //구매자가 선택한 상품 옵션에 대한 상세 정보
val supplements: List<Supplement>? = null,
val shipping: Shipping? = null, //상품 배송관련 상세 정보
) : Parcelable, BaseProductItem()


// 확실치 않은 정보들은 nullable 처리.. 어차피 네이버가 따로 검수!
@Parcelize
@Serializable
data class Option(
val optionQuantity: Int,
val optionPrice: Int? = null,
val selectionCode: String? = null,
val selections: List<Selection>? = null,
) : Parcelable


@Parcelize
@Serializable
data class Selection(
val code: String? = null,
val label: String? = null,
val value: String? = null,
) : Parcelable


@Parcelize
@Serializable
data class Supplement(
val id: String? = null, //추가구성품의 ID
val name: String? = null, //추가구성품 상품명
val price: Int? = null, //추가구성품 가격
val quantity: Int? = null //추가구성품 수량
) : Parcelable


@Parcelize
@Serializable
data class Shipping(
val groupId: String? = null,
val method: String? = null,
val baseFee: Int? = null,
val feeRule: List<FeeRule>? = null,
val feePayType: String? = null,
) : Parcelable


@Parcelize
@Serializable
data class FeeRule(
val freeByThreshold: Int? = null,
) : Parcelable

0 comments on commit 2e01979

Please sign in to comment.