국가별 통화,환불,인보이스,가상화폐 테스트 메뉴얼 - SeungpilPark/uEngine-bill GitHub Wiki

국가별 통화

Requirements

통화 통계 분석을 위한 데이터베이스 ddl 을 실행한다. ddl download

Install

https://github.com/killbill/killbill-analytics-plugin 의 소스를 받아 maven 빌드한다.

빌드 후 생성된 jar 파일을 /var/tmp/bundles/plugins/java/analytics-plugin/4.1.0 경로에 카피한다.

이후 /var/tmp/bundles/plugins 폴더의 plugin_identifiers.json 파일에 다음을 추가한다.

{
.
.
"analytics":{"plugin_name":"analytics-plugin","language":"java","group_id":"org.kill-bill.billing.plugin.java","artifact_id":"analytics-plugin","packaging":"jar","classifier":null,"version":"4.1.0"}
}

Setup

분석 시드 데이터를 위해 다음의 스크립트를 실행한다.

#!/usr/bin/env bash

###################################################################################
#                                                                                 #
#                   Copyright 2010-2014 Ning, Inc.                                #
#                   Copyright 2014-2015 Groupon, Inc.                             #
#                   Copyright 2014-2015 The Billing Project, LLC                  #
#                                                                                 #
#      The Billing Project licenses this file to you under the Apache License,    #
#      version 2.0 (the "License"); you may not use this file except in           #
#      compliance with the License.  You may obtain a copy of the License at:     #
#                                                                                 #
#          http://www.apache.org/licenses/LICENSE-2.0                             #
#                                                                                 #
#      Unless required by applicable law or agreed to in writing, software        #
#      distributed under the License is distributed on an "AS IS" BASIS, WITHOUT  #
#      WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the  #
#      License for the specific language governing permissions and limitations    #
#      under the License.                                                         #
#                                                                                 #
###################################################################################

HERE=`cd \`dirname $0\`; pwd`

KILLBILL_HTTP_PROTOCOL=${KILLBILL_HTTP_PROTOCOL-"http"}
KILLBILL_HOST=${KILLBILL_HOST-"127.0.0.1"}
KILLBILL_PORT=${KILLBILL_PORT-"8080"}

KILLBILL_USER=${KILLBILL_USER-"admin"}
KILLBILL_PASSWORD=${KILLBILL_PASSWORD-"password"}
KILLBILL_API_KEY=${KILLBILL_API_KEY-"bob"}
KILLBILL_API_SECRET=${KILLBILL_API_SECRET-"lazar"}

MYSQL_HOST=${MYSQL_HOST-"127.0.0.1"}
MYSQL_USER=${MYSQL_USER-"root"}
MYSQL_PASSWORD=${MYSQL_PASSWORD-"root"}
MYSQL_DATABASE=${MYSQL_DATABASE-"killbill"}

REPORTS=$HERE/reports
SYSTEM=$HERE/system

function install_ddl() {
    local ddl=$1
    mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASSWORD $MYSQL_DATABASE -e "source $ddl"
}

function create_report() {
    local report_name=$1
    local report_pretty_name=$2
    local report_type=$3
    local source_table_name=$4

    curl -v \
         -X POST \
         -u $KILLBILL_USER:$KILLBILL_PASSWORD \
         -H "X-Killbill-ApiKey:$KILLBILL_API_KEY" \
         -H "X-Killbill-ApiSecret:$KILLBILL_API_SECRET" \
         -H 'Content-Type: application/json' \
         -d "{\"reportName\": \"$report_name\",
              \"reportPrettyName\": \"$report_pretty_name\",
              \"reportType\": \"$report_type\",
              \"sourceTableName\": \"$source_table_name\"}" \
         $KILLBILL_HTTP_PROTOCOL://$KILLBILL_HOST:$KILLBILL_PORT/plugins/killbill-analytics/reports
}

# Install the DDL - the calendar table needs to be first
install_ddl $REPORTS/calendar.sql
for r in `find $REPORTS -type f -name '*.sql' -o -name '*.ddl' -maxdepth 1`; do install_ddl $r; done
for r in `find $SYSTEM -type f -name '*.sql' -o -name '*.ddl' -maxdepth 1`; do install_ddl $r; done

