Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2018
    Posts
    165
    Plugin Contributions
    4

    Default New Stripe Payment addon in development

    The following url:

    https://github.com/drillsar/Stripe-Zen-Cart

    If anyone can help with this project would be appreciated.

  2. #2
    Join Date
    Jan 2018
    Posts
    165
    Plugin Contributions
    4

    Default Re: New Stripe Payment addon in development

    I am going to test phase. As of now updated Api Version. Will test tonight

  3. #3
    Join Date
    Jan 2018
    Posts
    165
    Plugin Contributions
    4

    Default Re: New Stripe Payment addon in development

    Quote Originally Posted by tmccaff View Post
    I am going to test phase. As of now updated Api Version. Will test tonight
    Ok it charges cutomer but when they come back have an issue:

    I forget is there away to print array or debug this code?

    Must provide source or customer:

    Here is the old code:

    PHP Code:
    Stripe::setApiKey($secret_key);
            
    $error '';
            
    // get the credit card details submitted by the form
            
    $token $_POST['StripeToken'];
            
    //existing customer
            
    if (zen_not_null($_POST['StripeCustomerID'])) {
                if (
    $token == 'NONE') {
                    
    //charge the customer on existing card
                    
    try {
                        
    $charge Stripe_Charge::create(array(
                            
    //"amount" => ($order->info['total']) * 100, // amount in cents
                            //fimgirl fix for total
                            
    "amount" =>floor(($order->info['total']) * 100),
                            
    "currency" => MODULE_PAYMENT_STRIPEPAY_CURRENCY,
                            
    "customer" => $_POST['StripeCustomerID']
                        ));
                    }
                    catch (
    Exception $e) {
                        
    $error $e->getMessage();
                        
    $messageStack->add_session('checkout_confirmation'$error '<!-- [' $this->code '] -->''error');
                        
    zen_redirect(zen_href_link(FILENAME_CHECKOUT_CONFIRMATION'''SSL'truefalse));
                    }
                } 
    //end use existing card
                //start new card
                //new card for the customer and he wants to save it (or we are not allowing the option do StripesaveCard==YES
                
    elseif (zen_not_null($_POST['StripeSaveCard']) && ($_POST['StripeSaveCard'] == 'YES')) {
                    try {
                        
    //update the card for the customer
                        
    $cu       Stripe_Customer::retrieve($_POST['StripeCustomerID']);
                        
    $cu->source $token;
                        
    $cu->save();
                        
    //charge the customer
                        
    $charge Stripe_Charge::create(array(
                            
    //"amount" => ($order->info['total']) * 100, // amount in cents
                            //fimgirl fix for total
                            
    "amount" =>floor(($order->info['total']) * 100),
                            
    "currency" => MODULE_PAYMENT_STRIPEPAY_CURRENCY,
                            
    "customer" => $_POST['StripeCustomerID']
                        ));
                    }
                    catch (
    Exception $e) {
                    
    $error $e->getMessage();
                    
    $messageStack->add_session('checkout_confirmation'$error '<!-- [' $this->code '] -->''error');
                    
    zen_redirect(zen_href_link(FILENAME_CHECKOUT_CONFIRMATION'''SSL'truefalse));
                }
                } 
    //end save card
                
    else {
                    
    //a saved customer has entered new card details but does NOT want them saved. Currently (Nov 2012) Stripe does not allow you to remove a card object so you'll have to charge the card and not the customer
                    
    try {
                        
    // create the charge on Stripe's servers - this will charge the user's card no customer object
                        
    $charge Stripe_Charge::create(array(
                           
    // "amount" => ($order->info['total']) * 100, // amount in cents
                                        //fimgirl fix for total
                            
    "amount" =>floor(($order->info['total']) * 100),
                            
    "currency" => MODULE_PAYMENT_STRIPEPAY_CURRENCY,
                            
    "card" => $token,
                            
    "description" => $order->customer['email_address']
                        ));
                    }
                    catch (
    Exception $e) {
                    
    $error $e->getMessage();
                    
    $messageStack->add_session('checkout_confirmation'$error '<!-- [' $this->code '] -->''error');
                    
    zen_redirect(zen_href_link(FILENAME_CHECKOUT_CONFIRMATION'''SSL'truefalse));
                }
                }
            } 
    //end existing customer
            //new customer wants to save card details
            
    elseif (zen_not_null($_POST['StripeSaveCard']) && ($_POST['StripeSaveCard'] == 'YES')) {
                
    //new customer create the object
                
    try {
                    
    // create a Customer
                    
    $customer Stripe_Customer::create(array(
                        
    "card" => $token,
                        
    "description" => $order->customer['email_address']
                    ));
                    
    // charge the Customer instead of the card
                    
    $charge   Stripe_Charge::create(array(
                    
    //    "amount" => ($order->info['total']) * 100, // amount in cents
                                            //fimgirl fix for total
                        
    "amount" =>floor(($order->info['total']) * 100),
                        
    "currency" => MODULE_PAYMENT_STRIPEPAY_CURRENCY,
                        
    "customer" => $customer->id
                    
    ));
                }

                catch (
    Exception $e) {
                    
    $error $e->getMessage();
                    
    $messageStack->add_session('checkout_confirmation'$error '<!-- [' $this->code '] -->''error');
                    
    zen_redirect(zen_href_link(FILENAME_CHECKOUT_CONFIRMATION'''SSL'truefalse));
                }
            }
            
    //   not a customer token
            
    else {
                try {
                    
    // create the charge on Stripe's servers - this will charge the user's card no customer object
                    
    $charge Stripe_Charge::create(array(
                      
    //  "amount" => ($order->info['total']) * 100, // amount in cents
                                                //fimgirl fix for total
                        
    "amount" =>floor(($order->info['total']) * 100),
                        
    "currency" => MODULE_PAYMENT_STRIPEPAY_CURRENCY,
                        
    "card" => $token,
                        
    "description" => $order->customer['email_address']
                    ));
                }
                catch (
    Exception $e) {
                    
    $error $e->getMessage();
                    
    $messageStack->add_session('checkout_confirmation'$error '<!-- [' $this->code '] -->''error');
                    
    zen_redirect(zen_href_link(FILENAME_CHECKOUT_CONFIRMATION'''SSL'truefalse));
                }
            } 
    //end not a customer token
            //    die ( $charge);
            
    return false;
        } 
    I changed it to:
    PHP Code:
           \Stripe\Stripe::setApiKey($secret_key);
            
    $error '';
            
    // get the credit card details submitted by the form
            
    $token $_POST['StripeToken'];
            
    //existing customer
            
    if (zen_not_null($_POST['StripeCustomerID'])) {
                if (
    $token == 'NONE') {
                    
    //charge the customer on existing card
                    
    try {
                        
    $charge = \Stripe\Charge::create(array(
                            
    //"amount" => ($order->info['total']) * 100, // amount in cents
                            //fimgirl fix for total
                            
    "amount" =>floor(($order->info['total']) * 100),
                            
    "currency" => MODULE_PAYMENT_STRIPEPAY_CURRENCY,
                            
    "customer" => $_POST['StripeCustomerID']
                        ));
                    }
                    catch (
    Exception $e) {
                        
    $error $e->getMessage();
                        
    $messageStack->add_session('checkout_confirmation'$error '<!-- [' $this->code '] -->''error');
                        
    zen_redirect(zen_href_link(FILENAME_CHECKOUT_CONFIRMATION'''SSL'truefalse));
                    }
                } 
    //end use existing card
                //start new card
                //new card for the customer and he wants to save it (or we are not allowing the option do StripesaveCard==YES
                
    elseif (zen_not_null($_POST['StripeSaveCard']) && ($_POST['StripeSaveCard'] == 'YES')) {
                    try {
                        
    //update the card for the customer
                        
    $customer = \Stripe\Customer::retrieve($_POST['StripeCustomerID']);
                        
    $customer->default_source $card->id;
                        
    $customer->save();
                        
    //charge the customer
                        
    $charge = \Stripe\Charge::create(array(
                            
    //"amount" => ($order->info['total']) * 100, // amount in cents
                            //fimgirl fix for total
                            
    "amount" =>floor(($order->info['total']) * 100),
                            
    "currency" => MODULE_PAYMENT_STRIPEPAY_CURRENCY,
                            
    "customer" => $_POST['StripeCustomerID']
                        ));
                    }
                    catch (
    Exception $e) {
                    
    $error $e->getMessage();
                    
    $messageStack->add_session('checkout_confirmation'$error '<!-- [' $this->code '] -->''error');
                    
    zen_redirect(zen_href_link(FILENAME_CHECKOUT_CONFIRMATION'''SSL'truefalse));
                }
                } 
    //end save card
                
    else {
                    
    //a saved customer has entered new card details but does NOT want them saved. Currently (Nov 2012) Stripe does not allow you to remove a card object so you'll have to charge the card and not the customer
                    
    try {
                        
    // create the charge on Stripe's servers - this will charge the user's card no customer object
                        
    $charge = \Stripe\Charge::create(array(
                           
    // "amount" => ($order->info['total']) * 100, // amount in cents
                                        //fimgirl fix for total
                            
    "amount" =>floor(($order->info['total']) * 100),
                            
    "currency" => MODULE_PAYMENT_STRIPEPAY_CURRENCY,
                            
    "card" => $token,
                            
    "description" => $order->customer['email_address']
                        ));
                    }
                    catch (
    Exception $e) {
                    
    $error $e->getMessage();
                    
    $messageStack->add_session('checkout_confirmation'$error '<!-- [' $this->code '] -->''error');
                    
    zen_redirect(zen_href_link(FILENAME_CHECKOUT_CONFIRMATION'''SSL'truefalse));
                }
                }
            } 
    //end existing customer 
    It could be another area of code that is causing the problem not sure

  4. #4
    Join Date
    Mar 2007
    Posts
    248
    Plugin Contributions
    6

    Default Re: New Stripe Payment addon in development

    Did you manage to complete this module? Looking to change to stripe to offer Applepay to customers.. so interested in this.

 

 

Similar Threads

  1. Stripe.com payment integration module
    By sakwoya in forum Addon Payment Modules
    Replies: 319
    Last Post: 23 Apr 2024, 01:05 PM
  2. v154 Whoops! Your session has expired. Just upgraded to 1.5.4 from 1.3.9. Stripe payment m
    By SHtj in forum Built-in Shipping and Payment Modules
    Replies: 6
    Last Post: 20 Aug 2015, 04:00 PM
  3. v151 can the taxcloud addon be tested within local wamp development server??
    By tlyczko in forum Currencies & Sales Taxes, VAT, GST, etc.
    Replies: 2
    Last Post: 4 Dec 2012, 08:37 PM
  4. New Development!
    By impact in forum Installing on a Windows Server
    Replies: 2
    Last Post: 27 May 2010, 09:44 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR