public function initBillingAgreement(BillingAgreementInterface $billingAgreement, $entity, $entityItem = null) { /** @var PartnerInterface $owner **/ $owner = $entity->getOwner(); //$paymentProfile = $owner->getPreferredPaymentProfile(); $billingAgreement->setOwner($owner); }
public function getNextBillingPeriod(BillingAgreementInterface $billingAgreement) { //Find out to which date the billing agreement was already executed (eg. a billing request was already made) $startDate = $billingAgreement->getBilledToDate(); if (null == $startDate) { //If never billed: use the initial billing date as starting point $startDate = clone $billingAgreement->getInitialBillingDate(); } else { //Increase last billed to with one day; that will be the start date of the next period $startDate = clone $startDate->add(new \DateInterval('P1D')); } //Determine end date $endDate = $this->addMonth($startDate, 1); //TODO: allow more then just months return array($startDate, $endDate); }
/** * @param \Vespolina\Entity\Billing\BillingAgreementInterface $ba */ public function deactivateBillingAgreement(BillingAgreementInterface $ba) { $ba->setActive(0); $this->gateway->updateBillingAgreement($ba); }