# Dashboard views
create_report 'accounts_summary' 'Account summary' 'COUNTERS' 'v_report_accounts_summary'
create_report 'active_by_product_term_monthly' 'Active subscriptions' 'TIMELINE' 'v_report_active_by_product_term_monthly'
create_report 'cancellations_count_daily' 'Cancellations' 'TIMELINE' 'v_report_cancellations_count_daily'
create_report 'chargebacks_daily' 'Chargebacks' 'TIMELINE' 'v_report_chargebacks_daily'
create_report 'conversions_daily' 'Conversions' 'TIMELINE' 'v_report_conversions_daily'
create_report 'invoice_adjustments_daily' 'Invoice adjustments' 'TIMELINE' 'v_report_invoice_adjustments_daily'
create_report 'invoice_item_adjustments_daily' 'Invoice item adjustments' 'TIMELINE' 'v_report_invoice_item_adjustments_daily'
create_report 'invoice_item_credits_daily' 'Invoice credits' 'TIMELINE' 'v_report_invoice_item_credits_daily'
create_report 'invoices_balance_daily' 'Invoice balance' 'TIMELINE' 'v_report_invoices_balance_daily'
create_report 'invoices_daily' 'Invoices' 'TIMELINE' 'v_report_invoices_daily'
create_report 'mrr_daily' 'MRR' 'TIMELINE' 'v_report_mrr_daily'
create_report 'new_accounts_daily' 'New accounts' 'TIMELINE' 'v_report_new_accounts_daily'
create_report 'overdue_states_count_daily' 'Overdue states' 'TIMELINE' 'v_report_overdue_states_count_daily'
create_report 'payments_total_daily' 'Payment ($ amount)' 'TIMELINE' 'v_report_payments_total_daily'
create_report 'refunds_total_daily' 'Refunds' 'TIMELINE' 'v_report_refunds_total_daily'
create_report 'trial_starts_count_daily' 'Trials' 'TIMELINE' 'v_report_trial_starts_count_daily'

# System views
create_report 'system_report_control_tag_no_test' 'Control tags' 'COUNTERS' 'v_system_report_control_tag_no_test'
create_report 'system_report_notifications_per_queue_name' 'Notification queues' 'TIMELINE' 'v_system_report_notifications_per_queue_name'
create_report 'system_report_notifications_per_queue_name_late' 'Late notifications' 'COUNTERS' 'v_system_report_notifications_per_queue_name_late'
create_report 'system_report_payments' 'Payments status' 'COUNTERS' 'v_system_report_payments'
create_report 'system_report_payments_per_day' 'Payments' 'TIMELINE' 'v_system_report_payments_per_day'

환율 교환 정보를 아래의 인서트 구분을 사용해 채워넣는다.

INSERT INTO `killbill`.`analytics_currency_conversion`
(`record_id`,
`currency`,
`start_date`,
`end_date`,
`reference_rate`,
`reference_currency`)
VALUES
(<{record_id: }>,
<{currency: }>,
<{start_date: }>,
<{end_date: }>,
<{reference_rate: }>,
<{reference_currency: USD}>);

킬빌 서버의 java 프로퍼티에 다음을 추가하고 재시동한다.

org.killbill.notificationq.analytics.tableName=analytics_notifications 
org.killbill.notificationq.analytics.historyTableName=analytics_notifications_history

환불, 가상화폐

테스트 테넌트에 구매자 페이팔 계정정보를 등록한다.

curl -v \
     -X POST \
     -u admin:password \
     -H 'X-Killbill-ApiKey: sppark' \
     -H 'X-Killbill-ApiSecret: sppark' \
     -H 'X-Killbill-CreatedBy: admin' \
     -H 'Content-Type: text/plain' \
     -d ':paypal_express:
  :signature: "AFcWxV21C7fd0v3bYYYRCpSSRl31AMcE0Wek0G6Vp-SmFlXQb7CW1xmT"
  :login: "darkgodarkgo-facilitator_api1.gmail.com"
  :password: "KDAVR7W8W28AXL4F"' \
     http://127.0.0.1:8080/1.0/kb/tenants/uploadPluginConfig/killbill-paypal-express

종량제 과금 청약 요청(billing agreement)을 한다.

curl -v \
     -X POST \
     -u admin:password \
     -H 'X-Killbill-ApiKey: sppark' \
     -H 'X-Killbill-ApiSecret: sppark' \
     -H 'X-Killbill-CreatedBy: admin' \
     -H 'Content-Type: application/json' \
     -d '{
       "kb_account_id": "83de2217-6de3-45b5-93af-b34ffefbb0a3",
       "currency": "USD",
       "options": {
         "return_url": "http://www.google.com/?q=SUCCESS",
         "cancel_return_url": "http://www.google.com/?q=FAILURE",
         "billing_agreement": {
           "description": "Your subscription"
         }
       }
     }' \
     http://127.0.0.1:8080/plugins/killbill-paypal-express/1.0/setup-checkout

