/** * Cost in percent. Range of 0 to 100. * * @param string $percent * * @return $this */ public function setPercent($percent) { NumericValidator::validate($percent, "Percent"); $percent = FormatConverter::formatToNumber($percent); $this->percent = $percent; return $this; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
public function testFormat() { $result = FormatConverter::format("12.0123", "%0.2f"); $this->assertEquals("12.01", $result); }
/** * 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; }
/** * 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; }
/** * 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; }