You are here

function _uc_stripe_post_transaction in Ubercart Stripe 6

Same name and namespace in other branches
  1. 7 uc_stripe.module \_uc_stripe_post_transaction()

Post transactions to Stripe using this function.

1 call to _uc_stripe_post_transaction()
uc_stripe_charge in ./uc_stripe.module
uc_credit callback for creating an actual credit card charge

File

./uc_stripe.module, line 714
A module used for Stripe. Developed by Victor Quinn for Health for Hackers (http://www.healthforhackers.com)

Code

function _uc_stripe_post_transaction($order_id, $data) {
  global $user;
  try {
    $charge_object = Stripe_Charge::create($data);
    $result = array(
      'success' => TRUE,
      'message' => t('Credit card payment processed successfully.'),
      'uid' => $user->uid,
      'trans_id' => $charge_object
        ->__get('id'),
    );
  } catch (Exception $e) {
    $result = array(
      'success' => FALSE,
      'comment' => $e
        ->getCode(),
      'message' => t("Credit card declined. !message", array(
        "!message" => $e
          ->getMessage(),
      )),
      'uid' => $user->uid,
      'order_id' => $order_id,
    );
  }
  uc_order_comment_save($order_id, $user->uid, $result['message'], 'admin');
  return $result;
}