Esempio n. 1
0
 /**
  * Creates an Simplify_Payment object
  * @param     array $hash a map of parameters; valid keys are:<dl style="padding-left:10px;">
  *     <dt><tt>amount</tt></dt>    <dd>Amount of the payment (minor units). Example: 1000 = 10.00 <strong>required </strong></dd>
  *     <dt><tt>card.addressCity</tt></dt>    <dd>City of the cardholder. </dd>
  *     <dt><tt>card.addressCountry</tt></dt>    <dd>Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. </dd>
  *     <dt><tt>card.addressLine1</tt></dt>    <dd>Address of the cardholder. </dd>
  *     <dt><tt>card.addressLine2</tt></dt>    <dd>Address of the cardholder if needed. </dd>
  *     <dt><tt>card.addressState</tt></dt>    <dd>State code (USPS code) of residence of the cardholder. </dd>
  *     <dt><tt>card.addressZip</tt></dt>    <dd>Postal code of the cardholder. </dd>
  *     <dt><tt>card.cvc</tt></dt>    <dd>CVC security code of the card. This is the code on the back of the card. Example: 123 </dd>
  *     <dt><tt>card.expMonth</tt></dt>    <dd>Expiration month of the card. Format is MM. Example: January = 01 <strong>required </strong></dd>
  *     <dt><tt>card.expYear</tt></dt>    <dd>Expiration year of the card. Format is YY. Example: 2013 = 13 <strong>required </strong></dd>
  *     <dt><tt>card.name</tt></dt>    <dd>Name as it appears on the card. </dd>
  *     <dt><tt>card.number</tt></dt>    <dd>Card number as it appears on the card. <strong>required </strong></dd>
  *     <dt><tt>currency</tt></dt>    <dd>Currency code (ISO-4217) for the transaction. Must match the currency associated with your account. <strong>required </strong><strong>default:USD</strong></dd>
  *     <dt><tt>customer</tt></dt>    <dd>ID of customer. If specified, card on file of customer will be used. </dd>
  *     <dt><tt>description</tt></dt>    <dd>Custom naming of payment for external systems to use. </dd>
  *     <dt><tt>token</tt></dt>    <dd>If specified, card associated with card token will be used. </dd></dl>
  * @param     string publicKey Public key. If null, the value of static Simplify::$publicKey will be used
  * @param     string privateKey Private key. If null, the value of static Simplify::$privateKey will be used
  * @return    Payment a Payment object.
  */
 public static function createPayment($hash, $publicKey = null, $privateKey = null)
 {
     $instance = new Simplify_Payment();
     $instance->setAll($hash);
     $object = Simplify_PaymentsApi::createObject($instance, $publicKey, $privateKey);
     return $object;
 }
