페이스북이 제공하는 결제 시스템에 대해 정리한다.
결제 시스템 이용 전에 Apps - Payments 페이지를 통해 회사 정보 / 은행 계좌 정보를 등록해야 한다. 공식사이트를 참고한다.
오픈 그래프의 타입인 og:product 오브젝트를 정의하는 단계이다.
페이스북 앱에서 제공할 수 있는 상품의 종류에는 아래와 같이 두 가지가 있다.
페이스북에서 권장하는 상품 판매 모델로써, 게임에서 쓰이는 코인의 개념이다. 유저는 코인을 구입한 후 이 코인을 통해 다른 상품을 구매할 수 있다. 이 방법을 권장하는 이유는 Price Jumping 현상을 방지하기 위해서이다.1) In-app Currency를 사용하면 코인 가격 조절을 통해 Price Jumping 현상에 쉽게 대처할 수 있게끔 해준다. 1코인당 0.10달러 정도로 설정하면 된다. (소수점 아래 둘째 자리까지 조절 가능하다) og:product는 다음과 같은 형태로 정의한다.
<!DOCTYPE html> <html> <head prefix= "og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# product: http://ogp.me/ns/product#"> <meta property="og:type" content="og:product" /> <meta property="og:title" content="Friend Smash Coin" /> <meta property="og:plural_title" content="Friend Smash Coins" /> <meta property="og:image" content="http://www.friendsmash.com/images/coin_600.png" /> <meta property="og:description" content="Friend Smash Coins to purchase upgrades and items!" /> <meta property="og:url" content="http://www.friendsmash.com/og/coins.html" /> <meta property="product:price:amount" content="0.30"/> <meta property="product:price:currency" content="USD"/> <meta property="product:price:amount" content="0.20"/> <meta property="product:price:currency" content="GBP"/> </head> </html>
페이스북 앱 내에서 직접 돈을 주고 구매할 수 있는 상품이다. 여러 가지 상품을 묶어 할인된 가격으로 판매하는 '스타터 팩'이 그 예이다. og:product는 다음과 같은 형태로 정의한다.
<html> <head prefix= "og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# product: http://ogp.me/ns/product#"> <meta property="og:type" content="og:product" /> <meta property="og:title" content="The Smashing Pack" /> <meta property="og:image" content="http://www.friendsmash.com/images/pack_600.png" /> <meta property="og:description" content="A smashing pack full of items!" /> <meta property="og:url" content="http://www.friendsmash.com/og/smashingpack.html" /> <meta property="product:price:amount" content="2.99"/> <meta property="product:price:currency" content="USD"/> <meta property="product:price:amount" content="1.99"/> <meta property="product:price:currency" content="GBP"/> </head> </html>
페이스북 결제 시스템에는 추가로 지불한 금액을 저장한 후 나중에 다시 사용하는 기능이 없다. 즉, 결제 시에는 지정한 금액만큼 지불하여야 한다. 예외로 페이스북 기프트 카드의 경우에는 결제한 후 남은 금액을 다시 사용할 수 있다.
가격에는 두 가지 종류가 있다.
말그대로 고정된 가격이다. 정적 가격을 사용하려면 og:product 오브젝트에 가격을 명시하면 된다. 가격은 여러 통화 단위로 정할 수 있으며 정하지 않은 통화 단위에 대해서는 페이스북에서 환율에 따라 가격을 자동으로 변환해준다.
상황이나 이벤트에 따라 변동 가능한 가격이다. og:product 오브젝트에 product:price:amount와 product:price:currency 메타 태그를 생략하면 된다. 동적 가격을 사용하면 Pay 다이얼로그를 열 때 앱 세팅의 Payments 페이지에 정의한 콜백 URL로 HTTP POST 요청을 보내게 된다. 그러므로 여기에 콜백 URL을 지정하지 않으면 안된다.
Product를 정의한 html을 사용하기 위해서는 Facebook이 scrape하는 과정이 필요하다. 이를 위해서는 facebook의 디버그 툴에 html의 URL을 적거나 직접 다음의 요청을 하면 된다.
GET https://graph.facebook.com/?id=OG_URL&scrape=true&method=post
OG_URL 대신 product의 URL을 적으면 된다.
레퍼런스를 참고한다. 이 중 중요한 옵션은 product, request_id 정도이다. product 옵션에는 og:product의 URL을 적으면 되는데 이 대신 ID를 적어도 된다.