

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# 결제 이벤트 데이터 피드
<a name="data-feed-billing-event"></a>

이 데이터 피드는 인보이스 발행 및 지불 등 결제 이벤트에 대한 정보를 제공합니다.

예를 들어, 이 데이터 피드를 사용하여 구매자에게 인보이스가 발행되는 시기와 항목을 확인할 수 있습니다. [예제 SQL 쿼리](#data-feeds-billing-event-query-examples)를 사용하여 이 데이터 피드의 데이터를 분석할 수도 있습니다.

이 데이터 피드에는 사용자가 등록 판매자인 결제 이벤트와 관련된 정보가 포함되어 있습니다. 채널 파트너를 통해 체결된 계약의 경우 이 데이터 피드는 제조업자와 등록 판매자 간의 결제 이벤트에 대한 정보를 포함합니다.

결제 이벤트 데이터 피드는 24시간마다 새로 고쳐지므로 매일 새 데이터를 사용할 수 있습니다.

결제 이벤트 데이터는 변경할 수 없습니다.

다음 표에서는 데이터 피드 열의 이름과 설명을 설명합니다.


| 열 이름  | 설명  | 
| --- | --- | 
| billing\_event\_id | 결제 이벤트의 식별자입니다. 이 ID는 판매자의 환경에서 고유합니다. | 
| from\_account\_id | 결제 이벤트를 시작한 계정입니다. `transaction_type`이 `SELLER_REV_SHARE`인 경우 구매자의 지급인 계정입니다. [계정](data-feed-account.md) 데이터 피드에 대한 외래 키입니다.<br />`account_id` 필드의 `Account` 데이터 피드에 조인하는 데 사용할 수 있습니다. | 
| to\_account\_id | 제품에 대한 거래 금액을 수취하는 계정입니다. 계정 데이터 피드에 대한 외래 키입니다.`account_id` 필드의 `Account` 데이터 피드에 조인하는 데 사용할 수 있습니다. | 
| end\_user\_account\_id | 제품을 사용하는 계정입니다. 이 계정은 구매자 및 지급인 계정과 다를 수 있습니다.`account_id` 필드의 `Account` 데이터 피드에 조인하는 데 사용할 수 있습니다. | 
| product\_id | 제품의 식별자입니다. [제품](data-feed-product.md) 데이터 피드에 대한 외래 키입니다.`product_id` 필드의 `Product` 데이터 피드에 조인하는 데 사용할 수 있습니다. | 
| 작업 | 이 이벤트의 작업 유형입니다. 가능한 값은 다음과 같습니다.[See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/marketplace/latest/userguide/data-feed-billing-event.html) | 
| transaction\_type | 거래 유형입니다. 예시는 [세금 시나리오](#data-feeds-billing-event-tax-examples) 섹션을 참조하세요. 가능한 값은 다음과 같습니다.[See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/marketplace/latest/userguide/data-feed-billing-event.html) | 
| parent\_billing\_event\_id | `broker_id`가 `AWS_INC`이고 `action`이 `DISBURSED` 또는 `FORGIVEN`이고 `transaction_type`이 `DISBURSEMENT`이면 `parent_billing_event_id`는 이 결제 이벤트를 시작한 원래 `billing_event_id`를 나타냅니다. `action`에 다른 값이 있는 경우 이 필드는 null입니다.<br />`broker_id`가 `AWS_EUROPE`이면 `parent_billing_event_id`는 다음 시나리오에서 이 결제 이벤트를 시작한 원래 `billing_event_id`를 나타냅니다.[See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/marketplace/latest/userguide/data-feed-billing-event.html)<br />`broker_id`가 `AWS_EUROPE`이면 `parent_billing_event_id`는 다음 시나리오에서 이전에 성공한 지급 결제 이벤트의 원래 `billing_event_id`를 나타냅니다.[See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/marketplace/latest/userguide/data-feed-billing-event.html)<br />`broker_id`가 `AWS_EUROPE`이면 나머지 모든 시나리오에서 이 필드는 null입니다. | 
| disbursement\_billing\_event\_id | `action`이 `DISBURSED`이고 다음 중 하나가 true일 때의 관련 지급입니다.[See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/marketplace/latest/userguide/data-feed-billing-event.html)<br />그 외의 경우에는 이 값이 null입니다. | 
| 수량 | 결제 이벤트 금액입니다. | 
| currency | ISO 639 통화 코드입니다. | 
| disbursement\_amount | 지급 금액입니다. 이중 인보이스 발행 시나리오의 경우, 이 필드에는 지급 금액이 포함됩니다. 통합 인보이스 발행 시나리오의 경우, 이 필드는 null입니다. | 
| disbursement\_currency | 지급 금액에 대한 ISO 639 통화 코드입니다. 이중 인보이스 발행 시나리오의 경우, 이 필드에는 지급 통화 코드가 포함됩니다. 통합 인보이스 발행 시나리오의 경우, 이 필드는 null입니다. | 
| balance\_impacting | 판매자 지불액 계산 시 해당 금액이 고려되는지 여부입니다. 값이 0이면 해당 금액이 정보 제공을 위해 표시된 것이며 잔액에는 영향을 주지 않습니다. 값이 1이면 판매자 지불액을 결정할 때 이 금액이 고려됩니다. | 
| invoice\_date | 인보이스가 발행된 날짜입니다. | 
| payment\_due\_date | `action`의 값이 `INVOICED`일 때 인보이스의 기한입니다. | 
| usage\_period\_start\_date | 레코드에 있는 기간 시작 날짜입니다. | 
| usage\_period\_end\_date | 레코드에 있는 기간 종료 날짜입니다. | 
| invoice\_id |  AWS 인보이스 ID입니다. | 
| billing\_address\_id | 주소 데이터 피드에서 지급인의 청구지 주소 참조입니다.`address_id` 필드의 `Address` 데이터 피드에 조인하는 데 사용할 수 있습니다. | 
| transaction\_reference\_id | 다음 보고서의 데이터를 상호 참조할 수 있도록 하는 식별자입니다.[See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/marketplace/latest/userguide/data-feed-billing-event.html) | 
| bank\_trace\_id | 지급 거래(`transaction_type`은 `DISBURSEMENT`이고 action은 `DISBURSED`)의 경우 은행에서 할당한 추적 ID입니다. 추적 ID를 사용하여 판매자 은행에서 제공한 보고서와 연결할 수 있습니다. | 
| broker\_id | 거래를 이끈 기업체의 식별자입니다. 가능한 값은 다음과 같습니다.[See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/marketplace/latest/userguide/data-feed-billing-event.html) | 
| buyer\_transaction\_reference\_id | `GROUP BY` 또는 SQL의 창 함수 구조를 사용하여 결제 피드의 모든 관련 레코드를 그룹화하는 식별자입니다. 이러한 관련 레코드에는 구매자 인보이스, 판매자 인보이스, 등록 수수료의 부가가치세(VAT)가 포함될 수 있습니다. | 
| action\_date | 트랜잭션 이벤트가 발생한 날짜입니다. 특정 날짜는 작업 유형에 따라 다릅니다.[See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/marketplace/latest/userguide/data-feed-billing-event.html) | 
| 수신자\_계정\_id | 피드에서 데이터를 수신하는 판매자의 계정입니다.<br />`account_id` 필드의 `Account` 데이터 피드에 조인하는 데 사용할 수 있습니다. | 
| offer\_id | 구매자 인보이스 품목과 연결된 제안의 표시 ID입니다.<br />`offer_id` 필드의 `Offer` 데이터 피드에 조인하는 데 사용할 수 있습니다. | 
| buyer\_invoice\_date | 연결된 구매자 인보이스 항목의 인보이스 날짜입니다. | 
| line\_item\_id | 지급 세부 수준에서 인보이스 행 항목 ID입니다. | 
| buyer\_line\_item\_id | 지급 세부 수준의 구매자 인보이스 품목 ID입니다. | 
| charge\_variant | 구매 또는 판매 대상을 나타냅니다. | 
| charge\_side | 판매자가 요금 변형을 구매 또는 판매하고 있는지 여부를 나타냅니다. | 

## 세금 시나리오
<a name="data-feeds-billing-event-tax-examples"></a>

구매자와 판매자의 국가와 지방 정부의 과세 모델에 따라 세금을 수금하고 송금하는 방식이 달라집니다. 가능한 시나리오는 다음과 같습니다.
+ 세금은에서 징수하고 송금합니다 AWS. 이 경우 `transaction_type`은 `AWS_TAX_SHARE`입니다.
+ 세금은 판매자가 징수 AWS하고, 판매자에게 지급하고, 판매자가 세무 당국에 송금합니다. 이 경우 `transaction_type`은 `SELLER_TAX_SHARE`입니다.
+ 세금은에서 징수하지 않습니다 AWS. 판매자가 세금을 계산하여 세무 당국에 송금해야 합니다. 이러한 경우 AWS Marketplace 는 세금 계산을 수행하거나 세금 정보를 받지 않습니다. 판매자가 수익에서 세금을 지불합니다.

## 결제 이벤트 데이터 피드의 예
<a name="data-feed-billing-event-sample-scenario"></a>

이 단원에서는 송장 발행 시점부터 한 달 이후의 결제 이벤트 데이터 기간에 대한 예를 보여줍니다. 이 단원의 모든 표에서 다음 사항에 유의하세요.
+ 데이터 피드에서 `billing_event_id` 값은 40자의 영숫자 문자열이지만, 여기서는 가독성을 위해 2자의 문자열로 표시되어 있습니다.
+ 데이터 피드에서 이 정보는 단일 테이블에 표시됩니다. 가독성을 위해 여기에는 데이터가 여러 표에 나와 있고 모든 열은 표시되어 있지 않습니다.

이 섹션의 예에서는 다음과 같이 가정합니다.
+ Arnav는 구매자입니다.
  + 계정 ID는 `737399998888`입니다.
  + Marketplace Facilitator 법률이 적용되는 프랑스에 거주하고 있습니다. 자세한 내용은 [Amazon Web Service 세금 도움말](https://aws.amazon.com/tax-help/)을 참조하세요.
  + `prod-o4grxfafcxxxx`를 구매했고 이 제품의 월 사용에 대해 120.60 USD의 인보이스를 받았습니다.
  + 그 달 안에 인보이스를 지불했습니다.
+ Jane은 제조업자입니다.
  + 계정 ID는 `111122223333`입니다.
+ Paulo는 등록 판매자입니다.
  + 계정 ID는 `777788889999`입니다.
  + Marketplace Facilitator 법률이 적용되지 않는 미국 캔자스주에 거주하고 있습니다.

### 등록 판매자에 대한 결제 이벤트 데이터 피드
<a name="billing-event-example-seller-of-record"></a>

등록 판매자로서 Paulo는 구매자인 Arnav에게 인보이스를 발행합니다.

다음 표는 Paulo가 Arnav에게 인보이스를 발행할 때 Paulo의 데이터 피드에 포함되는 관련 정보를 보여줍니다.


| billing\_event\_id  | from\_account\_id  | to\_account\_id  | end\_user\_account\_id | product\_id | action | transaction\_type | 
| --- | --- | --- | --- | --- | --- | --- | 
| I0 | 737399998888 | 777788889999 | 737399998888 | prod-o4grxfafcxxxx | INVOICED | SELLER\_REV\_SHARE | 
| I1 | 737399998888 | AWS | 737399998888 | prod-o4grxfafcxxxx | INVOICED | AWS\_TAX\_SHARE | 
| I2 | 777788889999 | 111122223333 | 737399998888 | prod-o4grxfafcxxxx | INVOICED | SELLER\_REV\_SHARE | 
| I3 | 777788889999 | AWS | 737399998888 | prod-o4grxfafcxxxx | INVOICED | AWS\_REV\_SHARE | 




| parent\_billing\_event\_id | disbursement\_billing\_event\_id | amount | currency | invoice\_date | invoice\_id | 
| --- | --- | --- | --- | --- | --- | 
|  |  | 100 | USD | 2018-12-31T00:00:00Z | 781216640 | 
|  |  | 20.6 | USD | 2018-12-31T00:00:00Z | 781216640 | 
|  |  | -80 | USD | 2018-12-31T00:04:07Z | 788576665 | 
|  |  | -0.2 | USD | 2018-12-31T00:04:07Z | 788576665 | 

다음 표는 Arnav가 인보이스 대금을 지불한 후 월말에 Paulo의 데이터 피드에 포함되는 관련 정보를 보여줍니다.


| billing\_event\_id  | from\_account\_id  | to\_account\_id  | end\_user\_account\_id | product\_id | action | transaction\_type | 
| --- | --- | --- | --- | --- | --- | --- | 
| I10 | 737399998888 | 777788889999 | 737399998888 |  | DISBURSED | SELLER\_REV\_SHARE | 
| I12 | 777788889999 | 111122223333 | 737399998888 |  | DISBURSED | SELLER\_REV\_SHARE | 
| I13 | 777788889999 | AWS | 737399998888 | prod-o4grxfafcxxxx | DISBURSED | AWS\_REV\_SHARE | 
| I14 | AWS | 777788889999 |  |  | DISBURSED | DISBURSEMENT | 




| parent\_billing\_event\_id | disbursement\_billing\_event\_id | amount | currency | invoice\_date | invoice\_id | 
| --- | --- | --- | --- | --- | --- | 
| I0 | I14 | -100 | USD | 2018-12-31T00:00:00Z | 781216640 | 
| I2 | I14 | 80 | USD | 2018-12-31T00:04:07Z | 788576665 | 
| I3 | I14 | 0.2 | USD | 2018-12-31T00:04:07Z | 788576665 | 
|  |  | 19.8 | USD |  |  | 

### 제조업자에 대한 결제 이벤트 데이터 피드
<a name="billing-event-example-manufacturer"></a>

다음 표는 Paulo가 Arnav에게 인보이스를 발행할 때 Jane의 데이터 피드에 포함되는 관련 정보를 보여줍니다.


| billing\_event\_id  | from\_account\_id  | to\_account\_id  | end\_user\_account\_id | product\_id | action | transaction\_type | 
| --- | --- | --- | --- | --- | --- | --- | 
| I5 | 777788889999 | 111122223333 |  | prod-o4grxfafcxxxx | INVOICED | SELLER\_REV\_SHARE | 
| I6 | 777788889999 | 111122223333 |  | prod-o4grxfafcxxxx | INVOICED | SELLER\_TAX\_SHARE | 
| I7 | 111122223333 | AWS |  | prod-o4grxfafcxxxx | INVOICED | AWS\_REV\_SHARE | 




| parent\_billing\_event\_id | disbursement\_billing\_event\_id | amount | currency | invoice\_date | invoice\_id | 
| --- | --- | --- | --- | --- | --- | 
|  |  | 73.5 |  | 2018-12-31T00:04:07Z | 788576665 | 
|  |  | 6.5 |  | 2018-12-31T00:04:07Z | 788576665 | 
|  |  | -7.35 |  | 2018-12-31T00:04:07Z | 788576665 | 

다음 표는 인보이스 대금이 지불된 후 월말에 Jane의 데이터 피드에 포함되는 관련 정보를 보여줍니다.


| billing\_event\_id  | from\_account\_id  | to\_account\_id  | end\_user\_account\_id | product\_id | action | transaction\_type | 
| --- | --- | --- | --- | --- | --- | --- | 
| I30 | 777788889999 | 111122223333 |  | prod-o4grxfafcxxxx | DISBURSED | SELLER\_REV\_SHARE | 
| I31 | 777788889999 | 111122223333 |  | prod-o4grxfafcxxxx | DISBURSED | SELLER\_TAX\_SHARE | 
| I32 | 111122223333 | AWS |  | prod-o4grxfafcxxxx | DISBURSED | AWS\_REV\_SHARE | 
| I33 | AWS | 111122223333 |  |  | DISBURSED | DISBURSEMENT | 




| parent\_billing\_event\_id | disbursement\_billing\_event\_id | amount | currency | invoice\_date | invoice\_id | 
| --- | --- | --- | --- | --- | --- | 
| I5 | I33 | -73.5 | USD |  |  | 
| I6 | I33 | -6.5 | USD |  |  | 
| I7 | I33 | 7.35 | USD |  |  | 
|  |  | 72.65 | USD |  |  | 

## 예제 쿼리
<a name="data-feeds-billing-event-query-examples"></a>

[데이터 피드를 사용하여 데이터 수집 및 분석](data-feed-using.md)에 설명된 대로 [ Athena](https://docs.aws.amazon.com/athena/latest/ug/what-is.html)를 사용하여 관리형 Amazon S3 버킷에 데이터 피드로 수집 및 저장된 데이터에 대한 쿼리를 실행할 수 있습니다. 이 단원에서는 이 작업을 수행하는 일반적인 방법의 몇 가지 예제를 제공합니다. 모든 예제에서는 단일 통화가 사용된다고 가정합니다.

## 예제 1: 세금을 포함한 인보이스 금액
<a name="data-feed-example-query-tax-invoice"></a>

세금을 포함하여 구매자에게 발행된 인보이스 금액을 확인하려면 다음 예제처럼 쿼리를 실행하면 됩니다.

```
SELECT sum(amount) FROM billing_event 
WHERE 
  action = 'INVOICED'
  AND
  (
    (transaction_type in ('SELLER_REV_SHARE', 'SELLER_TAX_SHARE')
      -- to discard SELLER_REV_SHARE from Manufacturer to Channel Partner, aka cost of goods
      AND to_account_id='{{seller-account-id}}'
    )
  OR transaction_type= 'AWS_TAX_SHARE'
  );
```

## 예제 2: 판매자를 대신하여 구매자에게 발행된 인보이스 금액
<a name="data-feed-example-query-invoice-for-seller"></a>

판매자를 대신하여 구매자에게 발행된 인보이스 금액을 확인하려면 다음 예제처럼 쿼리를 실행하면 됩니다.

```
SELECT sum(amount) FROM billing_event 
WHERE
  action = 'INVOICED'
  AND transaction_type in ('SELLER_REV_SHARE', 'SELLER_TAX_SHARE')
  AND to_account_id='{{seller-account-id}}'
;
```

## 예제 3: 판매자를 대신하여 수금 AWS 할 수 있는 금액
<a name="data-feed-example-query-aws-collect"></a>

가 판매자를 대신하여 수금할 AWS 수 있는 금액에서 환불, 크레딧 및 포기된 계정을 뺀 금액을 확인하려면 다음 예제와 같이 쿼리를 실행할 수 있습니다.

```
SELECT sum(amount) FROM billing_event 
WHERE
  -- what is invoiced on behalf of SELLER, incl. refunds/ credits and cost of goods
  transaction_type like 'SELLER_%' 
  -- FORGIVEN action records will "negate" related INVOICED
  and action in ('INVOICED','FORGIVEN') 
;
```

## 예제 4: 판매자가 수금할 수 있는 금액
<a name="data-feed-example-query-seller-collect"></a>

판매자가 수금할 수 있는 금액을 확인하려면 다음 예제처럼 쿼리를 실행하면 됩니다. 이 예제에서는가 AWS 징수하는 등록 수수료 및 세금을 제거하고 예외적인 잔액 조정을 추가합니다.

```
SELECT sum(amount) FROM billing_event
WHERE
  (transaction_type like 'SELLER_%' -- what is invoiced on behalf of SELLER
  or transaction_type like 'AWS_REV_%' -- what is owed to AWS
  or transaction_type = 'BALANCE_ADJUSTMENT' -- exceptionnal case
  )
  and action in ('INVOICED','FORGIVEN')
;
```

또한 다음 예제처럼 다음 쿼리를 사용하여 동일한 정보를 수집할 수도 있습니다.

```
SELECT sum(amount) FROM billing_event
WHERE
  balance_impacting = 1
  and action in ('INVOICED','FORGIVEN')
;
```

다음 예제에서는 동일한 정보를 보여 주지만 2018년 거래로 제한되며 모든 구매자가 인보이스 대금을 지불했다고 가정합니다.

```
SELECT sum(amount) FROM billing_event
WHERE
  invoice_date between '2018-01-01' and '2018-12-31'
  and balance_impacting = 1
  and action in ('INVOICED','FORGIVEN')
;
```

## 예제 5: 지불 금액
<a name="data-feed-example-query-disbursements"></a>

지불된 금액을 확인하려면 다음 예제처럼 쿼리를 실행하면 됩니다.

```
select sum(amount) FROM billing_event
WHERE
  action ='DISBURSED'
  and transaction_type like 'DISBURSEMENT%'
;
```

## 예제 6: 지불 보류 금액
<a name="data-feed-example-query-pending-disbursement"></a>

지급 보류 중인 금액을 확인하려면 다음 예제처럼 쿼리를 실행하면 됩니다. 이 쿼리는 이미 지불된 금액을 제외합니다.

```
SELECT sum(amount) FROM billing_event targeted 
WHERE
   (transaction_type like 'SELLER_%'  -- what is invoiced on behalf of SELLER
    or transaction_type like 'AWS_REV_%'  -- what is owed to AWS
    or transaction_type = 'BALANCE_ADJUSTMENT' -- exceptionnal case
   ) 
  -- DISBURSEMENT action records will "negate" 'INVOICED'
  -- but do not take into account failed disbursements
   AND 
    (not exists
      (select 1 
        from billing_event disbursement
          join billing_event failed_disbursement
           on disbursement.billing_event_id=failed_disbursement.parent_billing_event_id
        where
         disbursement.transaction_type='DISBURSEMENT'
         and failed_disbursement.transaction_type='DISBURSEMENT_FAILURE'
         and targeted.disbursement_billing_event_id=disbursement.billing_event_id
      )
    ) 
;
```

동일한 정보를 얻는 또 다른 방법은 다음 예제처럼 쿼리를 실행하여 판매자의 잔액을 구하는 것입니다.

```
SELECT sum(amount) FROM billing_event
WHERE
 balance_impacting = 1
;
```

다음 쿼리는 예제를 확장하여 2018년 거래로 결과를 제한하고 거래에 대한 추가 정보를 반환합니다.

```
select sum(residual_amount_per_transaction)
from
 (SELECT
    max(billed_invoices.amount) invoiced_amount,
    sum(nvl(disbursed_invoices.amount,0)) disbursed_amount,
    -- Exercise left to the reader:
    -- use transaction_type to distinguish listing fee vs seller-owed money
    -- still pending collection
    max(transaction_type) transaction_type,
    max(billed_invoices.amount) 
      + sum(nvl(disbursed_invoices.amount,0)) residual_amount_per_transaction
  FROM billing_event billed_invoices
    -- find related disbursements
    left join billing_event disbursed_invoices
      on disbursed_invoices.action='DISBURSED'
      and disbursed_invoices.parent_billing_event_id=billed_invoices.billing_event_id
  WHERE
    billed_invoices.invoice_date between '2018-01-01' and '2018-12-31'
    and billed_invoices.transaction_type like 'SELLER_%' -- invoiced on behalf of SELLER
    and billed_invoices.action in ('INVOICED','FORGIVEN')
    -- do not take into account failed disbursements
    AND not exists
      (select 1 from billing_event failed_disbursement
       where disbursed_invoices.disbursement_billing_event_id = failed_disbursement.parent_billing_event_id
      )
   GROUP BY billed_invoices.billing_event_id
);
```

## 예제 7: 인보이스 세트의 잔액
<a name="data-feed-example-query-balance-invoice-set"></a>

인보이스 세트의 합계를 알아보려면 다음 예제처럼 쿼리를 실행하면 됩니다.

```
SELECT invoice_id, sum(amount) FROM billing_event targeted
WHERE
  -- invoice_id is only not null for invoiced records AND disbursed records 
  -- linking them to related disbursement -> no need to filter more precisely
  invoice_id in ('XXX','YYY') 
  -- filter out failed disbursements 
  AND not exists
      (select 1 
        from billing_event disbursement
          join billing_event failed_disbursement
           on disbursement.billing_event_id=failed_disbursement.parent_billing_event_id
        where
         disbursement.transaction_type='DISBURSEMENT'
         and failed_disbursement.transaction_type='DISBURSEMENT_FAILURE'
         and targeted.disbursement_billing_event_id=disbursement.billing_event_id
      ) 
  group by invoice_id;
```