Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Enhance Customers Payment Experience with LINE Pay API

Enhance Customers Payment Experience with LINE Pay API

LINE Thailand Developer Conference 2019
https://www.facebook.com/events/410021356453349/

LINE Developers

June 04, 2019
Tweet

More Decks by LINE Developers

Other Decks in Technology

Transcript

  1. “LINE API EXPERT” (LAE) LINE API Expert is a program

    that recognizes skilled engineers who have a deep understanding of the APIs provided by LINE and are influential in the community by giving them the title of "LINE API experts"
  2. • LINE Messaging API • LINE Frontend Framework • LINE

    Beacon • Rabbit LINE Pay API LAE IN THAILAND
  3. LET’S START • Create Sandbox Account • API Endpoint &

    Headers • Reserve API • Confirm API • Others API • Transaction ➩
  4. • Create Sandbox Account • API Endpoint & Headers •

    Reserve API • Confirm API • Others API • Transaction ➩ API ENDPOINT & HEADERS
  5. API ENDPOINT & HEADERS API Endpoint Sandbox https://sandbox-api-pay.line.me Production https://api-pay.line.me

    Headers Content-Type application/json X-LINE-ChannelId {channel-id} X-LINE-ChannelSecret {channel-secret-key}
  6. • Create Sandbox Account • API Endpoint & Headers •

    Reserve API • Confirm API • Others API • Transaction ➩ RESERVE API
  7. RESERVE API Request JSON Body Params Required Description productName Y

    Product name (charset: UTF-8) productImageUrl Product image URL amount Y Payment amount currency Y [USD / JPY / TWD / THB] orderId Y Unique reference number confirmUrl Y Callback/Redirect URL confirmUrlType [CLIENT / SERVER] payType [NORMAL / PREAPPROVED] langCd [en / ko / ja / th / zh-Hans /zh-Hant] capture [true / false]
  8. RESERVE API Request JSON Body Params Required Description productName Y

    Product name (charset: UTF-8) productImageUrl Product image URL amount Y Payment amount currency Y [USD / JPY / TWD / THB] orderId Y Unique reference number confirmUrl Y Callback/Redirect URL confirmUrlType [CLIENT / SERVER] payType [NORMAL / PREAPPROVED] langCd [en / ko / ja / th / zh-Hans /zh-Hant] capture [true / false]
  9. RESERVE API Request JSON Body Params Required Description productName Y

    Product name (charset: UTF-8) productImageUrl Product image URL amount Y Payment amount currency Y [USD / JPY / TWD / THB] orderId Y Unique reference number confirmUrl Y Callback/Redirect URL confirmUrlType [CLIENT / SERVER] payType [NORMAL / PREAPPROVED] langCd [en / ko / ja / th / zh-Hans /zh-Hant] capture [true / false]
  10. RESERVE API Request JSON Body Params Required Description productName Y

    Product name (charset: UTF-8) productImageUrl Product image URL amount Y Payment amount currency Y [USD / JPY / TWD / THB] orderId Y Unique reference number confirmUrl Y Callback/Redirect URL confirmUrlType [CLIENT / SERVER] payType [NORMAL / PREAPPROVED] langCd [en / ko / ja / th / zh-Hans /zh-Hant] capture [true / false]
  11. RESERVE API Request JSON Body Params Required Description productName Y

    Product name (charset: UTF-8) productImageUrl Product image URL amount Y Payment amount currency Y [USD / JPY / TWD / THB] orderId Y Unique reference number confirmUrl Y Callback/Redirect URL confirmUrlType [CLIENT / SERVER] payType [NORMAL / PREAPPROVED] langCd [en / ko / ja / th / zh-Hans /zh-Hant] capture [true / false]
  12. RESERVE API Request JSON Body Params Required Description productName Y

    Product name (charset: UTF-8) productImageUrl Product image URL amount Y Payment amount currency Y [USD / JPY / TWD / THB] orderId Y Unique reference number confirmUrl Y Callback/Redirect URL confirmUrlType [CLIENT / SERVER] payType [NORMAL / PREAPPROVED] langCd [en / ko / ja / th / zh-Hans /zh-Hant] capture [true / false]
  13. RESERVE API Request JSON Body Params Required Description productName Y

    Product name (charset: UTF-8) productImageUrl Product image URL amount Y Payment amount currency Y [USD / JPY / TWD / THB] orderId Y Unique reference number confirmUrl Y Callback/Redirect URL confirmUrlType [CLIENT / SERVER] payType [NORMAL / PREAPPROVED] langCd [en / ko / ja / th / zh-Hans /zh-Hant] capture [true / false]
  14. RESERVE API Request JSON Body Params Required Description productName Y

    Product name (charset: UTF-8) productImageUrl Product image URL amount Y Payment amount currency Y [USD / JPY / TWD / THB] orderId Y Unique reference number confirmUrl Y Callback/Redirect URL confirmUrlType [CLIENT / SERVER] payType [NORMAL / PREAPPROVED] langCd [en / ko / ja / th / zh-Hans /zh-Hant] capture [true / false]
  15. RESERVE API Request JSON Body Params Required Description productName Y

    Product name (charset: UTF-8) productImageUrl Product image URL amount Y Payment amount currency Y [USD / JPY / TWD / THB] orderId Y Unique reference number confirmUrl Y Callback/Redirect URL confirmUrlType [CLIENT / SERVER] payType [NORMAL / PREAPPROVED] langCd [en / ko / ja / th / zh-Hans /zh-Hant] capture [true / false]
  16. RESERVE API Request JSON Body Params Required Description productName Y

    Product name (charset: UTF-8) productImageUrl Product image URL amount Y Payment amount currency Y [USD / JPY / TWD / THB] orderId Y Unique reference number confirmUrl Y Callback/Redirect URL confirmUrlType [CLIENT / SERVER] payType [NORMAL / PREAPPROVED] langCd [en / ko / ja / th / zh-Hans /zh-Hant] capture [true / false]
  17. RESERVE API function reservePayment(req, res) { const { productName, amount,

    orderId } = req.body; const url = `…/v2/payments/request`; const payload = { productImageUrl:IMAGE_URL, productName, amount, orderId, currency: 'THB', confirmUrl: `${config.apiUrl}/confirmPayment`, langCd: 'th', confirmUrlType: 'SERVER', };
  18. RESERVE API { "returnCode": "0000", "returnMessage": "Success.", "info": { "paymentUrl":

    { "web": "https://sandbox-web-pay.line.me/web/ payment/wait?transactionReserveId=xxxxx", "app": "line://pay/payment/xxxxx" }, "transactionId": 2019052400052785400, "paymentAccessToken": "636329400726" } } Response
  19. RESERVE API { "returnCode": "0000", "returnMessage": "Success.", "info": { "paymentUrl":

    { "web": "https://sandbox-web-pay.line.me/web/ payment/wait?transactionReserveId=xxxxx", "app": "line://pay/payment/xxxxx" }, "transactionId": 2019052400052785400, "paymentAccessToken": "636329400726" } } Response
  20. • Create Sandbox Account • API Endpoint & Headers •

    Reserve API • Confirm API • Others API • Transaction ➩ CONFIRM API
  21. CONFIRM API HTTP Request POST /v2/payments/{transactionId}/confirm Request JSON Body Params

    Required Description amount Y Payment amount currency Y [USD / JPY / TWD / THB]
  22. CONFIRM API function confirmPayment(req, res) { const { transactionId }

    = req.body; const url = `…/v2/payments/${transactionId}/confirm`; const order = await readDB(transactionId); const body = { amount: order.amount, currency: order.currency, }; return rp({ method: 'POST', uri: url, body, headers, json: true, }); };
  23. CONFIRM API { "returnCode": "0000", "returnMessage": "Success.", "info": { "transactionId":

    2019052400052787200, "orderId": "1558643411038", "payInfo": [ { "method": "CREDIT_CARD", "amount": 138 } ] } } Response
  24. CONFIRM API if (response && response.returnCode === '0000') { data.status

    = 'paid'; saveOrder(orderId, data); line.pushMessage(data.userId, { type: 'text', text: 'ได้รับชําระเงินเรียบร้อยแล้ว', }); }
  25. • Create Sandbox Account • API Endpoint & Headers •

    Reserve API • Confirm API • Others API • Transaction ➩ OTHERS API
  26. RESERVE API Request JSON Body Params Required Description productName Y

    Product name (charset: UTF-8) productImageUrl Product image URL amount Y Payment amount currency Y [USD / JPY / TWD / THB] orderId Y Unique reference number confirmUrl Y Callback/Redirect URL confirmUrlType [CLIENT / SERVER] payType [NORMAL / PREAPPROVED] langCd [en / ko / ja / th / zh-Hans /zh-Hant] capture [true / false]
  27. CAPTURE API RESERVE CAPTURE_WAIT AUTH CANCEL CAPTURE Reserve API User

    Confirm API capture=true capture=false Capture API
  28. CAPTURE API HTTP Request POST /v2/payments/authorizations/{transactionId}/capture Request JSON Body Params

    Required Description amount Y Payment amount currency Y [USD / JPY / TWD / THB]
  29. CAPTURE API { "returnCode": "0000", "returnMessage": "OK", "info": { "transactionId":

    20140101123123123, "orderId": "order_210124213", "payInfo": [{ "method": "BALANCE", "amount": 10 },{ "method": "DISCOUNT", "amount": 10 }] } } Response
  30. CAPTURE API RESERVE CAPTURE_WAIT AUTH CANCEL CAPTURE Reserve API User

    Confirm API capture=true capture=false Capture API
  31. VOID API RESERVE CAPTURE_WAIT AUTH CANCEL CAPTURE Reserve API User

    Confirm API capture=true capture=false Void API VOID Capture API
  32. VOID API RESERVE CAPTURE_WAIT AUTH CANCEL CAPTURE Reserve API User

    Confirm API capture=true capture=false Void API VOID Capture API
  33. REFUND API RESERVE CAPTURE_WAIT AUTH CANCEL CAPTURE Reserve API User

    Confirm API capture=true capture=false Void API VOID Capture API
  34. REFUND API RESERVE CAPTURE_WAIT AUTH CANCEL CAPTURE Reserve API User

    Confirm API capture=true capture=false REFUND Refund API Void API VOID Capture API
  35. REFUND API HTTP Request POST /v2/payments/{transactionId}/refund Request JSON Body Params

    Required Description refundAmount Full refund if params not passed
  36. REFUND API { "returnCode": "0000", "returnMessage": "success", "info": { "refundTransactionId":

    123123123123, "refundTransactionDate": "2014-01-01T06:17:41Z" } } Response
  37. REFUND API RESERVE CAPTURE_WAIT AUTH CANCEL CAPTURE Reserve API User

    Confirm API capture=true capture=false REFUND Refund API Void API VOID Capture API
  38. PREAPPROVED API RESERVE CAPTURE_WAIT AUTH CANCEL CAPTURE Reserve API User

    Confirm API capture=true capture=false Capture API Void API VOID REFUND Refund API Preapproved API
  39. RESERVE API Request JSON Body Params Required Description productName Y

    Product name (charset: UTF-8) productImageUrl Product image URL amount Y Payment amount currency Y [USD / JPY / TWD / THB] orderId Y Unique reference number confirmUrl Y Callback/Redirect URL confirmUrlType [CLIENT / SERVER] payType [NORMAL / PREAPPROVED] langCd [en / ko / ja / th / zh-Hans /zh-Hant] capture [true / false]
  40. CONFIRM API (PREAPPROVED) { "returnCode": "0000", "returnMessage": "Success.", "info": {

    "transactionId": 2019052400052787200, "orderId": "1558643411038", "payInfo": [ { "method": "CREDIT_CARD", "amount": 138 } ], "regKey": "RKf930b19XTF1TX" } } Response
  41. PREAPPROVED API RESERVE CAPTURE_WAIT AUTH CANCEL CAPTURE Reserve API User

    Confirm API capture=true capture=false Capture API Void API VOID REFUND Refund API Preapproved API
  42. PREAPPROVED API HTTP Request POST /v2/payments/preapprovedPay/{regKey}/payment Request JSON Body Params

    Required Description productName Y Product name (charset: UTF-8) amount Y Payment amount currency Y [USD / JPY / TWD / THB] orderId Y Unique reference number capture [true / false]
  43. PREAPPROVED API { "returnCode": "0000", "returnMessage": "OK", "info": { "transactionId":

    123123123123, "transactionDate": "2014-01-01T06:17:41Z" } } Response
  44. PREAPPROVED API RESERVE CAPTURE_WAIT AUTH CANCEL CAPTURE Reserve API User

    Confirm API capture=true capture=false Capture API Void API VOID REFUND Refund API Preapproved API
  45. GET API HTTP Request GET /v2/payments Request JSON Body Params

    Required Description transactionId[] List of transaction IDs orderId[] List of order IDs
  46. GET API { "returnCode": "0000", "returnMessage": "success", "info": [{ "transactionId":

    1020140728100001997, "transactionDate": "2014-07-28T09:48:43Z", "transactionType": "PAYMENT", "payInfo": [{ "method": "BALANCE", "amount": 10 },{ "method": "DISCOUNT", "amount": 10 }], "productName": "tes production", "currency": "USD", "orderId": "20140101123123123", } ] } { "returnCode": "0000", "returnMessage": "success", "info": [ { "transactionId": 1020140728100001997, "transactionDate": "2014-07-28T09:48:43Z", "transactionType": "PARTIAL_REFUND", "amount": -5, "productName": "", "currency": "USD", "orderId": "20140101123123123", "originalTransactionId": 1020140728100001999 } ] } Response Response
  47. • Create Sandbox Account • API Endpoint & Headers •

    Reserve API • Confirm API • Others API • Transaction ➩ TRANSACTIONS