### Offerwall Detail Request Example Source: https://github.com/linkprice/affiliatesetup/blob/master/docs/오퍼월_쇼핑적립_연동_가이드.md This is an example of an HTTP GET request to retrieve detailed information for a specific merchant within the Offerwall. ```http GET https://api.linkprice.com/offerwall/{a_id}/detail ``` -------------------------------- ### Fetch Offerwall Guide Data with cURL Source: https://context7.com/linkprice/affiliatesetup/llms.txt This cURL command retrieves the usage guide and FAQ data for the Linkprice Offerwall in JSON format. ```bash # ── 이용 가이드 및 FAQ ── curl "https://api.linkprice.com/offerwall/A100000131/guide?\nmode=json&u_id=member_12345" ``` -------------------------------- ### Example JSON Response for Reward List Source: https://context7.com/linkprice/affiliatesetup/llms.txt This is an example of the JSON response structure for the expected reward list, including details about offerwall configuration, categories, banners, and individual reward items. ```json // 메인 응답 예시 (mode=json) { "offerwall_conf": { "m_type": "3", "is_unique_uid": "N" }, "offerwall_categories": { "": "전체", "EV": "이벤트", "1": "종합쇼핑몰", "10": "금융" }, "offerwall_cards": [ { "merchant_id": "11st", "site_name": "11번가", "cate_order": 1, "event_flag": "Y", "category_code": "1", "banner_url": "https://img.linkprice.com/files/glink/11st/logo.png", "max_commission": "0.59%" } ], "offerwall_banners": { "top": [ { "banner_size": "320x100", "order_num": 1, "banner_url": "https://img.linkprice.com/banner.gif", "merchant_id": "cjbrand" } ] }, "u_id": "member_12345", "commission": "50000", "affiliateId": "A100000131", "c_name": "포인트", "c_unit": "P" } // 예상 적립금 응답 예시 { "reward_list": [ { "yyyymmdd": "20250715", "merchant_id": "clickbuy3", "site_name": "메이크샵 테스트2", "order_code": "A", "sales": 60000, "commission": 1600, "reward_yyyymm": "202509" } ], "total_reward": 2400, "yyyymm": "202507", "yyyymms": ["202507", "202506", "202505", "202504", "202503", "202502"] } ``` -------------------------------- ### Transaction List API Request Example Source: https://github.com/linkprice/affiliatesetup/blob/master/docs/실적_조회_오픈_API_v1.6.md This example demonstrates how to request a list of transactions from the Linkprice Affiliate API. Ensure you replace placeholders like [A코드(사이트코드)] and [인증키] with your actual credentials. The yyyymmdd parameter specifies the date for which to retrieve transactions. ```json GET https://api.linkprice.com/affiliate/translist.php?a_id=[A코드(사이트코드)]&auth_key=[인증키]&yyyymmdd=20231120 { "result": "0", "list_count": 2, "order_list": [ { "trlog_id": "18000406750585", "m_id": "clickbuy", "o_cd": "recover_231019_182249", "p_cd": "recover_231019_182249", "p_nm": "pn_recover_5", "it_cnt": "1", "user_id": "u_id_recover_5", "status": "100", "c_cd": "test_c_cd", "create_time_stamp": "20231020", "applied_pgm_id": "0038", "yyyymmdd": "20231017", "hhmiss": "000000", "trans_comment": "", "sales": 39900, "commission": 1, "pgm_name": "tt_mo", "is_pc": "mobile", "pur_rate": "1원" }, { "trlog_id": "18000406750586", "m_id": "clickbuy", "o_cd": "recover_231019_182243", "p_cd": "recover_231019_182243", "p_nm": "pn_recover_4", "it_cnt": "1", "user_id": "u_id_recover_4", "status": "100", "c_cd": "test_c_cd", "create_time_stamp": "20231020", "applied_pgm_id": "0038", "yyyymmdd": "20231017", "hhmiss": "000000", "trans_comment": "", "sales": 39900, "commission": 1, "pgm_name": "tt_mo", "is_pc": "mobile", "pur_rate": "1원" } ] } ``` -------------------------------- ### 조회 오류시 응답 예 Source: https://github.com/linkprice/affiliatesetup/blob/master/docs/실적_조회_오픈_API_v1.6.md This example shows the response when a required parameter, such as the inquiry date (yyyymmdd), is missing from the request. ```json GET https://api.linkprice.com/affiliate/translist.php?a_id=[A코드(사이트코드)]&auth_key=[인증키] { "result": "200", "list_count": 0, "order_list": [] } ``` -------------------------------- ### Shopping Rewards API HTTP Request Source: https://github.com/linkprice/affiliatesetup/blob/master/docs/오퍼월_쇼핑적립_연동_가이드.md This is an example of an HTTP GET request to retrieve shopping rewards information. It requires the affiliate ID in the path. ```http GET https://api.linkprice.com/offerwall/{a_id}/guide ``` -------------------------------- ### Linkprice Merchant Detail Response Example Source: https://context7.com/linkprice/affiliatesetup/llms.txt This JSON shows the structure of the response when requesting detailed information about a merchant, including settlement terms and advertising restrictions. ```json [ { "merchant_id": "wizwid", "merchant_name": "위즈위드", "click_url": "http://click.linkprice.com/click.php?m=wizwid&a=A100000131&l=0000", "when_trans": "실시간 실적 전송", "trans_reposition": "전체 실적 중 확정 건 제외한 실적 취소", "commission_payment_standard": "구매 월 기준 익익월 6일 지급", "deny_product": "", "deny_ad": "상호 또는 오타 키워드 유료 광고^리워드 프로그램 배포", "notice": "", "app_ios_yn": "N", "app_android_yn": "N" } ] ``` -------------------------------- ### All Performance Inquiry URL Example Source: https://github.com/linkprice/affiliatesetup/blob/master/docs/실적_조회_오픈_API_v1.6.md Use this URL to retrieve all performance data within a specified period. For monthly searches, it covers all days from the 1st to the last day of the month. ```URL api.linkprice.com/affiliate/translist.php?a_id=[A코드(사이트코드)]&auth_key=[인증키]&yyyymmdd=20231120 ``` -------------------------------- ### Linkprice Basic Merchant List Response Example Source: https://context7.com/linkprice/affiliatesetup/llms.txt This JSON represents the basic response for a merchant list query, including essential details like commission rates, merchant name, and click URL. ```json [ { "category_id": "3", "category_name": "패션", "deeplink_yn": "Y", "max_commission_mobile": "2%", "max_commission_pc": "2000원", "merchant_id": "wizwid", "merchant_logo": "http://img.wizwid.com/logo.jpg", "merchant_name": "위즈위드", "merchant_url": "http://www.wizwid.com", "mobile_yn": "Y", "return_day": 7, "reward_yn": "Y", "subscript": "APR", "click_url": "http://click.linkprice.com/click.php?m=wizwid&a=A100000131&l=0000&l_cd1=B&l_cd2=1" } ] ``` -------------------------------- ### Cancellation Performance Inquiry URL Example Source: https://github.com/linkprice/affiliatesetup/blob/master/docs/실적_조회_오픈_API_v1.6.md Retrieve performance data specifically for cancellations, including cancellation requests and completed cancellations within the specified period. ```URL api.linkprice.com/affiliate/translist.php?a_id=[A코드(사이트코드)]&auth_key=[인증키]&yyyymmdd=20231120&cancel_flag=Y ``` -------------------------------- ### Test Performance Inquiry URL Example Source: https://github.com/linkprice/affiliatesetup/blob/master/docs/실적_조회_오픈_API_v1.6.md Use this URL to retrieve test performance data within the specified period. This is useful for verifying response results. ```URL api.linkprice.com/affiliate/translist.php?a_id=[A코드(사이트코드)]&auth_key=[인증키]&yyyymmdd=20231120&test=Y ``` -------------------------------- ### Offerwall Shopping Points Response (JSON) Source: https://github.com/linkprice/affiliatesetup/blob/master/docs/오퍼월_쇼핑적립_연동_가이드.md This JSON response provides common guide information, FAQs, and affiliate details for Offerwall shopping points. It includes fields for affiliate ID, user ID, commission, and custom names/units for points. ```json { "common_guide": "* 이용가이드 :\n쇼핑몰을 클릭 하신 뒤 쇼핑을 하시면 적립 됩니다.\n쇼핑몰 별 유의 사항 및 제외 항목이 있으니 꼭 확인하고 쇼핑 하세요.", "faqs": [ { "id": "83", "title": "테스트입니다.", "content": "<p style=\"margin: 0px; font-family: 나눔고딕, 돋움, dotum; font-size:10pt;\" class=\"smart-editor-line\">안녕하세요 테스트입니다.</p>" } ], "affiliateId": "A100000131", "u_id": "test1234", "commission": "50000", "c_name": "", "c_unit": "" } ``` -------------------------------- ### Shopping Rewards Detailed Response Example Source: https://github.com/linkprice/affiliatesetup/blob/master/docs/오퍼월_쇼핑적립_연동_가이드.md This JSON object represents a detailed response from the shopping rewards API, providing information about a specific merchant, commission details, and terms. ```json { "merchant_id": "woori", "banner_url": "http://img.linkprice.com/files/glink/woori/20160414/570eeb0573da2_120_60.jpg", "when_trans": "구매 월 기준 2개월 이내", "deny_product": "* 사이트 내 추적 허용 금지, 쿠키 미동의, 광고 차단 프로그램 설치 시 실적 미인정", "content": "오퍼월 - \"쇼핑적립\"를 경유하여 롯데홈쇼핑에서 쇼핑하고 쇼핑적립 받으세요!\n\n▶ 해당 몰에서 상품 구매 시 실시간으로 쇼핑적립이 적립됩니다.\n▶ 적립 후 익익월 6일이 지나야 쇼핑적립을 사용하실 수 있습니다.\n▶ 배송비, 포인트, 적립금, 쿠폰 등의 사용금액을 제외한 실결제 금액 기준으로 쇼핑적립이 적립됩니다.\n▶ 주문 후 주문취소, 반품 등이 발생하면 쇼핑적립 적립이 취소됩니다.\n▶ 오퍼월 - \"쇼핑적립\"를 반드시 경유하여 결제한 상품에만 쇼핑적립이 적립되며 바로접속 또는 해당 몰 자체 앱을 통해 결제한 상품에 대해서는 쇼핑적립이 적립되지 않습니다.\n▶ 롯데홈쇼핑은 가전제품(30만원) 상품권(1만원) 1일 기준 1ID 당 동일 상품 수량 1개, 최대 구매 가능 금액 제한되어 있습니다.", "max_commission": "1.2%", "site_name": "롯데홈쇼핑", "click_url": "https://click.linkprice.com/click.php?m=woori&a=A100000131&l=0000&u=test1234&l_cd1=R&l_cd2=0", "commission": "50000", "affiliateId": "A100000131", "u_id": "test1234", "merchants": [ { "merchant_id": "11st", "site_name": "11번가", "banner_url": "https://img.linkprice.com/files/glink/11st/20220907/00062dUQWu000_11st_logo(120x60).png", "max_commission": "0.59%" }, { "merchant_id": "ctrip", "site_name": "트립닷컴", "banner_url": "https://img.linkprice.com/files/glink/ctrip/20220404/000E2JnWW4000_ctriplogo(120x60).png", "max_commission": "2.16%" } ], "c_name": "", "c_unit": "" } ``` -------------------------------- ### Get Transaction List Source: https://github.com/linkprice/affiliatesetup/blob/master/docs/실적_조회_오픈_API_v1.6.md Retrieves a list of affiliate transactions for a specified date. Requires affiliate site code and authentication key. ```APIDOC ## GET /affiliate/translist.php ### Description Retrieves a list of affiliate transactions for a specified date. Requires affiliate site code and authentication key. ### Method GET ### Endpoint https://api.linkprice.com/affiliate/translist.php ### Parameters #### Query Parameters - **a_id** (string) - Required - Affiliate site code. - **auth_key** (string) - Required - Authentication key. - **yyyymmdd** (string) - Required - The date for which to retrieve transactions (YYYYMMDD format). ### Request Example ``` GET https://api.linkprice.com/affiliate/translist.php?a_id=[A코드(사이트코드)]&auth_key=[인증키]&yyyymmdd=20231120 ``` ### Response #### Success Response (200) - **result** (string) - Result code (0 for success). - **list_count** (integer) - The number of transactions returned. - **order_list** (array) - An array of transaction objects. - **trlog_id** (string) - Unique transaction log ID. - **m_id** (string) - Merchant ID. - **o_cd** (string) - Order code. - **p_cd** (string) - Product code. - **p_nm** (string) - Product name. - **it_cnt** (string) - Order quantity. - **user_id** (string) - Affiliate user ID (from click URL). - **status** (string) - Transaction status (e.g., 100: Normal, 300: Cancellation Requested, 310: Cancellation Complete, 200: Pending Settlement, 210: Settlement Complete). - **c_cd** (string) - Category code. - **create_time_stamp** (string) - Transaction creation date (YYYYMMDD). - **applied_pgm_id** (string) - Applied merchant program ID. - **yyyymmdd** (string) - Order date (YYYYMMDD). - **hhmiss** (string) - Order time (HHMMSS). - **trans_comment** (string) - Reason for transaction cancellation (if applicable). - **sales** (double) - Total sales amount (default KRW). - **commission** (integer) - Affiliate commission amount (default KRW). - **pgm_name** (string) - Applied merchant program name. - **is_pc** (enum) - Platform used by the affiliate user (mobile, pc, app, ios, android). - **pur_rate** (string) - Commission rate or amount per transaction (e.g., '1000원' or '0.5%'). #### Response Example ```json { "result": "0", "list_count": 2, "order_list": [ { "trlog_id": "18000406750585", "m_id": "clickbuy", "o_cd": "recover_231019_182249", "p_cd": "recover_231019_182249", "p_nm": "pn_recover_5", "it_cnt": "1", "user_id": "u_id_recover_5", "status": "100", "c_cd": "test_c_cd", "create_time_stamp": "20231020", "applied_pgm_id": "0038", "yyyymmdd": "20231017", "hhmiss": "000000", "trans_comment": "", "sales": 39900, "commission": 1, "pgm_name": "tt_mo", "is_pc": "mobile", "pur_rate": "1원" }, { "trlog_id": "18000406750586", "m_id": "clickbuy", "o_cd": "recover_231019_182243", "p_cd": "recover_231019_182243", "p_nm": "pn_recover_4", "it_cnt": "1", "user_id": "u_id_recover_4", "status": "100", "c_cd": "test_c_cd", "create_time_stamp": "20231020", "applied_pgm_id": "0038", "yyyymmdd": "20231017", "hhmiss": "000000", "trans_comment": "", "sales": 39900, "commission": 1, "pgm_name": "tt_mo", "is_pc": "mobile", "pur_rate": "1원" } ] } ``` ### Error Handling - **100**: A code (site code) not found. - **101**: Invalid page number. - **200**: Missing query date (yyyymmdd). - **210**: Invalid length for query date (yyyymmdd). - **300**: Invalid authentication key. - **400**: Unsupported currency unit. ``` -------------------------------- ### 쇼핑적립 메인 요청 (HTTP) Source: https://github.com/linkprice/affiliatesetup/blob/master/docs/오퍼월_쇼핑적립_연동_가이드.md 쇼핑 적립 메인 페이지 정보를 JSON 또는 HTML 형태로 요청하는 HTTP GET 메서드입니다. 필수 경로 파라미터인 a_id와 필수 쿼리 파라미터인 mode, u_id를 포함해야 합니다. ```HTTP GET https://api.linkprice.com/offerwall/{a_id} ``` -------------------------------- ### Non-Cancellation Performance Inquiry URL Example Source: https://github.com/linkprice/affiliatesetup/blob/master/docs/실적_조회_오픈_API_v1.6.md Retrieve performance data excluding cancellations, including general, pending settlement, and completed settlement statuses within the specified period. ```URL api.linkprice.com/affiliate/translist.php?a_id=[A코드(사이트코드)]&auth_key=[인증키]&yyyymmdd=20231120&cancel_flag=N ``` -------------------------------- ### Query Transactions with Currency Conversion (Python) Source: https://context7.com/linkprice/affiliatesetup/llms.txt This Python script demonstrates how to query transaction logs and convert sales and commission amounts to a specified currency (e.g., USD). It includes error code handling and a list of supported currencies. ```python # 에러 코드 처리 및 USD 환율 변환 조회 예시 import requests RESULT_CODES = { "0": "조회 성공", "100": "A코드(a_id) 없음", "101": "잘못된 페이지 번호", "200": "조회 일자(yyyymmdd) 없음", "210": "조회 일자 길이 오류", "300": "인증키(auth_key) 불일치", "400": "지원하지 않는 통화 코드", } # 지원 통화 코드 (ISO 4217) SUPPORTED_CURRENCIES = [ "KRW", "USD", "EUR", "JPY", "CNY", "AUD", "GBP", "VND", "CHF", "HKD", "PHP", "SGD", "TWD", "BRL", "IDR", "MYR", "PLN", "THB", "CAD", "INR", "NZD", ] def query_transactions(a_id, auth_key, yyyymmdd, currency="KRW"): if currency not in SUPPORTED_CURRENCIES: raise ValueError(f"지원하지 않는 통화: {currency}") resp = requests.get( "https://api.linkprice.com/affiliate/translist.php", params={ "a_id": a_id, "auth_key": auth_key, "yyyymmdd": yyyymmdd, "currency": currency, } ) resp.raise_for_status() body = resp.json() result_code = body.get("result") if result_code != "0": msg = RESULT_CODES.get(result_code, "알 수 없는 오류") raise Exception(f"[{result_code}] {msg}") return body["order_list"] # USD 환율 기준 실적 조회 orders = query_transactions("A100000131", "YOUR_AUTH_KEY", "20231120", currency="USD") for o in orders: print(f"{o['m_id']} | {o['o_cd']} | status={o['status']} | sales={o['sales']} USD") ``` -------------------------------- ### Get Estimated Rewards Source: https://github.com/linkprice/affiliatesetup/blob/master/docs/오퍼월_쇼핑적립_연동_가이드.md Retrieve estimated rewards based on provided query parameters. ```APIDOC ## GET /linkprice/affiliatesetup ### Description This endpoint retrieves estimated rewards for an affiliate. You can specify the response format, user ID, and optionally filter by commission, reward name, unit, or a specific month. ### Method GET ### Endpoint /linkprice/affiliatesetup ### Parameters #### Query Parameters - **mode** (string(4)) - Required - Response format. 'page' for HTML (web view), 'json' for JSON data. - **u_id** (string(560)) - Required - Unique identifier for the media's user. - **commission** (double) - Optional - Total commission amount to be displayed for the media user. - **c_name** (string(20)) - Optional - Name of the reward (e.g., 'Points', 'Cashback'). - **c_unit** (string(10)) - Optional - Unit for the reward (e.g., 'KRW', '$'). - **yyyymm** (string(6)) - Optional - The year and month to query reward data by (YYYYMM format). Defaults to the current month if not provided. ### Response #### Success Response (200) - **reward_list** (Array) - List of rewards. - **yyyymmdd** (string(8)) - Performance date (YYYYMMDD). - **merchant_id** (string(10)) - Merchant ID. - **site_name** (string(200)) - Merchant name. - **banner_url** (string(300)) - URL for the merchant's logo. - **order_code** (string(100)) - Order number. - **sales** (double) - Sales amount. - **commission** (double) - Commission amount. - **reward_yyyymm** (string(8)) - Scheduled reward month (YYYYMM). - **total_reward** (double) - Total rewards for the queried month based on purchase date. - **affiliate_id** (string(10)) - Affiliate code. - **u_id** (string(560)) - Media's user ID. - **commission** (double) - Affiliate user's commission information. - **c_name** (string(20)) - Reward name. - **c_unit** (string(10)) - Reward unit. - **yyyymm** (string(6)) - Queried month (YYYYMM) based on purchase date. - **yyyymms** (Array) - List of available months for querying. ### Response Example ```json { "reward_list": [ { "yyyymmdd": "20250715", "merchant_id": "clickbuy3", "site_name": "메이크샵 테스트2", "banner_url": "http://", "order_code": "A", "sales": 60000, "commission": 1600, "reward_yyyymm": "202509" }, { "yyyymmdd": "20250715", "merchant_id": "clickbuy3", "site_name": "메이크샵 테스트2", "banner_url": "http://", "order_code": "C", "sales": 15000, "commission": 800, "reward_yyyymm": "202509" } ], "total_reward": 2400, "affiliate_id": "A100000131", "u_id": "test1234", "commission": "1000", "c_name": "", "c_unit": "", "yyyymm": "202507", "yyyymms": [ "202507", "202506", "202505", "202504", "202503", "202502" ] } ``` ``` -------------------------------- ### Receive LinkPrice Rewards via POSTBACK (Python/Flask) Source: https://context7.com/linkprice/affiliatesetup/llms.txt Implement a Flask server to receive real-time reward data from LinkPrice via POSTBACK. Ensure to handle duplicate requests using `trlog_id` and manage commissions less than or equal to zero. ```python from flask import Flask, request, jsonify import hashlib app = Flask(__name__) # 제휴 링크에 u_id 포함 예시: # https://click.linkprice.com/click.php?m=gmarket&a=A100000131&l=0000&u_id=member_12345 @app.route("/reward/postback", methods=["POST"]) def receive_reward(): """ 링크프라이스로부터 수신되는 리워드 POSTBACK 데이터 예시: { "day": "20200701", "time": "112719", "merchant_id": "linkprice", "order_code": "oc11123", "product_code": "pc11123", "product_name": "test product", "category_code": "cc11", "item_count": 1, "price": 20000, "commision": 1800, # ※ 오탈자 아님, 필드명 주의 "affiliate_id": "A100000131", "affiliate_user_id": "member_12345", "trlog_id": 10000536080255, "base_commission": "8%", "incentive_commission": "1%" } """ data = request.get_json() trlog_id = data.get("trlog_id") merchant_id = data.get("merchant_id") order_code = data.get("order_code") user_id = data.get("affiliate_user_id") commission = data.get("commision") # ※ 오탈자 아님, 필드명 주의 price = data.get("price") # 중복 수신 방어: trlog_id 기준으로 DB 조회 if is_already_processed(trlog_id): return jsonify({"status": "duplicated"}), 200 # commission <= 0 인 실적은 적립 대상에서 제외 (일부 머천트 특성) if commission <= 0: save_pending_reward(trlog_id, merchant_id, order_code, user_id, price, commission) return jsonify({"status": "pending_commission"}), 200 # 적립 예정 내역 DB 저장 (확정 전이므로 '예정' 상태로 저장) save_pending_reward(trlog_id, merchant_id, order_code, user_id, price, commission) return jsonify({"status": "ok"}), 200 ``` -------------------------------- ### Estimated Rewards API Request Source: https://github.com/linkprice/affiliatesetup/blob/master/docs/오퍼월_쇼핑적립_연동_가이드.md This HTTP GET request retrieves a list of estimated shopping rewards. It requires the affiliate ID in the path. ```http GET https://api.linkprice.com/offerwall/A100683120/rewardList ``` -------------------------------- ### Fetch Expected Reward List Source: https://context7.com/linkprice/affiliatesetup/llms.txt Use this endpoint to retrieve a list of expected rewards based on purchase history for a specific month. Requires affiliate ID, user ID, and the target month. ```bash curl "https://api.linkprice.com/offerwall/A100683120/rewardList?mode=json&u_id=member_12345&yyyymm=202507" ``` -------------------------------- ### 리워드 데이터 전송 예시 (JSON) Source: https://github.com/linkprice/affiliatesetup/blob/master/docs/리워드_오픈_API.md 실적 발생 시 서버 간 통신(server to server)으로 전송되는 리워드 데이터의 JSON 형식 예시입니다. POST 방식으로 전송되며, 다양한 실적 관련 정보를 포함합니다. ```json POST { "day": "20200701", "time": "112719", "merchant_id": "linkprice", "order_code": "oc11123", "product_code": "pc11123", "product_name" : "test product", "category_code": "cc11", "item_count": 1, "price": 20000, "commision": 1800, "affiliate_id": "A100000000", "affiliate_user_id": "ac_aaa", "trlog_id" : 10000536080255, "base_commission" : "8%", "incentive_commission" : "1%" } ``` -------------------------------- ### Process Monthly Settlement (Python) Source: https://context7.com/linkprice/affiliatesetup/llms.txt This Python function outlines the process for handling monthly settlements, considering Linkprice's settlement cycle. It determines the target settlement month and processes confirmed or cancelled rewards, emphasizing the use of a composite key for tracking due to potential changes in `trlog_id` for batch merchants. ```python # 정산 주기를 고려한 리워드 적립 확정 처리 전체 플로우 예시 from datetime import date import requests def get_settlement_target_month(today: date) -> str: """ 매월 6일 이후, 전전월 실적을 정산 대상으로 삼는 로직. 예) 2023-11-06 실행 → 202309 조회 """ year, month = today.year, today.month month -= 2 if month <= 0: month += 12 year -= 1 return f"{year}{month:02d}" def process_monthly_settlement(a_id: str, auth_key: str): today = date.today() if today.day < 6: print("정산 완료 전입니다. 6일 이후 실행하세요.") return target_month = get_settlement_target_month(today) print(f"[{today}] {target_month} 실적 정산 처리 시작") resp = requests.get( "https://api.linkprice.com/affiliate/translist.php", params={"a_id": a_id, "auth_key": auth_key, "yyyymmdd": target_month} ) orders = resp.json().get("order_list", []) confirmed, cancelled, skipped = 0, 0, 0 for item in orders: # 배치 머천트: trlog_id가 바뀔 수 있으므로 복합 키로 추적 track_key = (item["m_id"], item["o_cd"], item["user_id"]) if item["status"] == "210": # 정산 완료 confirm_reward(track_key, item["commission"]) confirmed += 1 elif item["status"] == "310": # 취소 완료 cancel_reward(track_key) cancelled += 1 else: skipped += 1 # 100(일반), 200(대기) 상태는 아직 미확정 print(f"확정: {confirmed}건 | 취소: {cancelled}건 | 미확정: {skipped}건") # process_monthly_settlement("A100000131", "YOUR_AUTH_KEY") ``` -------------------------------- ### Transaction List Retrieval Source: https://github.com/linkprice/affiliatesetup/blob/master/docs/실적_조회_오픈_API_v1.6.md Retrieve a list of affiliate transactions. This endpoint requires your affiliate ID and authentication key. An example response for an error case (missing date) is also shown. ```APIDOC ## GET /affiliate/translist.php ### Description Retrieves a list of affiliate transactions. ### Method GET ### Endpoint https://api.linkprice.com/affiliate/translist.php ### Parameters #### Query Parameters - **a_id** (string) - Required - Your affiliate site code (A 코드). - **auth_key** (string) - Required - Your authentication key. ### Response #### Success Response (200) - **result** (string) - Indicates the success of the operation (e.g., "200"). - **list_count** (integer) - The number of orders in the list. - **order_list** (array) - A list of order objects. #### Response Example (Success) ```json { "result": "200", "list_count": 1, "order_list": [ { "order_id": "12345", "product_name": "Example Product", "price": 10000, "commission": 500, "currency": "JPY", "order_date": "2023-10-27" } ] } ``` #### Error Response Example (Missing Date) ```json { "result": "200", "list_count": 0, "order_list": [] } ``` ``` -------------------------------- ### Missing Inquiry API Request Source: https://github.com/linkprice/affiliatesetup/blob/master/docs/오퍼월_쇼핑적립_연동_가이드.md This HTTP GET request is used to inquire about missing shopping points. It requires the affiliate ID in the path and optional query parameters for response mode, user ID, and commission details. ```http GET https://api.linkprice.com/offerwall/{a_id}/missing ``` -------------------------------- ### Synchronize Affiliate Rewards with Linkprice API Source: https://context7.com/linkprice/affiliatesetup/llms.txt This Python script fetches affiliate transaction data and processes rewards based on their status (confirmed or cancelled). It requires the 'requests' library and iterates through paginated results. ```python import requests STATUS_CONFIRMED = "210" # 정산 완료 → 리워드 확정 지급 STATUS_CANCELLED = "310" # 취소 완료 → 리워드 회수/취소 def sync_rewards(a_id: str, auth_key: str, yyyymm: str): url = "https://api.linkprice.com/affiliate/translist.php" page = 1 while True: resp = requests.get(url, params={ "a_id": a_id, "auth_key": auth_key, "yyyymmdd": yyyymm, "page": page, "per_page": 1000, }) resp.raise_for_status() body = resp.json() if body["result"] != "0": raise Exception(f"API 오류: result={body['result']}") for item in body["order_list"]: # 실적 추적 키: m_id + o_cd + user_id (trlog_id는 배치 후 변경될 수 있음) key = (item["m_id"], item["o_cd"], item["user_id"]) if item["status"] == STATUS_CONFIRMED: confirm_user_reward(key, item["commission"]) elif item["status"] == STATUS_CANCELLED: cancel_user_reward(key) if len(body["order_list"]) < 1000: break page += 1 # 매월 6일에 전전월 실적 동기화 실행 # sync_rewards("A100000131", "YOUR_AUTH_KEY", "202309") ``` -------------------------------- ### Query Transaction Status via API (Bash) Source: https://context7.com/linkprice/affiliatesetup/llms.txt Use cURL to query LinkPrice transaction lists by date, filtering by cancellation status, currency, and pagination. Recommended API call frequency is no more than once every 15 minutes. ```bash # ── 전체 실적 조회 (일별) ── curl "https://api.linkprice.com/affiliate/translist.php?\ a_id=A100000131&auth_key=YOUR_AUTH_KEY&yyyymmdd=20231120" ``` ```bash # ── 취소 외 실적만 조회 (일반+정산대기+정산완료) ── curl "https://api.linkprice.com/affiliate/translist.php?\ a_id=A100000131&auth_key=YOUR_AUTH_KEY&yyyymmdd=20231120&cancel_flag=N" ``` ```bash # ── 취소 실적만 조회 ── curl "https://api.linkprice.com/affiliate/translist.php?\ a_id=A100000131&auth_key=YOUR_AUTH_KEY&yyyymmdd=20231120&cancel_flag=Y" ``` ```bash # ── 월별 조회 + USD 환율 변환 + 페이징 ── curl "https://api.linkprice.com/affiliate/translist.php?\ a_id=A100000131&auth_key=YOUR_AUTH_KEY&yyyymmdd=202311¤cy=USD&page=1&per_page=500" ``` ```bash # ── 테스트 실적 10건 조회 ── curl "https://api.linkprice.com/affiliate/translist.php?\ a_id=A100000131&auth_key=YOUR_AUTH_KEY&yyyymmdd=20231120&test=Y" ``` -------------------------------- ### Reward API - Receiving Postbacks Source: https://context7.com/linkprice/affiliatesetup/llms.txt This API allows LinkPrice to send real-time sales performance data (postbacks) to the affiliate's designated POSTBACK URL via POST requests. Affiliates must register their POSTBACK URL in the Affiliate Center and include a `u_id` parameter in affiliate links for user identification. It's crucial to implement duplicate prevention logic based on `trlog_id` as multiple calls for the same order may occur. ```APIDOC ## Reward API - POST /reward/postback ### Description Receives real-time sales performance data from LinkPrice. ### Method POST ### Endpoint /reward/postback ### Request Body - **day** (string) - Date of the transaction (YYYYMMDD). - **time** (string) - Time of the transaction (HHMMSS). - **merchant_id** (string) - The ID of the merchant. - **order_code** (string) - The merchant's order code. - **product_code** (string) - The merchant's product code. - **product_name** (string) - The name of the product. - **category_code** (string) - The category code of the product. - **item_count** (integer) - The number of items in the order. - **price** (integer) - The total price of the order. - **commision** (integer) - The commission amount. Note: This field name has a typo in the source and should be used as is. - **affiliate_id** (string) - The affiliate's ID. - **affiliate_user_id** (string) - The affiliate's user ID (from `u_id` parameter). - **trlog_id** (integer) - Unique transaction log ID for duplicate prevention. - **base_commission** (string) - The base commission rate (e.g., "8%"). - **incentive_commission** (string) - The incentive commission rate (e.g., "1%"). ### Request Example ```json { "day": "20200701", "time": "112719", "merchant_id": "linkprice", "order_code": "oc11123", "product_code": "pc11123", "product_name": "test product", "category_code": "cc11", "item_count": 1, "price": 20000, "commision": 1800, "affiliate_id": "A100000131", "affiliate_user_id": "member_12345", "trlog_id": 10000536080255, "base_commission": "8%", "incentive_commission": "1%" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the processing status (e.g., "ok", "duplicated", "pending_commission"). #### Response Example ```json { "status": "ok" } ``` ``` -------------------------------- ### Query Transactions with Currency Conversion Source: https://context7.com/linkprice/affiliatesetup/llms.txt Retrieves transaction logs for a given affiliate ID and date, with support for converting sales and commission amounts to a specified currency. ```APIDOC ## GET /affiliate/translist.php ### Description Fetches transaction logs for an affiliate, allowing for currency conversion of sales and commission figures. ### Method GET ### Endpoint https://api.linkprice.com/affiliate/translist.php ### Parameters #### Query Parameters - **a_id** (string) - Required - The affiliate ID. - **auth_key** (string) - Required - The authentication key for the affiliate. - **yyyymmdd** (string) - Required - The date for which to retrieve transactions (format: YYYYMMDD). - **currency** (string) - Optional - The ISO 4217 currency code to convert amounts to (default: KRW). ### Response #### Success Response (200) - **result** (string) - Result code of the operation ('0' for success). - **order_list** (array) - A list of transaction orders, each containing: - **m_id** (string) - Merchant ID. - **o_cd** (string) - Order code. - **status** (string) - Transaction status. - **sales** (number) - Sales amount in the requested currency. - **commission** (number) - Commission amount in the requested currency. - **user_id** (string) - User ID associated with the transaction. ### Error Codes - **100**: A code (a_id) not found. - **101**: Invalid page number. - **200**: Transaction date (yyyymmdd) not found. - **210**: Transaction date length error. - **300**: Authentication key mismatch. - **400**: Unsupported currency code. ``` -------------------------------- ### 기본 응답 샘플 Source: https://github.com/linkprice/affiliatesetup/blob/master/docs/광고주_조회_오픈_API_1.0.md 광고주 조회 API의 기본 응답 형식입니다. 각 광고주의 카테고리, 커미션 정보, 로고, URL 등을 포함합니다. ```json [ { "category_id": "3", "category_name": "패션", "deeplink_yn": "Y", "max_commission_mobile": "2%", "max_commission_pc": "2000원", "merchant_id": "wizwid", "merchant_logo": "http://img.wizwid.com/WIZWID/RAW-DOC2/pc/mkt-2019-raink/logo.jpg", "merchant_name": "위즈위드", "merchant_url": "http://www.wizwid.com/CSW/handler/wizwid/kr/MainView-MainView", "mobile_yn": "Y", "return_day": 7, "reward_yn": "Y", "subscript": "APR", "click_url": "http://click.linkprice.com/click.php?m=wizwid&a=A100000131&l=0000&l_cd1=B&l_cd2=1" } ] ```