/** * Init Simplify SDK. */ protected function init_simplify_sdk() { // Include lib require_once dirname(__FILE__) . '/includes/Simplify.php'; Simplify::$publicKey = $this->public_key; Simplify::$privateKey = $this->private_key; Simplify::$userAgent = 'WooCommerce/' . WC()->version; }
<?php require_once "./lib/Simplify.php"; Simplify::$publicKey = 'sbpb_YmFhN2JmZTMtZDBkZi00MzA5LWI5M2EtYTBjNjlkNTE3ZTVm'; Simplify::$privateKey = 'Eu/MTPwWMsL97YuJ5XCI8oIW0Sl7uGskdUbY4VXsWsx5YFFQL0ODSXAOkNtXTToq'; $plan = Simplify_Plan::createPlan(array('amount' => '1000', 'renewalReminderLeadDays' => '7', 'name' => 'plan2', 'billingCycle' => 'FIXED', 'frequency' => 'WEEKLY', 'billingCycleLimit' => '4', 'frequencyPeriod' => '2')); print_r($plan); print_r($plan->id); ?>
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* Instructions: * 1. Replace public key and private key with your respective API keys * 2. This sample code charges $10 to the card token submitted. You can pass the charge parameter by uncommenting * the charge parameter */ header('Content-Type: application/json'); error_reporting(E_ALL); require_once "./lib/Simplify.php"; Simplify::$publicKey = 'YOUR_PUBLIC_API_KEY'; // such as 'sbpb_MzIxYmFjYzItYThiYS00ZDA3LTllZTctY2ZjYjIxY2QzYWMw'; Simplify::$privateKey = 'YOUR_PRIVATE_API_KEY'; // such as 'gEEh+NSgYUi4dqG+u3F3iTuOK4n1L01StM60skz7CUR5YFFQL0ODSXAOkNtXTToq'; $token = $_POST['simplifyToken']; //You can get the charge from the client by uncommenting line below // $charge = $_POST['charge']; $charge = 1000; // charges $10 $c = array('amount' => $charge, 'token' => $token, 'description' => 'product description', 'currency' => 'USD'); try { $charge = Simplify_Payment::createPayment($c); $chargeId = $charge->{'id'}; echo $charge->{'paymentStatus'} . " charged :" . $charge->{'amount'} / 100; } catch (Exception $e) { echo ' Caught exception: ', $e->getMessage(), "\n", $e;
/** * Use this to do the final payment. Create the order then process the payment. If * you know the payment is successful right away go ahead and change the order status * as well. * Call $mp->cart_checkout_error($msg, $context); to handle errors. If no errors * it will redirect to the next step. * * @param array $cart. Contains the cart contents for the current blog, global cart if $mp->global_cart is true * @param array $shipping_info. Contains shipping info and email in case you need it */ function process_payment($cart, $shipping_info) { global $mp; $settings = get_option('mp_settings'); // Token MUST be set at this point if (!isset($_SESSION['simplifyToken'])) { $mp->cart_checkout_error(__('The Simplify Token was not generated correctly. Please go back and try again.', 'mp')); return false; } // Setup the Simplify API if (!class_exists('Simplify')) { require_once $mp->plugin_dir . "plugins-gateway/simplify-files/lib/Simplify.php"; } Simplify::$publicKey = $this->publishable_key; Simplify::$privateKey = $this->private_key; $totals = array(); $coupon_code = $mp->get_coupon_code(); foreach ($cart as $product_id => $variations) { foreach ($variations as $variation => $data) { $price = $mp->coupon_value_product($coupon_code, $data['price'] * $data['quantity'], $product_id); $totals[] = $price; } } $total = array_sum($totals); //shipping line $shipping_tax = 0; if (($shipping_price = $mp->shipping_price(false)) !== false) { $total += $shipping_price; $shipping_tax = $mp->shipping_tax_price($shipping_price) - $shipping_price; } //tax line if tax inclusive pricing is off. It it's on it would screw up the totals if (!$mp->get_setting('tax->tax_inclusive')) { $tax_price = $mp->tax_price(false) + $shipping_tax; $total += $tax_price; } $order_id = $mp->generate_order_id(); try { $token = $SESSION['simplifyToken']; $charge = Simplify_Payment::createPayment(array('amount' => $total * 100, 'token' => $_SESSION['simplifyToken'], 'description' => sprintf(__('%s Store Purchase - Order ID: %s, Email: %s', 'mp'), get_bloginfo('name'), $order_id, $_SESSION['mp_shipping_info']['email']), 'currency' => $this->currency)); if ($charge->paymentStatus == 'APPROVED') { $payment_info = array(); $payment_info['gateway_public_name'] = $this->public_name; $payment_info['gateway_private_name'] = $this->admin_name; $payment_info['method'] = sprintf(__('%1$s Card ending in %2$s - Expires %3$s', 'mp'), $charge->card->type, $charge->card->last4, $charge->card->expMonth . '/' . $charge->card->expYear); $payment_info['transaction_id'] = $charge->id; $timestamp = time(); $payment_info['status'][$timestamp] = __('Paid', 'mp'); $payment_info['total'] = $total; $payment_info['currency'] = $this->currency; $order = $mp->create_order($order_id, $cart, $_SESSION['mp_shipping_info'], $payment_info, true); unset($_SESSION['simplifyToken']); $mp->set_cart_cookie(array()); } } catch (Exception $e) { unset($_SESSION['simplifyToken']); $mp->cart_checkout_error(sprintf(__('There was an error processing your card: "%s". Please <a href="%s">go back and try again</a>.', 'mp'), $e->getMessage(), mp_checkout_step_url('checkout'))); return false; } }
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> <?php try { $nombre = $_POST['nombre']; $apellidos = $_POST['apellidos']; $dir = $_POST['direccion']; $telefono = $_POST['telefono']; $correo = $_POST['correo']; (string) ($numtarj = $_POST['numtarj']); $mv = $_POST['mesv']; $av = $_POST['aniov']; $cs = $_POST['cs']; $prop = $_POST['propietario']; $con = $_POST['concepto']; $total = $_POST['total']; require_once "simplify/lib/Simplify.php"; Simplify::$publicKey = 'sbpb_MDhjZmRmNmQtMTJlZC00NmQ1LWI4NDYtZjRhZTg1NjgzZjVi'; Simplify::$privateKey = 'Q65+PyW5h8jdhFECaykl95C7HNO/PgvqWV5gUDFlGSt5YFFQL0ODSXAOkNtXTToq'; $payment = Simplify_Payment::createPayment(array("card" => array("number" => $numtarj, "expMonth" => $mv, "expYear" => $av, "cvc" => $cs), 'amount' => $total, 'description' => $con, 'currency' => 'USD')); if ($payment->paymentStatus == 'APPROVED') { echo "<center>"; echo "<p style='font-size: 50px;'><strong>Slyfer</strong></p>"; echo "<i class='fa fa-refresh fa-spin fa-5x'></i>"; echo "<p style='font-size: 20px;'><strong>Procesando Tu pago espera unos segundos...</strong></p>"; echo "</center>"; header('refresh:10; url=paysucefull.php'); } } catch (Exception $e) { echo $e; }
<?php require_once "./lib/Simplify.php"; /* number "5555555555554444" expmonth 11 expyear 15 cvc 123 */ $number = $_POST["number"]; $expMonth = $_POST["expMonth"]; $expYear = $_POST["expYear"]; $cvc = $_POST["cvc"]; $amount = $_POST["amount"]; $description = $_POST["description"]; Simplify::$publicKey = 'sbpb_ZjMyMTI0MGItMDc4YS00MDdiLWI0MmQtMWMyNWNlZGYzNGZj'; Simplify::$privateKey = 'DyQ6iAM7BBDJGpJPVopUWMAe+QcgNfPriHeonuJ8J7x5YFFQL0ODSXAOkNtXTToq'; $payment = Simplify_Payment::createPayment(array("card" => array("number" => $number, "expMonth" => $expMonth, "expYear" => $expYear, "cvc" => $cvc), 'amount' => $amount, 'description' => $description, 'currency' => 'USD')); if ($payment->paymentStatus == 'APPROVED') { header('Content-type: application/json'); $result = "done"; echo json_encode($result); } else { header('Content-type: application/json'); $result = "fail"; echo json_encode($result); die; }
<?php require_once "simplifycommerce/lib/Simplify.php"; Simplify::$publicKey = 'sbpb_ZDQ3ZjU3N2ItNWY5My00ZWU1LWI3NjUtMzNiMTQyMjc3NmVm'; Simplify::$privateKey = 'cl5KEXyHM7tgQDBP6XiMjaVEgAAPsHxEnnGlNF1xdxt5YFFQL0ODSXAOkNtXTToq'; $payment = Simplify_Payment::createPayment(array('amount' => $_REQUEST['amount'], 'token' => $_REQUEST['token'], 'description' => $_REQUEST['description'], 'reference' => '7a6ef6be31', 'currency' => 'USD')); if ($payment->paymentStatus == 'APPROVED') { echo "Payment approved\n"; }
function process_payment($cart) { global $tc; $this->maybe_start_session(); $this->save_cart_info(); if (isset($_POST['simplify_payment_form']) && $_POST['simplify_payment_form'] == 'not_available') { $_SESSION['tc_gateway_error'] = __('The Simplify Commerce is not available at the moment. Please try another method or contact the admnistrator', 'tc-sc'); wp_redirect($tc->get_payment_slug(true)); tc_js_redirect($tc->get_payment_slug(true)); return false; } if (!isset($_POST['simplifyToken'])) { $_SESSION['tc_gateway_error'] = __('The Simplify Commerce Token was not generated correctly. Please go back and try again.', 'tc'); wp_redirect($tc->get_payment_slug(true)); tc_js_redirect($tc->get_payment_slug(true)); return false; } $_SESSION['simplifyToken'] = $_POST['simplifyToken']; require_once $tc->plugin_dir . "/includes/gateways/simplify/Simplify.php"; //generate a tickera order id $order_id = $tc->generate_order_id(); Simplify::$publicKey = $this->public_key; Simplify::$privateKey = $this->private_key; try { $payment = Simplify_Payment::createPayment(array('amount' => $this->total() * 100, 'token' => $_SESSION['simplifyToken'], 'description' => $this->cart_items(), 'reference' => $order_id, 'currency' => $this->currency)); if ($payment->paymentStatus == 'APPROVED') { $payment_info = array(); $payment_info['transaction_id'] = $payment->id; $payment_info = $this->save_payment_info(); $tc->create_order($order_id, $this->cart_contents(), $this->cart_info(), $payment_info, true); wp_redirect($tc->get_confirmation_slug(true, $order_id)); tc_js_redirect($tc->get_confirmation_slug(true)); exit; } else { if ($payment->paymentStatus == 'DECLINED') { //run if the card is declined etc. // $_SESSION['tc_gateway_error'] = apply_filters('tc_simplify_declined_card', __('We\'re very sorry but the card you entered was declined ', 'tc-sc')); wp_redirect($tc->get_payment_slug(true)); tc_js_redirect($tc->get_payment_slug(true)); exit; } } } catch (Simplify_ApiException $e) { unset($_SESSION['simplifyToken']); $_SESSION['tc_gateway_error'] = sprintf(__('There was an error processing your card - "%s".', 'tc'), $e->getMessage()); wp_redirect($tc->get_payment_slug(true)); tc_js_redirect($tc->get_payment_slug(true)); exit; } return false; }
$totalAmount = $_SESSION['totalAmount']; $orders = $_SESSION['orders']; //Getting shipping address $address = $_REQUEST['address']; $city = $_REQUEST['city']; $state = $_REQUEST['state']; $zip = $_REQUEST['zip']; //Generate payment description $description = ""; foreach ($orders as $productId => $quantity) { $description .= $merchant->products[$productId]->name . ":\$" . number_format($merchant->products[$productId]->price / 100, 2) . "X" . $quantity . ","; } $description .= $address . " " . $city . " " . $state . " " . $zip; session_destroy(); try { Simplify::$publicKey = $simplifyPublicKey; Simplify::$privateKey = $simplifyPrivateKey; // if the save card details flag is set if ($_REQUEST['saveCardDetails'] == true && isset($customerName) == true && isset($customerEmail) == true) { // create a customer $customer = Simplify_Customer::createCustomer(array('token' => $simplifyToken, 'email' => $customerEmail, 'name' => $customerName, 'reference' => 'Simplify Cake customer')); // make a payment with the customer $payment = Simplify_Payment::createPayment(array('amount' => $totalAmount, 'description' => $description, 'currency' => 'USD', 'customer' => $customer->id)); } else { // make a payment with a card token $payment = Simplify_Payment::createPayment(array('amount' => $totalAmount, 'token' => $simplifyToken, 'description' => $description, 'currency' => 'USD')); } } catch (Exception $e) { //Something wrong //Error handling needed //echo $e;
* without specific prior written permission. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ header('Content-Type: application/json'); error_reporting(E_ALL); require_once "./sdk/lib/Simplify.php"; Simplify::$publicKey = getenv('SIMPLIFY_API_PUBLIC_KEY'); Simplify::$privateKey = getenv('SIMPLIFY_API_PRIVATE_KEY'); if (!isset($_POST["amount"]) || !isset($_POST['simplifyToken'])) { echo "Please submit POST values with amount & simplifyToken params!"; return; } $token = $_POST['simplifyToken']; $payment = $_POST["amount"]; $currency = isset($_POST["currency"]) ? $_POST["currency"] : 'USD'; $paymentPayload = array('amount' => $payment, 'token' => $token, 'description' => 'Test payment', 'currency' => $currency); $response = array(); try { $payment = Simplify_Payment::createPayment($paymentPayload); if ($payment->paymentStatus == 'APPROVED') { $response["id"] = $payment->{'id'}; }