* About to connect() to 127.0.0.1 port 8080 (#0)
*   Trying 127.0.0.1...
* Adding handle: conn: 0x7fa094004000
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7fa094004000) send_pipe: 1, recv_pipe: 0
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
* Server auth using Basic with user 'admin'
> POST /plugins/killbill-paypal-express/1.0/setup-checkout HTTP/1.1
> Authorization: Basic YWRtaW46cGFzc3dvcmQ=
> User-Agent: curl/7.30.0
> Host: 127.0.0.1:8080
> Accept: */*
> X-Killbill-ApiKey: sppark
> X-Killbill-ApiSecret: sppark
> X-Killbill-CreatedBy: admin
> Content-Type: application/json
> Content-Length: 341
> 
* upload completely sent off: 341 out of 341 bytes
< HTTP/1.1 302 Found
* Server Apache-Coyote/1.1 is not blacklisted
< Server: Apache-Coyote/1.1
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Methods: GET, POST, DELETE, PUT, OPTIONS
< Access-Control-Allow-Headers: Authorization,Content-Type,X-Killbill-ApiKey,X-Killbill-ApiSecret,X-Killbill-Comment,X-Killbill-CreatedBy,X-Killbill-Pagination-CurrentOffset,X-Killbill-Pagination-MaxNbRecords,X-Killbill-Pagination-NextOffset,X-Killbill-Pagination-NextPageUri,X-Killbill-Pagination-TotalNbRecords,X-Killbill-Reason
< Access-Control-Expose-Headers: Authorization,Content-Type,X-Killbill-ApiKey,X-Killbill-ApiSecret,X-Killbill-Comment,X-Killbill-CreatedBy,X-Killbill-Pagination-CurrentOffset,X-Killbill-Pagination-MaxNbRecords,X-Killbill-Pagination-NextOffset,X-Killbill-Pagination-NextPageUri,X-Killbill-Pagination-TotalNbRecords,X-Killbill-Reason
< Location: https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-05V19241YK6158912
< X-Content-Type-Options: nosniff
< Set-Cookie: rack.session=BAh7CEkiD3Nlc3Npb25faWQGOgZFRiJFYjZjNWUwNzUwMzQ5NmFiMDVjNGZk%0ANjg5MDIyMmNhY2M5Zjk5YThlNDZhNDY1OWU1ZDhmMzAwYjdiOTZmZDQ4ZEki%0ACWNzcmYGOwBGIiU1MDljZGQ2ZDU0YWUyODdlYjZlYjViZjI3ZTUyZTJlY0ki%0ADXRyYWNraW5nBjsARnsHSSIUSFRUUF9VU0VSX0FHRU5UBjsARiItMmZkNGZj%0AZjE2MThhNGQzMjkxZjM5ZWIwMWU3ZTMxMzNiY2FkODQ0NEkiGUhUVFBfQUND%0ARVBUX0xBTkdVQUdFBjsARiItZGEzOWEzZWU1ZTZiNGIwZDMyNTViZmVmOTU2%0AMDE4OTBhZmQ4MDcwOQ%3D%3D%0A--758e62f68df0d900919a28ac3809f0f32d56d61f; path=/; HttpOnly
< Content-Type: application/json;charset=utf-8
< Content-Length: 0
< Date: Thu, 05 Jan 2017 08:47:41 GMT
< 
* Connection #0 to host 127.0.0.1 left intact

응답 코드의 Location 헤더로 페이팔 사이트로 접속한다.

청약을 수락 한 후 킬빌 서버로 최초 요청한 토큰을 사용해 청약 승낙을 알린다.

curl -v \
     -X POST \
     -u admin:password \
     -H 'X-Killbill-ApiKey: sppark' \
     -H 'X-Killbill-ApiSecret: sppark' \
     -H 'X-Killbill-CreatedBy: admin' \
     -H 'Content-Type: application/json' \
     -d '{
       "pluginName": "killbill-paypal-express",
       "pluginInfo": {
         "properties": [{
           "key": "token",
           "value": "EC-4GN264760E9390610"
         }]
       }
     }' \
     "http://127.0.0.1:8080/1.0/kb/accounts/83de2217-6de3-45b5-93af-b34ffefbb0a3/paymentMethods?isDefault=true"

이후 KAUI 사이트에서, 매월 1000 달러 구독을 6개월 동안 진행시킨 후, 구독료를 100달러로 바꾼 후 최초 구독날짜부터 시작하여 적용시킨다. 적용 후 구독료 차액이 발생하여 가상화폐로 세이브 된 걸 확인한다.

가장 최근 결제 트랜잭션 항목에서 PG 환불 및 CARGE BACK(현금 전달) 을 각각 실행해보고 환불이 진행될 때 사용자의 가상화폐량이 줄어듬을 확인한다.

페이팔 관리 사이트에서, PG 환불 처리된 항목에 대해 실제 환불이 되었는지 확인해본다.