Esempio n. 2
0
 /**
  * Creates an Simplify_Payment object
  * @param     array $hash a map of parameters; valid keys are:<dl style="padding-left:10px;">
  *     <dt><tt>amount</tt></dt>    <dd>Amount of the payment (in the smallest unit of your currency). Example: 100 = $1.00USD </dd>
  *     <dt><tt>authorization</tt></dt>    <dd>The ID of the authorization being used to capture the payment. </dd>
  *     <dt><tt>card.addressCity</tt></dt>    <dd>City of the cardholder. [max length: 50, min length: 2] </dd>
  *     <dt><tt>card.addressCountry</tt></dt>    <dd>Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. [max length: 2, min length: 2] </dd>
  *     <dt><tt>card.addressLine1</tt></dt>    <dd>Address of the cardholder. [max length: 255] </dd>
  *     <dt><tt>card.addressLine2</tt></dt>    <dd>Address of the cardholder if needed. [max length: 255] </dd>
  *     <dt><tt>card.addressState</tt></dt>    <dd>State of residence of the cardholder. For the US, this is a 2-digit USPS code. [max length: 255, min length: 2] </dd>
  *     <dt><tt>card.addressZip</tt></dt>    <dd>Postal code of the cardholder. The postal code size is between 5 and 9 in length and only contain numbers or letters. [max length: 9, min length: 3] </dd>
  *     <dt><tt>card.cvc</tt></dt>    <dd>CVC security code of the card. This is the code on the back of the card. Example: 123 </dd>
  *     <dt><tt>card.expMonth</tt></dt>    <dd>Expiration month of the card. Format is MM. Example: January = 01 [min value: 1, max value: 12] <strong>required </strong></dd>
  *     <dt><tt>card.expYear</tt></dt>    <dd>Expiration year of the card. Format is YY. Example: 2013 = 13 [min value: 0, max value: 99] <strong>required </strong></dd>
  *     <dt><tt>card.name</tt></dt>    <dd>Name as it appears on the card. [max length: 50, min length: 2] </dd>
  *     <dt><tt>card.number</tt></dt>    <dd>Card number as it appears on the card. [max length: 19, min length: 13] <strong>required </strong></dd>
  *     <dt><tt>currency</tt></dt>    <dd>Currency code (ISO-4217) for the transaction. Must match the currency associated with your account. [default: USD] <strong>required </strong></dd>
  *     <dt><tt>customer</tt></dt>    <dd>ID of customer. If specified, card on file of customer will be used. </dd>
  *     <dt><tt>description</tt></dt>    <dd>Free form text field to be used as a description of the payment. This field is echoed back with the payment on any find or list operations. [max length: 1024] </dd>
  *     <dt><tt>invoice</tt></dt>    <dd>ID of invoice for which this payment is being made. </dd>
  *     <dt><tt>reference</tt></dt>    <dd>Custom reference field to be used with outside systems. </dd>
  *     <dt><tt>replayId</tt></dt>    <dd>An identifier that can be sent to uniquely identify a payment request to facilitate retries due to I/O related issues. This identifier must be unique for your account (sandbox or live) across all of your payments. If supplied, we will check for a payment on your account that matches this identifier. If found will attempt to return an identical response of the original request. [max length: 50, min length: 1] </dd>
  *     <dt><tt>statementDescription.name</tt></dt>    <dd>Merchant name. <strong>required </strong></dd>
  *     <dt><tt>statementDescription.phoneNumber</tt></dt>    <dd>Merchant contact phone number. </dd>
  *     <dt><tt>token</tt></dt>    <dd>If specified, card associated with card token will be used. [max length: 255] </dd></dl>
  * @param     $authentication -  information used for the API call.  If no value is passed the global keys Simplify::public_key and Simplify::private_key are used.  <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.<i/>
  * @return    Payment a Payment object.
  */
 public static function createPayment($hash, $authentication = null)
 {
     $args = func_get_args();
     $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
     $instance = new Simplify_Payment();
     $instance->setAll($hash);
     $object = Simplify_PaymentsApi::createObject($instance, $authentication);
     return $object;
 }
 /**
  * process_subscription_payment function.
  *
  * @param WC_order $order
  * @param integer $amount (default: 0)
  * @uses  Simplify_BadRequestException
  * @return bool|WP_Error
  */
 public function process_subscription_payment($order, $amount = 0)
 {
     if (0 == $amount) {
         // Payment complete
         $order->payment_complete();
         return true;
     }
     if ($amount * 100 < 50) {
         return new WP_Error('simplify_error', __('Sorry, the minimum allowed order total is 0.50 to use this payment method.', 'woocommerce'));
     }
     $order_items = $order->get_items();
     $order_item = array_shift($order_items);
     $subscription_name = sprintf(__('%s - Subscription for "%s"', 'woocommerce'), esc_html(get_bloginfo('name', 'display')), $order_item['name']) . ' ' . sprintf(__('(Order #%s)', 'woocommerce'), $order->get_order_number());
     $customer_id = get_post_meta($order->id, '_simplify_customer_id', true);
     if (!$customer_id) {
         return new WP_Error('simplify_error', __('Customer not found', 'woocommerce'));
     }
     try {
         // Charge the customer
         $payment = Simplify_Payment::createPayment(array('amount' => $amount * 100, 'customer' => $customer_id, 'description' => trim(substr($subscription_name, 0, 1024)), 'currency' => strtoupper(get_woocommerce_currency()), 'reference' => $order->id, 'card.addressCity' => $order->billing_city, 'card.addressCountry' => $order->billing_country, 'card.addressLine1' => $order->billing_address_1, 'card.addressLine2' => $order->billing_address_2, 'card.addressState' => $order->billing_state, 'card.addressZip' => $order->billing_postcode));
     } catch (Exception $e) {
         $error_message = $e->getMessage();
         if ($e instanceof Simplify_BadRequestException && $e->hasFieldErrors() && $e->getFieldErrors()) {
             $error_message = '';
             foreach ($e->getFieldErrors() as $error) {
                 $error_message .= ' ' . $error->getFieldName() . ': "' . $error->getMessage() . '" (' . $error->getErrorCode() . ')';
             }
         }
         $order->add_order_note(sprintf(__('Simplify payment error: %s', 'woocommerce'), $error_message));
         return new WP_Error('simplify_payment_declined', $e->getMessage(), array('status' => $e->getCode()));
     }
     if ('APPROVED' == $payment->paymentStatus) {
         // Payment complete
         $order->payment_complete($payment->id);
         // Add order note
         $order->add_order_note(sprintf(__('Simplify payment approved (ID: %s, Auth Code: %s)', 'woocommerce'), $payment->id, $payment->authCode));
         return true;
     } else {
         $order->add_order_note(__('Simplify payment declined', 'woocommerce'));
         return new WP_Error('simplify_payment_declined', __('Payment was declined - please try another card.', 'woocommerce'));
     }
 }
 /**
  * do payment function.
  *
  * @param WC_order $order
  * @param int $amount (default: 0)
  * @uses  Simplify_BadRequestException
  * @return bool|WP_Error
  */
 public function do_payment($order, $amount = 0, $token = array())
 {
     if ($amount * 100 < 50) {
         return new WP_Error('simplify_error', __('Sorry, the minimum allowed order total is 0.50 to use this payment method.', 'woocommerce'));
     }
     try {
         // Charge the customer
         $data = array('amount' => $amount * 100, 'description' => sprintf(__('%1$s - Order #%2$s', 'woocommerce'), esc_html(get_bloginfo('name', 'display')), $order->get_order_number()), 'currency' => strtoupper(get_woocommerce_currency()), 'reference' => $order->get_id());
         $data = array_merge($data, $token);
         $payment = Simplify_Payment::createPayment($data);
     } catch (Exception $e) {
         $error_message = $e->getMessage();
         if ($e instanceof Simplify_BadRequestException && $e->hasFieldErrors() && $e->getFieldErrors()) {
             $error_message = '';
             foreach ($e->getFieldErrors() as $error) {
                 $error_message .= ' ' . $error->getFieldName() . ': "' . $error->getMessage() . '" (' . $error->getErrorCode() . ')';
             }
         }
         $order->add_order_note(sprintf(__('Simplify payment error: %s', 'woocommerce'), $error_message));
         return new WP_Error('simplify_payment_declined', $e->getMessage(), array('status' => $e->getCode()));
     }
     if ('APPROVED' == $payment->paymentStatus) {
         // Payment complete
         $order->payment_complete($payment->id);
         // Add order note
         $order->add_order_note(sprintf(__('Simplify payment approved (ID: %1$s, Auth Code: %2$s)', 'woocommerce'), $payment->id, $payment->authCode));
         return true;
     } else {
         $order->add_order_note(__('Simplify payment declined', 'woocommerce'));
         return new WP_Error('simplify_payment_declined', __('Payment was declined - please try another card.', 'woocommerce'));
     }
 }
 /**
  * Process standard payments
  *
  * @param  WC_Order $order
  * @param  string   $cart_token
  * @uses   Simplify_ApiException
  * @uses   Simplify_BadRequestException
  * @return array
  */
 protected function process_standard_payments($order, $cart_token = '')
 {
     try {
         if (empty($cart_token)) {
             $error_msg = __('Please make sure your card details have been entered correctly and that your browser supports JavaScript.', 'woocommerce');
             if ('yes' == $this->sandbox) {
                 $error_msg .= ' ' . __('Developers: Please make sure that you\'re including jQuery and there are no JavaScript errors on the page.', 'woocommerce');
             }
             throw new Simplify_ApiException($error_msg);
         }
         $payment = Simplify_Payment::createPayment(array('amount' => $order->order_total * 100, 'token' => $cart_token, 'description' => sprintf(__('%s - Order #%s', 'woocommerce'), esc_html(get_bloginfo('name', 'display')), $order->get_order_number()), 'currency' => strtoupper(get_woocommerce_currency()), 'reference' => $order->id, 'card.addressCity' => $order->billing_city, 'card.addressCountry' => $order->billing_country, 'card.addressLine1' => $order->billing_address_1, 'card.addressLine2' => $order->billing_address_2, 'card.addressState' => $order->billing_state, 'card.addressZip' => $order->billing_postcode));
         $order_complete = $this->process_order_status($order, $payment->id, $payment->paymentStatus, $payment->authCode);
         if ($order_complete) {
             // Return thank you page redirect
             return array('result' => 'success', 'redirect' => $this->get_return_url($order));
         } else {
             $order->add_order_note(__('Simplify payment declined', 'woocommerce'));
             throw new Simplify_ApiException(__('Payment was declined - please try another card.', 'woocommerce'));
         }
     } catch (Simplify_ApiException $e) {
         if ($e instanceof Simplify_BadRequestException && $e->hasFieldErrors() && $e->getFieldErrors()) {
             foreach ($e->getFieldErrors() as $error) {
                 wc_add_notice($error->getFieldName() . ': "' . $error->getMessage() . '" (' . $error->getErrorCode() . ')', 'error');
             }
         } else {
             wc_add_notice($e->getMessage(), 'error');
         }
         return array('result' => 'fail', 'redirect' => '');
     }
 }
