/** * {@inheritdoc} */ public function save(StripeObject $stripeObject, $flush = false) { /** @var ChargeModelInterface $charge */ $charge = parent::save($stripeObject); if ($stripeObject['source']) { /** @var CardModelInterface $card */ $card = $this->cardManager->save($stripeObject['source'], $flush); $charge->setSource($card->getStripeId()); } if ($flush) { $this->objectManager->flush($charge); } return $charge; }
/** * {@inheritdoc} */ public function save(StripeObject $stripeObject, $flush = false) { /** @var InvoiceModelInterface $invoice */ $invoice = parent::save($stripeObject); if ($stripeObject['discount']) { /** @var CouponModelInterface $coupon */ $coupon = $this->couponManager->save($stripeObject['discount']['coupon'], $flush); $invoice->setCoupon($coupon->getStripeId()); } if ($flush) { $this->objectManager->flush($invoice); } return $invoice; }
/** * {@inheritdoc} */ public function save(StripeObject $stripeObject, $flush = false) { $model = parent::save($stripeObject, $flush); if ($stripeObject['sources']['total_count'] > 0) { foreach ($stripeObject['sources']['data'] as $sourceObject) { $this->cardManager->save($sourceObject, $flush); } } if ($stripeObject['subscriptions']['total_count'] > 0) { foreach ($stripeObject['subscriptions']['data'] as $subscriptionObject) { $this->subscriptionManager->save($subscriptionObject, $flush); } } return $model; }
/** * @inheritdoc */ public function save(StripeObject $stripeObject, $flush = false) { /** @var SubscriptionModelInterface $subscription */ $subscription = parent::save($stripeObject); if ($stripeObject['discount']) { /** @var CouponModelInterface $coupon */ $coupon = $this->couponManager->save($stripeObject['discount']['coupon'], $flush); $subscription->setCoupon($coupon->getStripeId()); } if ($stripeObject['plan']) { /** @var PlanModelInterface $plan */ $plan = $this->planManager->save($stripeObject['plan'], $flush); $subscription->setPlan($plan->getStripeId()); } if ($flush) { $this->objectManager->flush($subscription); } return $subscription; }