96 lines
3.2 KiB
Plaintext
96 lines
3.2 KiB
Plaintext
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
|
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
|
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
|
|
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
|
|
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
|
|
<%@ taglib prefix="ui" uri="http://www.winbit.kr/ctl/ui"%>
|
|
<%@ taglib prefix="f" uri="/WEB-INF/tlds/f.tld"%>
|
|
|
|
<%--
|
|
Class Name : PayTossPayEasyC.jsp
|
|
Description : 간편결제창
|
|
Modification Information
|
|
|
|
수정일 수정자 수정내용
|
|
------- -------- ---------------------------
|
|
2024-06-12 이경숙 최초 생성
|
|
--%>
|
|
<!-- 토스페이먼츠 JSP 결제 샘플 소스코드 -->
|
|
<!DOCTYPE html>
|
|
<html lang="ko">
|
|
<head>
|
|
<title>구매하기</title>
|
|
<meta charset="UTF-8" />
|
|
<meta http-equiv="x-ua-compatible" content="ie=edge" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
|
|
<link rel="stylesheet" href="./bulma.min.css" />
|
|
|
|
<script src="https://js.tosspayments.com/v1"></script>
|
|
</head>
|
|
|
|
<body>
|
|
<section class="hero is-link">
|
|
<div class="hero-body">
|
|
<div class="container">
|
|
<h1 class="title">토스페이먼츠 연동 샘플</h1>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
<section class="section">
|
|
<div class="container">
|
|
<button class="button is-link" onclick="pay('카드',jsons.card,'토스페이');">토스페이</button>
|
|
|
|
<button class="button is-link" onclick="pay('카드',jsons.card,'페이코');">페이코</button> 페이코은 토스에서 지원하지 않는 간편결제라고 함. 확인이 필요함.
|
|
</div>
|
|
</section>
|
|
</body>
|
|
|
|
<script>
|
|
let amount = 50000;
|
|
let easyPay = "";
|
|
|
|
//let tossPayments = TossPayments("test_ck_D5GePWvyJnrK0W0k6q8gLzN97Eoq"); //개발가이드
|
|
let tossPayments = TossPayments("test_ck_0RnYX2w5322yZWP2kbBR3NeyqApQ"); //durmj2
|
|
|
|
function pay(method, requestJson,easyPay) {
|
|
console.log(requestJson);
|
|
|
|
requestJson.easyPay=easyPay;
|
|
|
|
tossPayments.requestPayment(method, requestJson).catch(function (error) {
|
|
if (error.code === "USER_CANCEL") {
|
|
alert("유저가 취소했습니다.");
|
|
} else {
|
|
alert(error.message);
|
|
}
|
|
});
|
|
}
|
|
|
|
let successUrl = window.location.origin + "/sopmal/pay/tossPaySuccss"; //"http://localhost:18110/sopmal/pay/PayFail",
|
|
let failUrl = window.location.origin + "/sopmal/pay/PayFail"; //"http://localhost:18110/sopmal/pay/PayFail",
|
|
let orderId = new Date().getTime();
|
|
|
|
let jsons = {
|
|
card: {
|
|
amount: amount,
|
|
orderId: "sample-" + orderId,
|
|
orderName: "토스 티셔츠 외 2건",
|
|
successUrl: successUrl,
|
|
failUrl: failUrl,
|
|
cardCompany: null,
|
|
cardInstallmentPlan: null,
|
|
maxCardInstallmentPlan: null,
|
|
useCardPoint: false,
|
|
customerName: "박토스",
|
|
customerEmail: null,
|
|
customerMobilePhone: null,
|
|
taxFreeAmount: null,
|
|
useInternationalCardOnly: false,
|
|
flowMode: "DIRECT",
|
|
discountCode: null,
|
|
appScheme: null,
|
|
easyPay: easyPay,
|
|
},
|
|
};
|
|
</script>
|
|
</html> |