apps code bible ii_제 2회 hello, dev.square 개발자 세미나
DESCRIPTION
제 2회 Hello, Dev.Square 개발자 세미나, Apps Code Bible II 발표 자료TRANSCRIPT
2009. 11. 12
Apps Code Bible II
Custom APIs
1.일촌추천 UI- opensocial.requestShareApp
2.게시물로저장하기- openNate.minihpScrap
3. Payment- openNate.dotoriPayment
일촌초대하기 – opensocial.requestShareApp
일촌초대팝업 UI 또는직접호출을통해초대 feed 발송
opensocial.requestShareApp(recipients , message, opt_callback);opensocial.requestShareApp(recipients , null, opt_callback);opensocial.requestShareApp(null , message, opt_callback);opensocial.requestShareApp(null , null, opt_callback);
Sample code
* Methodopensocial.requestShareApp
* Parameterrecipients : 수신자 IDs, arraymessage : opensocial message 객체callbackFn : 콜백함수 (optional)
일촌초대하기 – opensocial.requestShareApp
ⓐ opensocial.requestShareApp(recipients , message, opt_callback);ⓑ opensocial.requestShareApp(recipients , null, opt_callback);ⓒ opensocial.requestShareApp(null , message, opt_callback);ⓓ opensocial.requestShareApp(null , null, opt_callback);
Sample code
1) 앱스토어 초대 기본 메시지 ex) 미니미님이 싸이앱스를 추천하였습니다.2) message : 앱스 지정 메시지 ex) 정말 좋아요3) 사용자 작성 메시지 ex) 야~ 나랑 앱스하자
hint)recipients 는 일촌초대 팝업 UI 사용 여부와 관련이 있음
openNate 시작하기
<Require feature="opennate" />
<?xml version="1.0" encoding="UTF-8" ?><Module>
<ModulePrefs><Require feature="opensocial-0.8" /><Require feature="opennate" />
</ModulePrefs><Content type="html"><![CDATA[
]]></Content>
</Module>
Sample code
게시물로저장하기 – openNate.minihpScrap
앱스에서생성된컨텐츠를미니홈피게시판에저장
var params = {};params[openNate.ScrapParameters.CONTENT] =
"<u>게시물</u>로 저장되는 내용";openNate.minihpScrap(params);
Sample code
* MethodopenNate.minihpScrap
* ParameteropenNate.ScrapParameters.CONTENT
* ReturnNone
Payment – openNate.dotoriPayment
앱스에서네이트도토리결제시스템이용
* MethodopenNate.dotoriPayment
* ParameteropenNate.PaymentParameters.ITEMTYPEopenNate.PaymentParameters.ITEMIDopenNate.PaymentParameters.ITEMNAMEopenNate.PaymentParameters.THUMBNAILopenNate.PaymentParameters.DOTORIopenNate.PaymentParameters.CALLBACKFNopenNate.PaymentParameters.PASSTHROUGHopenNate.PaymentParameters.CALLBACKURL
* Returnobject
Payment – openNate.dotoriPayment
* Return 객체paymentKeypassthroughstatusmessage
status message 설명
true Success 결제성공
ERR001 Communication error3rd party 서버와의통신상의오류
1단계통신중오류및 3rd party 프로세스실행중오류
ERR002 Dotori error 네이트도토리결제처리중오류
ERR003 Payment error네이트도토리결제처리이후 3rd party 서버프로세스실행중
오류 또는 2단계통신중오류
ERR004 Expired page 동일한결제에대한재요청발생
payment 데이터흐름
결제 팝업
3rd party 앱스
openNate.dotoriPayment 실행
도토리 부족알림 팝업
네이트 도토리충전 팝업
-payment_key 생성-결제 요청정보 저장
-request parameter 및shared key를 이용하여 hmac 키 생성
3rd party 서버 프로세스-passthrough 확인-Mac key 생성 후 비교-아이템 정보 임시 저장 등
response HTTP RC
결제 진행 결과 팝업- 에러 메시지
HTTP RC 확인ERR001
네이트 도토리 차감도토리 차감 결과 전송
3rd party 서버 프로세스-Passthrough, mac key 등 확인-사용자 아이템 구매 정보 저장
response HTTP RC
HTTP RC 확인
ERR002
ERR003 (고객센터)
결제 진행 결과 팝업- 결제 성공
결제 버튼 클릭
Popup UI
-계약정보 확인
callbackFN
1
2
3
4
5
6
7
89
10
13
11
12
1415
16
17
18
19
파라미터status – ready, accepted, failedpayment_keypassthroughuser_idapps_noitem_iditem_typeitem_nameitem_dotorimac
6 11
Payment – openNate.dotoriPayment
var params = {};params[openNate.PaymentParameters.ITEMTYPE] = “item_type”;params[openNate.PaymentParameters.ITEMID] = “item_id”;params[openNate.PaymentParameters.ITEMNAME] = “item_name”;params[openNate.PaymentParameters.THUMBNAIL] =
“image_thumbnail_url”;params[openNate.PaymentParameters.DOTORI] = “dotori”;params[openNate.PaymentParameters.CALLBACKFN] =
"callbackFunction";params[openNate.PaymentParameters.PASSTHROUGH] =
“generated passthrough";params[openNate.PaymentParameters.CALLBACKURL] =
"http://www.thirdparty.com/callback.php";
openNate.dotoriPayment(params);
Sample code
dotoriPayment API 활용
1
2
3
앱스에서dotoriPayment호출시 팝업 UI
네이트컨테이너결제 프로세스
Payment – 팝업 UI
Payment – 3rd party 로의 http request
callback URL : http://www.thirdparty.com/callback
parameters : payment_key=2059ec5f423caac343f6677de784d320&user_id=12345678&apps_no=10&item_id=3&item_type=COIN&item_name=test+item&item_dotori=10&status=ready&passthrough=kjse23fjs52fgsog34
shared key : opennate_payment_shared_key
generated MAC key : bcd9cf234c6cb711eb14d488ebe5d8e0
http request : http://www.thirdparty.com/callback?payment_key=2059ec5f423caac343f6677de784d320&user_id=12345678&apps_no=10&item_id=3&item_type=COIN&item_name=test+item&item_dotori=10&status=ready&passthrough=kjse23fjs52fgsog34&mac=bcd9cf234c6cb711eb14d488ebe5d8e0
Payment – hmac key 생성
C = callbackURL [eg " http://www.thirdparty.com/callback"]P = 파라미터 [eg "param1=value1¶m2=value2&...¶mN=valueN"]K = the shared secret keyH = md5
M = hash (K,P) = H ((K XOR opad) + H ((K XOR ipad) + P))
opad : outer padding (0x5c5c…5c5c, one-block-long hexadecimal constant) ipad : inner padding (0x3636…3636, one-block-long hexadecimal constant)
request (C,P,K) =" http://www.thirdparty.com/callback?param1=value1¶m2=value2&...¶mN=valueN&mac="+ M
RFC 2104 HMAC_MD5
Payment – 3rd party 서버프로세스
이것만은지키자.
1. Payment API 실행시 passthrough 값 생성
2. 전송된 passthrough 값이 서버에서 생성된 값인지 확인
3. Hmac key 생성 후 request parameter 중 mac 값과 비교
4. 아이템 구매 내역 로그 기록
5. Shared key 는 소중하게 관리
감사합니다.