paypay / paypayopa-sdk-php

With PayPay's Payment SDK, you can build a custom Payment checkout process to suit your unique business needs and branding guidelines
http://developer.paypay.ne.jp/
Apache License 2.0
16 stars 11 forks source link

If the HTTP status code of the Check Cashback Details response is 200, I don't want to raise an exception. #174

Closed tomokatsu closed 3 years ago

tomokatsu commented 3 years ago

Describe the bug If the HTTP status code of the Check Cashback Details response is 200, I don't want to raise an exception. https://github.com/paypay/paypayopa-sdk-php/blob/bea1bb11ad7b19d4ca532bce23e437126ddc193d/src/core/Controller.php#L171

For example, if NOT_ENOUGH_MONEY is raised, I want to get the cashbackId included in the response body.

https://www.paypay.ne.jp/opa/doc/jp/v1.0/cashback#section/%E3%83%AC%E3%82%B9%E3%83%9D%E3%83%B3%E3%82%B9%E3%82%B3%E3%83%BC%E3%83%89%E4%B8%80%E8%A6%A7 image

How about this as a suggested modification to the source code?

$ git diff
diff --git a/src/core/Controller.php b/src/core/Controller.php
index 8a77021..b68b4cf 100644
--- a/src/core/Controller.php
+++ b/src/core/Controller.php
@@ -167,7 +167,8 @@ class Controller
      */
     protected function parseResultInfo($apiInfo, $resultInfo, $statusCode)
     {
-        if (strcmp($resultInfo['code'], "SUCCESS") !== 0 && strcmp($resultInfo['code'], "REQUEST_ACCEPTED")) {
+        $acceptStatusCodeList = [200, 202];
+        if (in_array($statusCode, $acceptCodeList, true) === false) {
             throw new ClientControllerException(
                 $apiInfo,
                 $resultInfo, //PayPay API message

Also, let me ask you one question. If the response code is NOT_ENOUGH_MONEY, BALANCE_OUT_OF_LIMIT, or INTERNAL_SERVICE_ERROR, will the data.status in the response body be FAILURE? In what cases does data.status become FAILURE?

https://www.paypay.ne.jp/opa/doc/jp/v1.0/cashback#operation/checkCashback image

chao-chang-paypay commented 3 years ago

hello @tomokatsu san, thanks for raising the issue, this is addressed in https://github.com/paypay/paypayopa-sdk-php/pull/176 , can you try version 2.0.0 ?