2017-01-11 4 views
1

최신 버전 인 Recurly API 2.7을 사용하고 있습니다. 송장 객체에서 쿠폰 세부 정보를 가져 오는 데 문제가 있습니다.Recurly_CouponRedemptionList에서 쿠폰 세부 정보를 얻는 방법

이 결과에서 첫 번째 보너스 상품의 쿠폰 객체를 가져오고 싶습니다.

$i = $ss->invoice->get(); 

if ($i->redemptions) { 
    $r = $i->redemptions->get(); 
    print_r($r); 
    if ($r->count > 0) { 
     $coupon = $r[0]->coupon->get(); 
    } 
} 

하지만 $ r [0]은 Recurly_CouponRedemption 개체를 반환하지 않습니다.

Recurly_CouponRedemptionList Object 
(
    [_position:Recurly_Pager:private] => 0 
    [_count:protected] => 1 
    [_objects:protected] => Array 
     (
      [0] => Recurly_CouponRedemption Object 
       (
        [_values:protected] => Array 
         (
          [coupon] => Recurly_Stub Object 
           (
            [objectType] => coupon 
            [_href:protected] => https://xxx.recurly.com/v2/accounts/test 
            [_client:protected] => Recurly_Client Object 
             (
              [_apiKey:Recurly_Client:private] => 
              [_acceptLanguage:Recurly_Client:private] => en-US 
             ) 

            [_links:protected] => Array 
             (
             ) 

           ) 

          [account] => Recurly_Stub Object 
           (
            [objectType] => account 
            [_href:protected] => https://xxx.recurly.com/v2/accounts/test 
            [_client:protected] => Recurly_Client Object 
             (
              [_apiKey:Recurly_Client:private] => 
              [_acceptLanguage:Recurly_Client:private] => en-US 
             ) 

            [_links:protected] => Array 
             (
             ) 

           ) 

          [uuid] => 0b00000000000000000000000 
          [single_use] => 
          [total_discounted_in_cents] => 500 
          [currency] => USD 
          [state] => active 
          [coupon_code] => 5off 
          [created_at] => DateTime Object 
           (
            [date] => 2017-01-11 16:30:09 
            [timezone_type] => 2 
            [timezone] => Z 
           ) 

          [updated_at] => DateTime Object 
           (
            [date] => 2017-01-11 16:30:09 
            [timezone_type] => 2 
            [timezone] => Z 
           ) 

         ) 

        [_unsavedKeys:protected] => Array 
         (
         ) 

        [_errors:protected] => Recurly_ErrorList Object 
         (
          [transaction] => 
          [transaction_error] => 
          [errors:Recurly_ErrorList:private] => Array 
           (
           ) 

         ) 

        [_href:protected] => 
        [_client:protected] => Recurly_Client Object 
         (
          [_apiKey:Recurly_Client:private] => 
          [_acceptLanguage:Recurly_Client:private] => en-US 
         ) 

        [_links:protected] => Array 
         (
         ) 

       ) 

     ) 

    [_href:protected] => test 
    [_client:protected] => Recurly_Client Object 
     (
      [_apiKey:Recurly_Client:private] => 
      [_acceptLanguage:Recurly_Client:private] => en-US 
     ) 

    [_links:protected] => Array 
     (
     ) 

) 

감사합니다.

답변

1

쿠폰 세부 정보는 수혜 대상 개체의 스텁 개체입니다.

첨부 된 코드 스 닙은 쿠폰 스텁을 호출하고 몇 가지 샘플 쿠폰 세부 정보를 반환합니다.

호출에는 반환 할 수있는 쿠폰 매개 변수/값을 더 잘 보여주기 위해 형식화 된 배열로 쿠폰 객체를 반환하는 것도 포함됩니다.

https://gist.github.com/ianatrecurly/fc47fb5c98deb999cde182402049050b

관련 문제