Esempio n. 6
0
 * 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;
}
 /**
  * Process a pre-order payment when the pre-order is released.
  *
  * @param WC_Order $order
  * @return wp_error|null
  */
 public function process_pre_order_release_payment($order)
 {
     try {
         $order_items = $order->get_items();
         $order_item = array_shift($order_items);
         $pre_order_name = sprintf(__('%s - Pre-order for "%s"', 'woocommerce'), esc_html(get_bloginfo('name', 'display')), $order_item['name']) . ' ' . sprintf(__('(Order #%s)', 'woocommerce'), $order->get_order_number());
         $customer_id = get_post_meta($order->id, '_simplify_customer_id', true);
         if (!$customer_id) {
             return new WP_Error('simplify_error', __('Customer not found', 'woocommerce'));
         }
         // Charge the customer
         $payment = Simplify_Payment::createPayment(array('amount' => $order->order_total * 100, 'customer' => $customer_id, 'description' => trim(substr($pre_order_name, 0, 1024)), 'currency' => strtoupper(get_woocommerce_currency()), 'reference' => $order->id));
         if ('APPROVED' == $payment->paymentStatus) {
             // Payment complete
             $order->payment_complete($payment->id);
             // Add order note
             $order->add_order_note(sprintf(__('Simplify payment approved (ID: %s, Auth Code: %s)', 'woocommerce'), $payment->id, $payment->authCode));
         } else {
             return new WP_Error('simplify_payment_declined', __('Payment was declined - the customer need to try another card.', 'woocommerce'));
         }
     } catch (Exception $e) {
         $order_note = sprintf(__('Simplify Transaction Failed (%s)', 'woocommerce'), $e->getMessage());
         // Mark order as failed if not already set,
         // otherwise, make sure we add the order note so we can detect when someone fails to check out multiple times
         if ('failed' != $order->get_status()) {
             $order->update_status('failed', $order_note);
         } else {
             $order->add_order_note($order_note);
         }
     }
 }
