/** * Get items * * @see Pronamic_Pay_PaymentDataInterface::get_items() * @return Pronamic_IDeal_Items */ public function get_items() { // Items $items = new Pronamic_IDeal_Items(); // Amount $amount = filter_input(INPUT_POST, 'pronamic_pay_amount', FILTER_SANITIZE_STRING, array('flags' => FILTER_FLAG_ALLOW_THOUSAND, 'options' => array('decimal' => pronamic_pay_get_decimal_separator()))); // Get correct amount if pronamic_pay_amount is an array if (!$amount && ($amount = filter_input(INPUT_POST, 'pronamic_pay_amount', FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY))) { // Array filter will remove values NULL, FALSE and empty strings ('') $amount = array_filter($amount); // Make sure the amount has the correct floating value foreach ($amount as $key => $value) { if ('other' !== $key) { $amount[$key] = $value / 100; } } // Get first element of the array $amount = array_shift($amount); } $amount = Pronamic_WP_Pay_Util::string_to_amount($amount); // Item $item = new Pronamic_IDeal_Item(); $item->setNumber($this->get_order_id()); $item->setDescription(sprintf(__('Payment %s', 'pronamic_ideal'), $this->get_order_id())); $item->setPrice($amount); $item->setQuantity(1); $items->addItem($item); return $items; }
/** * Get items * * @see Pronamic_Pay_PaymentDataInterface::get_items() * @return Pronamic_IDeal_Items */ public function get_items() { // Items $items = new Pronamic_IDeal_Items(); $amount = filter_input(INPUT_POST, 'pronamic_pay_amount', FILTER_VALIDATE_FLOAT, array('flags' => FILTER_FLAG_ALLOW_THOUSAND, 'options' => array('decimal' => pronamic_pay_get_decimal_separator()))); // Item $item = new Pronamic_IDeal_Item(); $item->setNumber($this->get_order_id()); $item->setDescription(sprintf(__('Payment %s', 'pronamic_ideal'), $this->get_order_id())); $item->setPrice($amount); $item->setQuantity(1); $items->addItem($item); return $items; }
} ?> <div class="pronamic-pay-amount pronamic-pay-form-row-wide"> <?php if (in_array($amount_method, $methods_with_choices)) { ?> <?php foreach ($amount_choices as $amount) { ?> <?php $input_id = 'pronamic-pay-amount-' . esc_attr($amount); $decimals = $amount % 100 > 0 ? 2 : 0; $amount_formatted = number_format($amount / 100, $decimals, pronamic_pay_get_decimal_separator(), pronamic_pay_get_thousands_separator()); ?> <div> <input class="pronamic-pay-amount-input pronamic-pay-input" id="<?php esc_attr_e($input_id); ?> " name="pronamic_pay_amount[]" type="radio" required="required" value="<?php esc_attr_e($amount); ?> " /> <label for="<?php echo $input_id; ?> "> <span class="pronamic-pay-currency-symbol pronamic-pay-currency-position-before">€</span>
/** * Maybe test payment */ public function maybe_test_payment() { if (filter_has_var(INPUT_POST, 'test_pay_gateway') && check_admin_referer('test_pay_gateway', 'pronamic_pay_test_nonce')) { $id = filter_input(INPUT_POST, 'post_ID', FILTER_SANITIZE_NUMBER_INT); $gateway = Pronamic_WP_Pay_Plugin::get_gateway($id); if ($gateway) { $amount = filter_input(INPUT_POST, 'test_amount', FILTER_VALIDATE_FLOAT, array('flags' => FILTER_FLAG_ALLOW_THOUSAND, 'options' => array('decimal' => pronamic_pay_get_decimal_separator()))); $data = new Pronamic_WP_Pay_PaymentTestData(wp_get_current_user(), $amount); $payment = Pronamic_WP_Pay_Plugin::start($id, $gateway, $data); $error = $gateway->get_error(); if (is_wp_error($error)) { Pronamic_WP_Pay_Plugin::render_errors($error); } else { $gateway->redirect($payment); } exit; } } }