์ฌ์ ์ค๋น
- ์ ํ๋ฆฌ์ผ์ด์ ๋ฑ๋ก
- https://developers.kakaopay.com/applications
- ํค ๋ฐ๊ธ๋ฐ๊ธฐ
- ๊ด๋ จ ๋ฌธ์ ํฌ๋ผ
- https://developers.kakaopay.com/forum/
2024 ์นด์นด์คํ์ด API ์ธ์ฆ์ ์ฌ์ฉํ ๊ฐ
- ์ธ์ฆ ์คํค๋ง
- (๊ตฌ) "KakaoAK " -> (์ ) " SECRET_KEY "
- Secret Key๊ฐ์ ํ ์คํธ์ ๊ฒฝ์ฐ Secret Key(dev) ์ฌ์ฉํ๊ธฐ
์นด์นด์คํ์ด ๊ฒฐ์ ๊ตฌํ ๊ณผ์
- OrderInfoDTO : ์ฌ์ฉ์ ์ฃผ๋ฌธ ์ ๋ณด
- KakaoPaymentReadyRequestDTO : ์นด์นด์ค ๊ฒฐ์ ์ค๋น ์์ฒญ์ ํ์ํ Body๊ฐ
- PaymentInfo : ๊ฒฐ์ ์ ๋ณด ์ํฐํฐ
[ ์์ ์ฝ๋ ๋๋ณด๊ธฐ ๐ฝ ]
๋๋ณด๊ธฐ
OrderInfoDTO
@ToString
@Getter
@Setter
@NoArgsConstructor
public class OrderInfoDTO {
private Integer point_100_Quantity;
private Integer point_1000_Quantity;
private String paymentMethod; // ๊ฒฐ์ ๋ฐฉ๋ฒ
private String paymentId; // ๊ฒฐ์ ID
public OrderInfoDTO(Integer point_100_Quantity, Integer point_1000_Quantity, String paymentMethod, String paymentId) {
this.point_100_Quantity = point_100_Quantity;
this.point_1000_Quantity = point_1000_Quantity;
this.paymentMethod = paymentMethod;
this.paymentId = paymentId;
}
}
KakaoPaymentReadyRequestDTO
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class KakaoPaymentReadyRequestDTO {
private String cid;
private String cid_secret;
private String partner_order_id;
private String partner_user_id;
private String item_name;
private String item_code;
private Integer quantity;
private Integer total_amount;
private Integer tax_free_amount;
private Integer vat_amount;
private Integer green_deposit;
private String approval_url;
private String cancel_url;
private String fail_url;
private List<String> available_cards;
private String payment_method_type;
private Integer install_month;
private String use_share_installment;
private Map<String, String> custom_json;
}
PaymentInfo
@Entity
@Getter
@NoArgsConstructor
@Table(name = "payment_info")
public class PaymentInfo extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "payment_info_id")
private Long id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id")
private RBUser user; // ์ฌ์ฉ์ ID
private String aid; // ์์ฒญ ๊ณ ์ ๋ฒํธ - ์น์ธ/์ทจ์๊ฐ ๊ตฌ๋ถ๋ ๊ฒฐ์ ๋ฒํธ
private String tid; // ๊ฒฐ์ ๊ณ ์ ๋ฒํธ - ์น์ธ/์ทจ์๊ฐ ๋์ผํ ๊ฒฐ์ ๋ฒํธ
private String partnerOrderId; // ๊ฐ๋งน์ ์ฃผ๋ฌธ๋ฒํธ
private String partnerUserId; // ๊ฐ๋งน์ ํ์ ID
@Enumerated(EnumType.STRING) // Enum ๊ฐ์ ๋ฌธ์์ด๋ก ์ ์ฅ
private PaymentStatus status; // ๊ฒฐ์ ์ํ
private String itemName;
private String itemCode;
private Integer totalPointAmount; // ๊ณ ๊ฐ์ด ๊ตฌ๋งคํ๋ ์ด ํฌ์ธํธ ๊ธ์ก
private Integer totalAmount; // ์ํ ์ด์ก, ์ ํ์ ์ฌ์ฉ
private LocalDateTime createdAt; // ๊ฒฐ์ ์ค๋น ์์ฒญ ์๊ฐ
private LocalDateTime approvedAt; // ๊ฒฐ์ ์น์ธ ์๊ฐ
@Embedded
private Amount amount;
@Embedded
private CardInfo cardInfo;
public void setUser(RBUser user) {
if (this.user != null) {
this.user.getGameRecords().remove(this);
}
this.user = user;
}
public void firstPaymentInformation(RBUser user, String partnerOrderId, String partnerUserId,
String itemName, String itemCode, Integer totalAmount, Integer totalPointAmount) {
this.user = user;
this.partnerOrderId = partnerOrderId;
this.partnerUserId = partnerUserId;
this.itemName = itemName;
this.itemCode = itemCode;
this.totalAmount = totalAmount;
this.totalPointAmount = totalPointAmount;
}
public void updatePaymentStatus(PaymentStatus status) {
this.status = status;
}
public void secondPaymentInformation(String tid, LocalDateTime createdAt) {
this.tid = tid;
this.createdAt = createdAt;
}
public void thirdPaymentInformation(String aid, Amount amount, CardInfo cardInfo, LocalDateTime approvedAt) {
this.aid = aid;
this.amount = amount;
this.cardInfo = cardInfo;
this.approvedAt = approvedAt;
}
}
- KakaoPaymentReadyResponseDTO : ๊ฒฐ์ ์ค๋น์ ๋ํ ์๋ต
[ ์์ ์ฝ๋ ๋๋ณด๊ธฐ ๐ฝ ]
๋๋ณด๊ธฐ
KakaoPaymentReadyResponseDTO
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
@JsonIgnoreProperties(ignoreUnknown = true)
public class KakaoPaymentReadyResponseDTO {
private String tid;
private String next_redirect_app_url;
private String next_redirect_mobile_url;
private String next_redirect_pc_url;
private String android_app_scheme;
private String ios_app_scheme;
private boolean tms_result;
private LocalDateTime created_at;
}
- KakaoPaymentApproveRequestDTO : ๊ฒฐ์ ์น์ธ์ ์ํ ์์ฒญ body
[ ์์ ์ฝ๋ ๋๋ณด๊ธฐ ๐ฝ ]
๋๋ณด๊ธฐ
KakaoPaymentApproveRequestDTO
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class KakaoPaymentApproveRequestDTO {
private String cid; // ๊ฐ๋งน์ ์ฝ๋
private String cid_secret; // ๊ฐ๋งน์ ์ฝ๋ ์ธ์ฆํค
private String tid; // ๊ฒฐ์ ๊ณ ์ ๋ฒํธ
private String partner_order_id; // ๊ฐ๋งน์ ์ฃผ๋ฌธ๋ฒํธ
private String partner_user_id; // ๊ฐ๋งน์ ํ์ id
private String pg_token; // ๊ฒฐ์ ์น์ธ ์์ฒญ์ ์ธ์ฆํ๋ ํ ํฐ
private String payload; // ๊ฒฐ์ ์น์ธ ์์ฒญ์ ๋ํด ์ ์ฅํ๊ณ ์ถ์ ๊ฐ
private Integer total_amount; // ์ํ ์ด์ก
public KakaoPaymentApproveRequestDTO(String cid, String tid, String partner_order_id, String partner_user_id, String pg_token) {
this.cid = cid;
this.tid = tid;
this.partner_order_id = partner_order_id;
this.partner_user_id = partner_user_id;
this.pg_token = pg_token;
}
}
- KakaoPaymentApproveResponseDTO : ์ฑ๊ณต ์ ์๋ต bady ๋ด๊ธฐ
[ ์์ ์ฝ๋ ๋๋ณด๊ธฐ ๐ฝ ]
๋๋ณด๊ธฐ
KakaoPaymentApproveResponseDTO
- money ๊ฒฐ์ -> Amount
- card๊ฒฐ์ -> CardInfo
KakaoPaymentApproveResponseDTO
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
@JsonIgnoreProperties(ignoreUnknown = true)
public class KakaoPaymentApproveResponseDTO {
private String aid;
private String tid;
private String cid;
private String sid; // ํ๋ ์ถ๊ฐ (๊ตฌ API์์๋ง ํ์ํ์)
private String partnerOrderId;
private String partnerUserId;
private String paymentMethodType;
private String itemName;
private int quantity;
private LocalDateTime createdAt;
private LocalDateTime approvedAt;
private Amount amount; // ๊ธ์ก ์ ๋ณด
private CardInfo cardInfo; // ์นด๋ ์ ๋ณด, ๊ฒฐ์ ์๋จ์ด ์นด๋์ผ ๋๋ง ์กด์ฌ
}
@Embeddable
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class Amount {
private Integer total;
private Integer taxFree;
private Integer vat;
private Integer point;
private Integer discount;
private Integer greenDeposit;
private Integer taxFreeAmount; // ๋น๊ณผ์ธ ๊ธ์ก
private Integer vatAmount; // ๋ถ๊ฐ์ธ ๊ธ์ก
}
@Embeddable
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class CardInfo {
private String kakaopayPurchaseCorp;
private String kakaopayPurchaseCorpCode;
private String kakaopayIssuerCorp;
private String kakaopayIssuerCorpCode;
private String bin;
private String cardType;
private String installMonth;
private String approvedId;
private String cardMid;
private String interestFreeInstall;
private String installmentType;
private String cardItemCode;
}
- ์ค๋ช ์ด๋ฏธ์ง ํตํฉ๋ณธ PDF
๊ตฌํ ๊ณผ์ ์์ ๊ฒช์ ์ค๋ฅ
์ปจํธ๋กค๋ฌ ์์ฒญ ์์