WebPayで定額課金する流れ

WebPayにはいろいろなSDKが用意されています。JavaでWebPayの定額課金して課金ログを見る流れはこのように書きます。

          WebPay webpay = new WebPay("***KEY***");
          // 顧客登録
          CustomerResponse customerResponse =
            webpay.customer.createRequest().card("token").email(
              "hoge@test.com").description("hogehoge").execute();
          if (customerResponse != null) {
            logger.info(customerResponse);
            // 定期課金登録
            RecursionResponse recursionResponse =
              webpay.recursion
                .createRequest()
                .customer(customerResponse.id)
                .amount(1000)
                .currency("jpy")
                .period("month")
                .description("hogehoge")
                .execute();
            if (recursionResponse != null) {
              logger.info(recursionResponse);
            // 課金詳細取得
              ChargeResponseList chargeResponseList =
                webpay.charge
                  .allRequest()
                  .count(1)
                  .customer(customerResponse.id)
                  .recursion(recursionResponse.id)
                  .execute();
              if (chargeResponseList != null) {
                List<ChargeResponse> chargeList = chargeResponseList.data;
                for (ChargeResponse charge : chargeList) {
                  logger.info(charge);
                }
              }
            }
          }

参考

https://webpay.jp/docs/api/java#charges