예제 #1
0
 /**
  * Creates a charge on the invoice
  * @param array $chargeOptions (Default: All keys set to their respective default values) Encapsulates the following optional parameters:
  *	* @param string (Default: NULL) $..['pricingComponentName'] The name of the pricing component (provided the charge pertains to a pricing component)
  *	* @param string (Default: NULL) $..['pricingComponentValue'] The value of the pricing component (provided the charge pertains to a pricing component)
  *	* @param float (Default: NULL) $..['amount'] The monetary amount of the charge (provided the charge is an ad-hoc charge rather than regarding some pricing component)
  *	* @param string (Default: NULL) $..['description'] The reason for creating the charge
  *	* @param string_ENUM['Immediate', 'Aggregated'] (Default: 'Aggregated') $..['invoicingType'] Subscription-charge invoicing type
  *	*
  *	*	<Immediate>
  *	*	Generate invoice straight away with this charge applied.
  *	*
  *	*	<Aggregated> (Default)
  *	*	Add this charge to next invoice.
  *	*
  *	* @param boolean $..['taxAmount'] Whether to apply tax atop the charge (provided the charge is an ad-hoc charge rather than regarding some pricing component)
  *	* @param string_ENUM['Credit', 'Debit'] (Default: 'Debit') $..['chargeType']
  *	*
  *	*	<Credit>
  *	*
  *	*	<Debit> (Default)
  *	*
  * @return Bf_SubscriptionCharge[] All charges created in the process.
  */
 public function charge(array $chargeOptions = array('pricingComponentName' => NULL, 'pricingComponentValue' => NULL, 'amount' => NULL, 'description' => NULL, 'invoicingType' => 'Aggregated', 'taxAmount' => false, 'chargeType' => 'Debit'))
 {
     $inputOptions = $chargeOptions;
     $invoiceID = Bf_Invoice::getIdentifier($this);
     $stateParams = static::mergeUserArgsOverNonNullDefaults(__METHOD__, array(), $inputOptions);
     $requestEntity = new Bf_AddChargeRequest($stateParams);
     $endpoint = sprintf("%s/charges", rawurlencode($invoiceID));
     $responseEntity = Bf_AddChargeResponse::getClassName();
     $constructedEntity = static::postEntityAndGrabFirst($endpoint, $requestEntity, $responseEntity);
     return $constructedEntity;
 }
예제 #2
0
 protected function doUnserialize(array $json)
 {
     // consult parent for further unserialization
     parent::doUnserialize($json);
     $this->unserializeArrayEntities('responses', Bf_AddChargeResponse::getClassName(), $json);
 }