Skip to main content

Stripe

########### PAYMENT GATEWAY TYPES ###########
Sites in test mode connect to “Sandbox” gateways. ...
Sites in production mode connect to “Live” gateways.

__________________________________________________


https://stackoverflow.com/questions/25546372/stripe-payment-gateway-i-wants-to-use-amount-in-decimal-format
https://stripe.com/docs/recipes/variable-amount-checkout

__________________________________________________

{"id":"card_1E3MaZL09KjGnQBSE9GRBAXI","object":"card","address_city":null,"address_country":null,"address_line1":null,"address_line1_check":null,"address_line2":null,"address_state":null,"address_zip":null,"address_zip_check":null,"brand":"Visa","country":"US","customer":"cus_EWPPANFUwvgE6Y","cvc_check":"pass","dynamic_last4":null,"exp_month":3,"exp_year":2021,"fingerprint":"sLxubtQ4jOOqHpQj","funding":"credit","last4":"4242","metadata":[],"name":null,"tokenization_method":null}
_____________________________________________________
***** testservice.php ******
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Testservice extends CI_Controller {

public function __construct($config = 'rest')
{
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE");
parent::__construct();
}
  public function signup(){   
   
$email = (trim($this->input->get('email')));
$password = md5($this->input->get('password'));
$contact = (trim($this->input->get('contact')));
$username = (trim($this->input->get('username')));
$token = (trim($this->input->get('stripeToken')));
$role = 'user';

        // Create USER on Stripe
        require_once('stripe_payment_gateway/stripe-php/init.php');
       
        $keys = $this->user_model->get_joins('admin_stripe');
   
        //   $stripe = array(
        //     "secret_key"      => "$keys[0]['secretkey']",
        //     "publishable_key" => "$keys[0]['publishablekey']"
        //   );
       
          $stripe = array(
        "secret_key"      => "sk_test_bBcx24ld9rsUmP5kd1nNUS43",
        "publishable_key" => "pk_test_6C2zhCPDkgYTCvlU96n2WcIw"
      );
       
       
       
        \Stripe\Stripe::setApiKey($stripe['secret_key']);
   
        // Create a Customer:
        $customer = \Stripe\Customer::create([
            'source' => $token,
            'email' => $email,
        ]);


$insertdata = array(
'email' => $email,
'password' => $password,
'contact' => $contact,
'username' => $username,
'role'=>$role,
'date' => date('Y-m-d h:i:s'),
'stripecustomerid' => $customer->id
);

print_r($insertdata);
} 
   
}
?>
***** Create User.php **********
<html>
  <head>
    <title> Create Stripe User </title>

  </head>
  <body>
    <h5> Card details </h5> 
<span class="payment-errors text-danger"></span>
   <form id="paymentFrm" action="http://api.hairstylist.betaplanets.com/testservice/signup" method="get" > 
    <input type="text" name="email" autocomplete="off" placeholder="email" >
    <input type="text" name="username" autocomplete="off"  placeholder="username" >   
      <!-- <strong>Card Number : </strong> -->
      <input type="text" name="card_num" autocomplete="off" class="card-number" size="15" placeholder="card_num" >       
      <!-- <strong>CVC : </strong> -->
      <input placeholder="cvc" type="text" name="cvc" autocomplete="off" class="card-cvc" size="3">
      <!-- <strong>Expiration (MM/YYYY) : </strong> -->
      <input placeholder="exp_month" type="month" name="exp_month" size="2" class="card-expiry-month"/>
      <input placeholder="exp_year"  type="year" name="exp_year" size="4" class="card-expiry-year"/> 
    <button type="submit" id="payBtn" class="btn btn-primary btn-sm"> Submit Payment </button>
    </form>             

    <!-- Stripe JavaScript library -->
  <script type="text/javascript" src="https://js.stripe.com/v2/"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script type="text/javascript">
        //set your publishable key
        Stripe.setPublishableKey('pk_test_6C2zhCPDkgYTCvlU96n2WcIw');
        //callback to handle the response from stripe
        function stripeResponseHandler(status, response) {
            if (response.error) {
                //enable the submit button
                $('#payBtn').removeAttr("disabled");
                //display the errors on the form
                $(".payment-errors").html(response.error.message);
            } else {
                var form$ = $("#paymentFrm");
                //get token id
                var token = response['id'];
                //insert the token into the form
                form$.append("<input type='hidden' name='stripeToken' value='" + token + "' />");
                //submit form to the server
                form$.get(0).submit();
            }
        }
        $(document).ready(function() {
            //on form submit
            $("#paymentFrm").submit(function(event) {
                //disable the submit button to prevent repeated clicks
                $('#payBtn').attr("disabled", "disabled");
               
                //create single-use token to charge the user
                Stripe.createToken({
                    number: $('.card-number').val(),
                    cvc: $('.card-cvc').val(),
                    exp_month: $('.card-expiry-month').val(),
                    exp_year: $('.card-expiry-year').val()
                }, stripeResponseHandler);
               
                //submit from callback
                return false;
            });
        });
  </script>
  </body>

