formatToPrice() public static method

It covers the cases where certain currencies does not accept decimal values. We will be adding any specific currency level rules as required here.
public static formatToPrice ( $value, null $currency = null ) : null | string
$value
$currency null
return null | string
コード例 #1
0
ファイル: Amount.php プロジェクト: seoduda/Patua
 /**
  * Total amount charged as part of this payment.
  *
  *
  * @param string|double $total
  *
  * @return $this
  */
 public function setTotal($total)
 {
     NumericValidator::validate($total, "Total");
     $total = FormatConverter::formatToPrice($total, $this->getCurrency());
     $this->total = $total;
     return $this;
 }
コード例 #2
0
ファイル: InvoiceItem.php プロジェクト: seoduda/Patua
 /**
  * Quantity of the item. Range of 0 to 9999.999.
  *
  * @param string|double $quantity
  * 
  * @return $this
  */
 public function setQuantity($quantity)
 {
     NumericValidator::validate($quantity, "Percent");
     $quantity = FormatConverter::formatToPrice($quantity);
     $this->quantity = $quantity;
     return $this;
 }
コード例 #3
0
ファイル: Tax.php プロジェクト: Roc4rdho/app
 /**
  * Rate of the specified tax. Range of 0.001 to 99.999.
  *
  * @param string|double $percent
  * 
  * @return $this
  */
 public function setPercent($percent)
 {
     NumericValidator::validate($percent, "Percent");
     $percent = FormatConverter::formatToPrice($percent);
     $this->percent = $percent;
     return $this;
 }
コード例 #4
0
ファイル: Currency.php プロジェクト: Roc4rdho/app
 /**
  * amount up to N digit after the decimals separator as defined in ISO 4217 for the appropriate currency code.
  *
  * @param string|double $value
  * 
  * @return $this
  */
 public function setValue($value)
 {
     NumericValidator::validate($value, "Value");
     $value = FormatConverter::formatToPrice($value, $this->getCurrency());
     $this->value = $value;
     return $this;
 }
コード例 #5
0
ファイル: Item.php プロジェクト: paypal/rest-api-sdk-php
 /**
  * Tax of the item. Only supported when the `payment_method` is set to `paypal`.
  *
  * @param string|double $tax
  * 
  * @return $this
  */
 public function setTax($tax)
 {
     NumericValidator::validate($tax, "Tax");
     $tax = FormatConverter::formatToPrice($tax, $this->getCurrency());
     $this->tax = $tax;
     return $this;
 }
コード例 #6
0
 /**
  * @dataProvider CurrencyListWithNoDecimalsProvider
  */
 public function testPriceWithNoDecimalCurrencyValid($input)
 {
     $result = FormatConverter::formatToPrice("1.0000000", $input);
     $this->assertEquals("1", $result);
 }
コード例 #7
0
ファイル: InstallmentOption.php プロジェクト: seoduda/Patua
 /**
  * Discount percentage applied to the payment, if any
  *
  * @param string $discount_percentage
  * 
  * @return $this
  */
 public function setDiscountPercentage($discount_percentage)
 {
     NumericValidator::validate($discount_percentage, "Discount Percentage");
     $discount_percentage = FormatConverter::formatToPrice($discount_percentage);
     $this->discount_percentage = $discount_percentage;
     return $this;
 }
コード例 #8
0
ファイル: Details.php プロジェクト: paypal/rest-api-sdk-php
 /**
  * Fee charged by PayPal. In case of a refund, this is the fee amount refunded to the original receipient of the payment.
  *
  * @param string|double $fee
  * 
  * @return $this
  */
 public function setFee($fee)
 {
     NumericValidator::validate($fee, "Fee");
     $fee = FormatConverter::formatToPrice($fee);
     $this->fee = $fee;
     return $this;
 }
コード例 #9
0
ファイル: Details.php プロジェクト: johnmicahmiguel/yodaphp
 /**
  * Amount being charged as gift wrap fee.
  *
  * @param string|double $gift_wrap
  * 
  * @return $this
  */
 public function setGiftWrap($gift_wrap)
 {
     NumericValidator::validate($gift_wrap, "Gift Wrap");
     $gift_wrap = FormatConverter::formatToPrice($gift_wrap);
     $this->gift_wrap = $gift_wrap;
     return $this;
 }