-
-
Save ianatrecurly/fc47fb5c98deb999cde182402049050b to your computer and use it in GitHub Desktop.
Coupon Redemption By Account: PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$accountcode = '5786b0c8a2b12'; | |
try { | |
$account = Recurly_Account::get($accountcode); | |
$redemptions = $account->redemptions->get(); | |
foreach ($redemptions as $coupon_redemption) { | |
// Get coupon stub object | |
$coupon = $coupon_redemption->coupon->get(); | |
//Return details of coupon | |
echo "Coupon Name: " . $coupon->name . "</br>"; | |
echo "Coupon Code: " . $coupon->coupon_code . "</br>"; | |
echo "Coupon State: " . $coupon->state . "</br>"; | |
echo "Coupon Type (account or subscription) : " . $coupon->redemption_resource . "</br>"; | |
echo "Max redemptions per account: " . $coupon->max_redemptions_per_account . "</br>"; | |
echo "Coupon Discount: " . $coupon->discount_in_cents['USD']->amount_in_cents . "</br></br>"; | |
// Returns the coupon stub object for illustrative purposes to show object details and hierarchy | |
echo '<pre>'; | |
echo print_r($coupon); | |
echo '</pre>'; | |
} | |
} catch (Recurly_NotFoundError $e) { | |
print "Account not found: $e"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment