【问题标题】:How to get coupon detail from Recurly_CouponRedemptionList如何从 Recurly_CouponRedemptionList 获取优惠券详细信息
【发布时间】:2017-05-26 13:15:03
【问题描述】:

我正在使用最新版本的 Recurly API 2.7。我无法从发票对象中获取优惠券详细信息。

我想在这个结果中获得第一个 Redemption 对象的优惠券对象。

$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
        (
        )

)

感谢您的帮助。

【问题讨论】:

    标签: php recurly


    【解决方案1】:

    优惠券详情是兑换对象中的存根对象。

    附件是一个代码片段,演示如何调用优惠券存根并返回一些示例优惠券详细信息。

    调用还包括以格式化数组的形式返回优惠券对象,以便更好地了解可返回的优惠券参数/值。

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

    【讨论】:

      猜你喜欢
      • 2018-05-11
      • 2019-03-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-19
      • 2014-10-15
      • 2022-10-19
      相关资源
      最近更新 更多