/** * Creates, and immediately saves a payment. * * @param mixed $amount An integer, or float value * @param string $currency See schema for allowed currencies * @param PaymentData $data the data container to use * @return Payment */ public static final function create($amount, $currency, PaymentData $data) { if (is_float($amount) === false && is_int($amount) === false) { throw new InvalidArgumentException('$amount must be a float, or an integer.'); } $amount = floatval($amount); $currencies = self::getAllowedCurrencies(); if (!in_array($currency, $currencies, true)) { throw new InvalidArgumentException('Invalid $currency. Valids: ' . var_export($currencies, true)); } if ($data->exists() === true) { throw new LogicException('The payment data must be transient.'); } $payment = new Payment(); $payment->_iKnowWhatImDoing = true; $payment->target_amount = $amount; $payment->currency = $currency; $payment->save(); $payment->DataContainer = $data; $data->save(); return $payment; }
public function getPayment() { return PaymentData::getById($this->payment_id); }
<div class="row"> <div class="col-md-12"> <h1>Reportes</h1> <br> <form class="form-horizontal" role="form"> <input type="hidden" name="view" value="reports"> <?php $pacients = PacientData::getAll(); $medics = MedicData::getAll(); $statuses = StatusData::getAll(); $payments = PaymentData::getAll(); ?> <div class="form-group"> <div class="col-lg-3"> <div class="input-group"> <span class="input-group-addon"><i class="fa fa-male"></i></span> <select name="pacient_id" class="form-control"> <option value="">PACIENTE</option> <?php foreach ($pacients as $p) { ?> <option value="<?php echo $p->id; ?> " <?php if (isset($_GET["pacient_id"]) && $_GET["pacient_id"] == $p->id) { echo "selected"; } ?>
public function validSend($data) { require_once DIR_SYSTEM . 'library/stelo/Stelo.php'; $this->load->model('account/customer'); $this->load->model('checkout/order'); $customer = $this->model_account_customer->getCustomer($data['customer_id']); $order_total = $this->model_checkout_order->getOrderTotal($this->session->data['order_id'], 'shipping'); $params = array(); $converter = new Converter(); //OrderData $orderData = new OrderData(); $orderData->setOrderId((string) $this->session->data['order_id']); $params['orderData'] = $converter->convertOrderData($orderData); //PaymentData $paymentData = new PaymentData(); $paymentData->setAmount((double) number_format($data['total'], 2, '.', '')); $paymentData->setDiscountAmount(''); $paymentData->setFreight((double) number_format($order_total['value'], 2, '.', '')); $paymentData->setMaxInstallment('4'); // CartData if ($this->cart->getProducts()) { foreach ($this->cart->getProducts() as $product) { $cartData = new CartDataCollection(); $cartData->setProductName($product['name']); $cartData->setProductPrice((double) number_format($product['price'], 2, '.', '')); $cartData->setProductQuantity($product['quantity']); $cartData->setProductSku(substr($product['model'], 0, 19)); $paymentData->setCartData($cartData); } } $params['paymentData'] = $converter->convertPaymentData($paymentData); //CustomerData $customerData = new CustomerData(); $customerData->setCustomerIdentity(str_replace('/', '', str_replace('-', '', str_replace('.', '', $data['cpf_cnpj'])))); $customerData->setCustomerName($data['firstname'] . ' ' . $data['lastname']); $customerData->setCustomerEmail($data['email']); $customerData->setBirthDay($customer['birthday']); $customerData->setGender($customer['sex']); // Billing Address $billingAddress = new BillingAddress(); $billingAddress->setStreet($data['payment_address_1']); $billingAddress->setNumber($data['payment_number_home']); $billingAddress->setComplement($data['payment_address_2']); $billingAddress->setNeighborhood($data['payment_neighborhood']); $billingAddress->setZipcode($data['payment_postcode']); $billingAddress->setCity($data['payment_city']); $billingAddress->setState($data['payment_zone_code']); $customerData->setBillingAddress($billingAddress); // Shipping Address $shippingAddress = new ShippingAddress(); $shippingAddress->setStreet($data['shipping_address_1']); $shippingAddress->setNumber($data['shipping_number_home']); $shippingAddress->setComplement($data['shipping_address_2']); $shippingAddress->setNeighborhood($data['shipping_neighborhood']); $shippingAddress->setZipcode($data['shipping_postcode']); $shippingAddress->setCity($data['shipping_city']); $shippingAddress->setState($data['shipping_zone_code']); $customerData->setShippingAddress($shippingAddress); // Phone Data $phoneData = new PhoneDataCollection(); $phoneData->setPhoneType("CELL"); $phoneData->setNumber(str_replace('(', '', str_replace(')', '', str_replace('-', '', str_replace(' ', '', $data['cellphone']))))); $customerData->setPhoneData($phoneData); $params['customerData'] = $converter->convertCustomerData($customerData); $params['changeShipment'] = false; //$url = 'http://200.142.203.223/ec/V1/wallet/transactions'; //Homologação $url = 'http://api.stelo.com.br/ec/V1/wallet/transactions'; $stelo = new Stelo(); $response = $stelo->sendRequest($url, $this->config->get('stelo_client_id'), $this->config->get('stelo_client_secret'), $params); $insert = "INSERT INTO " . DB_PREFIX . "transaction_stelo SET order_id = '" . $this->session->data['order_id'] . "', json_encode = '" . json_encode($params) . "', "; if ($response) { $insert .= "link_confirm = '" . $response['link'][0]['@href'] . "', link_cancel = '" . $response['link'][1]['@href'] . "', link_wallet = '" . $response['link'][2]['@href'] . "', order_stelo_id = '" . $response['orderData']['orderId'] . "', "; } $insert .= "date_added = NOW()"; $this->db->query($insert); return true; }