• 테스트 결제 imPort 사이트

 

  • 카카오페이 복붙

https://github.com/iamport/iamport-manual/blob/master/%EC%9D%B8%EC%A6%9D%EA%B2%B0%EC%A0%9C/sample/kakao.md

 

GitHub - iamport/iamport-manual: 아임포트(iamport) 결제연동을 위한 매뉴얼입니다.

아임포트(iamport) 결제연동을 위한 매뉴얼입니다. Contribute to iamport/iamport-manual development by creating an account on GitHub.

github.com

 

 

cart.html 
<script type="text/javascript" src="https://cdn.iamport.kr/js/iamport.payment-1.2.0.js"></script>​
<script>
  $(function () {
    $('a.checkout').click(function (e) {
      e.preventDefault(); // a태그 이동 정지
      $.get('/cart/clear', {}, function () {}); //카트 클리어 요청
      //$("form#paypalform").submit();
      kakaoPay();
    });
  });
  function kakaoPay() {
    var IMP = window.IMP; // 생략 가능
    IMP.init('가맹점식별코드'); // 예: imp00000000
    IMP.request_pay(
      {
        pg: 'kakaopay',
        //pay_method : 'card', //생략 가능
        merchant_uid: 'order_no_0001', // 상점에서 관리하는 주문 번호
        name: '주문명:결제테스트',
        amount: '[[${ctotal}]]',
        buyer_email: 'iamport@siot.do',
        buyer_name: '구매자이름',
        buyer_tel: '010-1234-5678',
        buyer_addr: '서울특별시 강남구 삼성동',
        buyer_postcode: '123-456',
      },
      function (rsp) {
        if (rsp.success) {
          let msg = '결제가 완료되었습니다.';
          msg += '고유ID : ' + rsp.imp_uid;
          msg += '상점 거래ID : ' + rsp.merchant_uid;
          msg += '결제 금액 : ' + rsp.paid_amount;
          msg += '카드 승인번호 : ' + rsp.apply_num;
          if (!alert(msg)) location.reload();
        } else {
          let msg = '결제에 실패하였습니다.';
          msg += '에러내용 : ' + rsp.error_msg;
          alert(msg);
        }
      }
    );
  }
</script>
☆ 주문할때마다 오더 넘버 다르게해야 결제가 됨
merchant_uid: 'order_no_0001' 

 

 

 

- import 사이트에서 관리자콘솔에 들어가 로그인하기

 

가맹점 식별코드 복붙해서 붙이기

IMP.init('가맹점식별코드');    // 예: imp00000000 

 

 

 

 

- 카카오페이 테스트모드로 설정해야 실제로 결제가 안됨!

 

 

 

- 체크아웃 버튼 눌렀을때

카카오페이 결제

 

 

결제완료

 

 

 

 

- import 사이트의 결제승인내역 확인가능

 

 

 

 

결제후 결제성공 페이지 payment_success.html 로 넘어가는법은..??

반응형
LIST

+ Recent posts