コード例 #1
0
 /**
  * @param PlanDefinition $definition
  * @param Money $amountToPay
  * @param PlanParameters $parameters
  * @return PaymentPlan
  */
 public function getPlan(PlanDefinition $definition, Money $amountToPay, PlanParameters $parameters)
 {
     /** @var array $paymentProportions */
     $paymentProportions = $definition->getAttribute('payments');
     //The values of the payments array is a ratios array
     /** @var Money[] $amounts */
     $amounts = $amountToPay->allocate(array_values($paymentProportions));
     $payments = array_map(function ($rawDate, $amount) {
         //rawDate is either 'immediate' or a 'Y-m-d' string, or invalid.
         if ($rawDate === 'immediate') {
             return PlannedPayment::immediate($amount);
         }
         return PlannedPayment::withDueDate($amount, DueDate::fromString($rawDate));
     }, array_keys($paymentProportions), $amounts);
     return new PaymentPlan($payments, $definition->getAttribute('short_description'), $definition->getAttribute('long_description'));
 }
コード例 #2
0
 /**
  * @param PlanDefinition $definition
  * @param Money $amountToPay
  * @param \Ice\PaymentPlan\PlanParameters $parameters
  * @internal param string $planCode
  * @return \Ice\PaymentPlan\PaymentPlan
  */
 public function getPlan(PlanDefinition $definition, Money $amountToPay, PlanParameters $parameters)
 {
     $calculator = $this->getModifiedCalculator($definition->hasAttribute('modifiers') ? $definition->getAttribute('modifiers') : []);
     return $calculator->getPlan($definition, $amountToPay, $parameters);
 }