public function createOpenpayCustomer() { $customerData = array('name' => $this->order->billing_first_name, 'last_name' => $this->order->billing_last_name, 'email' => $this->order->billing_email, 'requires_account' => false, 'phone_number' => $this->order->billing_phone, 'address' => array('line1' => substr($this->order->billing_address_1, 0, 200), 'line2' => substr($this->order->billing_address_2, 0, 50), 'line3' => '', 'state' => $this->order->billing_state, 'city' => $this->order->billing_city, 'postal_code' => $this->order->billing_postcode, 'country_code' => $this->order->billing_country)); $openpay = Openpay::getInstance($this->merchant_id, $this->private_key); Openpay::setProductionMode($this->is_sandbox ? false : true); try { $customer = $openpay->customers->add($customerData); if (is_user_logged_in()) { update_user_meta(get_current_user_id(), '_openpay_customer_id', $customer->id); } return $customer; } catch (Exception $e) { $this->error($e); return false; } }
/** * Register the application services. * * @return void */ public function register() { $this->app->singleton('Intagono\\Openpay\\Openpay', function ($app) { $productionMode = config('openpay.production_mode'); $merchantId = config('openpay.merchant_id'); $privayeKey = config('openpay.private_key'); $openpayCore = OpenpayCore::getInstance($merchantId, $privayeKey); if ($productionMode) { OpenpayCore::setProductionMode(true); } return new Openpay($openpayCore); }); $this->app->bind('openpay', 'Intagono\\Openpay\\Openpay'); $this->mergeConfigFrom(__DIR__ . '/config/openpay.php', 'openpay'); }
public function createOpenpayWebhook($webhook_data) { $result = new stdClass(); $file = $this->file; if (file_exists($file)) { require_once $file; } else { $result->error = 'Openpay library is missing'; return $result; } $sk = $this->getSecretApiKey(); $id = $this->getMerchantId(); $openpay = Openpay::getInstance($id, $sk); Openpay::setProductionMode($this->isProductionMode()); try { $webhook = $openpay->webhooks->add($webhook_data); return $webhook; } catch (OpenpayApiTransactionError $e) { $result->error = $this->error($e); } catch (OpenpayApiRequestError $e) { $result->error = $this->error($e); } catch (OpenpayApiConnectionError $e) { $result->error = $this->error($e); } catch (OpenpayApiAuthError $e) { $result->error = $this->error($e); } catch (OpenpayApiError $e) { $result->error = $this->error($e); } catch (Exception $e) { $result->error = $this->error($e); } return $result; }
public function createWebhook($force_host_ssl = false) { $protocol = get_option('woocommerce_force_ssl_checkout') == 'no' ? 'http' : 'https'; $url = site_url('/', $protocol) . 'wc-api/Openpay_Stores'; $webhook_data = array('url' => $url, 'force_host_ssl' => $force_host_ssl, 'event_types' => array('verification', 'charge.succeeded', 'charge.created', 'charge.cancelled', 'charge.failed', 'payout.created', 'payout.succeeded', 'payout.failed', 'spei.received', 'chargeback.created', 'chargeback.rejected', 'chargeback.accepted')); $openpay = Openpay::getInstance($this->merchant_id, $this->private_key); Openpay::setProductionMode($this->is_sandbox ? false : true); try { $webhook = $openpay->webhooks->add($webhook_data); if (is_user_logged_in()) { update_user_meta(get_current_user_id(), '_openpay_webhook_id', $webhook->id); } return $webhook; } catch (Exception $e) { $force_host_ssl = $force_host_ssl == false ? true : false; // Si viene con parámtro FALSE, solicito que se force el host SSL $this->errorWebhook($e, $force_host_ssl, $url); return false; } }
protected function _setOpenpayObject() { /* Create OpenPay object */ $this->_openpay = Openpay::getInstance(Mage::getStoreConfig('payment/common/merchantid'), Mage::getStoreConfig('payment/common/privatekey')); Openpay::setProductionMode(!Mage::getStoreConfig('payment/common/sandbox')); }