Esempio n. 8
0
<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;
}
Esempio n. 9
0
 /**
  * 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;
     }
 }
Esempio n. 10
0
<?php

require_once "./lib/Simplify.php";
Simplify::$publicKey = 'sbpb_YmFhN2JmZTMtZDBkZi00MzA5LWI5M2EtYTBjNjlkNTE3ZTVm';
Simplify::$privateKey = 'Eu/MTPwWMsL97YuJ5XCI8oIW0Sl7uGskdUbY4VXsWsx5YFFQL0ODSXAOkNtXTToq';
$payment = Simplify_Payment::createPayment(array('amount' => floatval($_POST["amount"]) * 100, 'token' => $_POST["simplifyToken"], 'description' => 'One-time Single Donation', 'reference' => '7a6ef6be31', 'currency' => 'USD'));
if ($payment->paymentStatus == 'APPROVED') {
    echo "Payment approved\n";
}
echo $_GET["simplifyToken"];
?>

Esempio n. 11
0
<?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;
}
Esempio n. 12
0
        <?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;
 }
Esempio n. 14
0
    $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;
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>Checkout - <?php 
echo $merchant->name;
?>
Esempio n. 15
0
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'};
    }
    $response["status"] = $payment->paymentStatus;
} catch (Exception $e) {
    //error handling
    if ($e instanceof Simplify_ApiException) {
        $response["reference"] = $e->getReference();
        $response["message"] = $e->getMessage();
        $response["errorCode"] = $e->getErrorCode();
    }
    if ($e instanceof Simplify_BadRequestException && $e->hasFieldErrors()) {
        $fieldErrors = '';
        foreach ($e->getFieldErrors() as $fieldError) {
            $fieldErrors = $fieldErrors . $fieldError->getFieldName() . ": '" . $fieldError->getMessage() . "' (" . $fieldError->getErrorCode() . ")";