</html>
___________________________________________________________________________
## USER APP SIGNUP
public function signup(){
$email = (trim($this->input->get('email')));
$password = md5($this->input->get('password'));
$contact = (trim($this->input->get('contact')));
$username = (trim($this->input->get('username')));
$token = (trim($this->input->get('stripeToken')));
$role = 'user';

// Create USER on Stripe
        require_once('stripe_payment_gateway/stripe-php/init.php');
       
        $keys = $this->user_model->get_joins('admin_stripe');
   
          $stripe = array(
            "secret_key"      => "$keys[0]['secretkey']",
            "publishable_key" => "$keys[0]['publishablekey']"
          );


  //     $stripe = array(
    //     "secret_key"      => "sk_test_bBcx24ld9rsUmP5kd1nNUS43",
    //     "publishable_key" => "pk_test_6C2zhCPDkgYTCvlU96n2WcIw"
    //   );
       



        \Stripe\Stripe::setApiKey($stripe['secret_key']);
   
        // Create a Customer:
        $customer = \Stripe\Customer::create([
            'source' => $token,
            'email' => $email,
        ]);
$insertdata = array(
'email' => $email,
'password' => $password,
'contact' => $contact,
'username' => $username,
'role'=>$role,
'date' => date('Y-m-d h:i:s'),
'stripecustomerid' => $customer->id
);

$where_contact = array(
'contact' => $contact,
'username' => $username
);
$user_contact = ($this->user_model->get_joins('user', '','','','','','','','',$where_contact));
if (!empty($user_contact)){
echo "User & Contact is already registered";
}else{
$is_insert = $this->user_model->INSERTDATA('user', $insertdata);
if ($is_insert){
echo "true";
}else{
echo "Registration Failed";
}
}
}




Comments

Popular posts from this blog

SQL

****** Count "yes" or "no" ************** SELECT COUNT(case when decision="yes" THEN decision end )as yes, COUNT(case when decision="no" THEN decision end )as no, COUNT(case when decision="unsure" THEN decision end ) as unsure,COUNT(decision) FROM `election` WHERE `dispute_id` = '2' _____________________________________________ SELECT MAX(`date`) FROM stylist_payment WHERE `stylitid` ='390' > SELECT MAX(`date`) FROM stylist_payment GROUP BY `stylitid` > SELECT `stylist_payment`.`stylitid`, `stylitamount`, `percentage`, `si_amount`, `stylist_payment`.`date` FROM `stylist_payment` LEFT JOIN `booking` ON `booking`.`stylitid` = `stylist_payment`.`stylitid`GROUP BY `stylitid` SELECT MAX(`stylist_payment`.`date`) FROM stylist_payment LEFT JOIN `user` ON `user`.`id` = `stylist_payment`.`stylitid` GROUP BY `stylitid` SELECT stylitid,total_amount,user.username,user.firstname,user.lastname,user.contact,user.ema...

NGrok Setup

 https://dashboard.ngrok.com/get-started/setup 1. Unzip to install On Linux or Mac OS X you can unzip ngrok from a terminal with the following command. On Windows, just double click ngrok.zip to extract it. unzip /path/to/ngrok.zip 2. Connect your account Running this command will add your authtoken to the default ngrok.yml configuration file. This will grant you access to more features and longer session times. Running tunnels will be listed on the endpoints page of the dashboard. ngrok config add-authtoken 1woFn9zVqcI4VeGuSIiN2VtmnPa_ZXuAuF1AAPkqApr7WVsQ 3. Fire it up Read the documentation on how to use ngrok. Try it out by running it from the command line: ngrok help To start a HTTP tunnel forwarding to your local port 80, run this next: ngrok http 80

Update Node on Mac and Windows

Using brew: brew update brew upgrade node Using nvm:   NVM (Node Version Manager) is a tool that allows you to manage multiple versions of Node on your system. You can use nvm to install, update, and switch between different versions of Node. To update your version of Node using nvm, do the following: 1. Check if you already have nvm installed on your system:   
nvm --version 2. If it's not installed, install nvm using this command:    
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash 3. Once nvm is installed, check your current version of Node by running the following command: 
node -v 4. Then update your version of Node using the following command:   
nvm install node --reinstall-packages-from=node 5. And finally, verify that your update is complete by rechecking your Node version:   
node -v ———————————————————————————————————— Using NPM: To update Node using NPM, do the following: 1. Open the Terminal and check your curren...