コード例 #1
0
 /**
  * Get a single record by creating a WHERE clause with
  * a value for your primary key
  *
  * @param string $primary_value The value of your primary key
  * @return object or array
  */
 public function get($card_id)
 {
     try {
         $ch = Stripe_Token::retrieve($card_id);
         return $ch;
     } catch (Exception $e) {
         $this->error = TRUE;
         $this->message = $e->getMessage();
         $this->code = $e->getCode();
         return FALSE;
     }
 }
コード例 #2
0
ファイル: stripe_process.php プロジェクト: nseet/SIVIsuite
 if ($customerId == "") {
     # Create a Customer if the customer is already not in database.
     $customer = Stripe_Customer::create(array("card" => $token, "description" => $_SESSION['FBID']));
     // Save the customer ID in your database so you can use it later
     saveStripeCustomerId($_SESSION['FBID'], $customer->id);
     error_log("Saving Customer [" . $_SESSION['FBID'] . "] [" . $customer->id . "]");
     $customerId = $customer->id;
 }
 if ($customerId != "") {
     // Save the Transaction details in your database so you can use it later
     ## The default card is the 1st card
     list($fullName, $email) = getFullName($_SESSION['FBID']);
     $sid = $_SESSION['FBID'];
     #autoSubscribe($email);
     ## Get current Card ID from Token
     $retrieve_token = Stripe_Token::retrieve($token);
     $card_id = $retrieve_token->card->id;
     error_log("token :: [" . $token . "]");
     error_log("card_id :: [" . $card_id . "]");
     ## To check whether the Card is already in Customer Base if not we will add this now.
     $customer_data = Stripe_Customer::retrieve($customerId);
     error_log(">>>>>>>>>>>>>CUSTOMER OBJECT>>>>>>>>>>>>>>>>>>");
     error_log(print_r($customer_data, true), 0);
     try {
         $getCard = $customer_data->sources->retrieve($card_id);
         error_log(">>>>>>>>>>>>>CARD_OBJECT>>>>>>>>>>>>>>>>>>");
         error_log(print_r($getCard, true), 0);
     } catch (Stripe_InvalidRequestError $e) {
         // Invalid Request Possibly this card is not available.
         error_log("This Card is not Available \n");
         $getCard->id = '';
コード例 #3
0
ファイル: stripe.php プロジェクト: vilmark/vilmark_main
 /**
  * Return the chosen payment details here for final confirmation. You probably don't need
  *	to post anything in the form as it should be in your $_SESSION var already.
  *
  * @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 confirm_payment_form($cart, $shipping_info)
 {
     global $mp;
     $settings = get_option('mp_settings');
     //make sure token is set at this point
     if (!isset($_SESSION['stripeToken'])) {
         $mp->cart_checkout_error(__('The Stripe Token was not generated correctly. Please go back and try again.', 'mp'));
         return false;
     }
     //setup the Stripe API
     if (!class_exists('Stripe')) {
         require_once $mp->plugin_dir . "plugins-gateway/stripe-files/lib/Stripe.php";
     }
     Stripe::setApiKey($this->private_key);
     try {
         $token = Stripe_Token::retrieve($_SESSION['stripeToken']);
     } catch (Exception $e) {
         $mp->cart_checkout_error(sprintf(__('%s. Please go back and try again.', 'mp'), $e->getMessage()));
         return false;
     }
     $content = '';
     $content .= '<table class="mp_cart_billing">';
     $content .= '<thead><tr>';
     $content .= '<th>' . __('Billing Information:', 'mp') . '</th>';
     $content .= '<th align="right"><a href="' . mp_checkout_step_url('checkout') . '">' . __('&laquo; Edit', 'mp') . '</a></th>';
     $content .= '</tr></thead>';
     $content .= '<tbody>';
     $content .= '<tr>';
     $content .= '<td align="right">' . __('Payment method:', 'mp') . '</td>';
     $content .= '<td>' . sprintf(__('Your <strong>%1$s Card</strong> ending in <strong>%2$s</strong>. Expires <strong>%3$s</strong>', 'mp'), $token->card->type, $token->card->last4, $token->card->exp_month . '/' . $token->card->exp_year) . '</td>';
     $content .= '</tr>';
     $content .= '</tbody>';
     $content .= '</table>';
     return $content;
 }