コード例 #1
0
	/**
	 * Updates the payment item corresponding to this Something
	 *
	 * @param  cbpaidPaymentItem    $item
	 * @param  cbpaidPaymentBasket  $paymentBasket
	 * @param  int                  $quantity          Quantity
	 * @param  string               $currency_code     The currency of the payment basket (so the payment item must be converted into that currency
	 * @return void
	 */
	public function updatePaymentItem( &$item, $paymentBasket , $quantity = null, $currency_code = null ) {
		$item->callIntegrations( 'beforeUpdatePaymentItem', $this, $paymentBasket );

		if ( $quantity === null ) {
			$quantity				=	$item->quantity;
		}
		if ( $currency_code === null ) {
			$currency_code			=	$item->currency;
		}
		$reason						=	$item->reason;
		$tryAutorecurring			=	$item->autorecurring;
		$start_time					=	strtotime( $item->start_date );
		list( $first_rate, /* $first_validity */, $rate, /* $validity */, $prorate_discount, /* $autorecurring */, /* $recurring_max_times */ )	=	$this->computeItemRatesAndValidity( $quantity, $currency_code, $reason, $start_time, $tryAutorecurring );
		if ( $first_rate !== false ) {
			$item->quantity			=	$quantity;
			$item->currency			=	$currency_code;
			$item->first_rate		=	$first_rate;
			$item->rate				=	$rate;
			$item->prorate_discount	=	$prorate_discount;
		}
		$item->callIntegrations( 'afterUpdatePaymentItem', $this, $paymentBasket );
	}
コード例 #2
0
	/**
	 * Updates the payment item corresponding to this Something
	 *
	 * @param  cbpaidPaymentItem    $item
	 * @param  cbpaidPaymentBasket  $paymentBasket
	 * @param  int                  $quantity          Quantity
	 * @param  string               $currency_code     The currency of the payment basket (so the payment item must be converted into that currency
	 * @return void
	 */
	public function updatePaymentItem( &$item, $paymentBasket,  $quantity = null, $currency_code = null ) {
		$item->callIntegrations( 'beforeUpdatePaymentItem', $this, $paymentBasket );

		if ( $quantity === null ) {
			$quantity				=	$item->quantity;
		}
		if ( $currency_code === null ) {
			$currency_code			=	$item->currency;
		}
		$start_time					=	strtotime( $item->start_date );
		$rate						=	$this->getPriceOfNextPayment( $currency_code, $start_time, $quantity, $item->reason );
		if ( $rate === false ) {
			$rate					=	0;
		}

		$item->currency				=	$currency_code;
		$item->rate					=	$rate;
		$item->quantity				=	$quantity;

		$item->callIntegrations( 'afterUpdatePaymentItem', $this, $paymentBasket );
	}