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

SETUP REST API IN CI

1. Create Rest_controller.php inside controllers and paste code: <?php defined('BASEPATH') OR exit('No direct script access allowed'); require APPPATH . '/libraries/API_Controller.php'; class Rest_controller extends API_Controller { public function __construct() { parent::__construct(); } public function index() { $this->api_return(             [ 'status' => true,                'result' => "Welcome to Testservices."             ],         200); } } ?> 2. Create api.php inside config and paste code : <?php defined('BASEPATH') OR exit('No direct script access allowed'); /**  * API Key Header Name  */ $config['api_key_header_name'] = 'X-API-KEY'; /**  * API Key GET Request Parameter Name  */ $config['api_key_get_name'] = 'key'; /**  * API Key POST Request Parameter Name ...

Array Difference, Radio Button Js,

$a1=array("a"=>"red","b"=>"green","c"=>"blue","d"=>"yellow"); $a2=array("e"=>"red","f"=>"green","g"=>"blue"); $result=array_diff($a1,$a2); print_r($result); ______________________________________________________ <script type="text/javascript">  $(document).ready(function(){       $("input[type='radio']").click(function(){             var radioValue = $("input[name='duration']:checked").val();             if(radioValue){                 alert("Your are a - " + radioValue);             }         });  }); </script>   $(document).on("click", ".upappdesc", function(){ // alert($(this).data('id'));  var option = $(this).data("cat").split(",");  // alert($(this).data(...

KrutiDev To Unicode Conversion

http://wrd.bih.nic.in/font_KtoU.htm ___________________________________ <html> <head> <title>KrutiDev <=> Unicode Conversion</title> </title> <link rel="stylesheet" href="style.css">       <script src='script.js'></script> </head> <!--       body of the HTML starts here. one text box is provided each for input and output. --> <body bgcolor='#99CCFF'> <P style='text-align:center; font-family: Arial, Helvetica, sans-serif; font-size: 14pt; font-weight:bold; background-color: #FF6600; color: #FFFFFF'> Conversion between Krutidev-010 and Unicode क्रुतिदेव-०१० और यूनिकोड के बीच रूपांतरण </P> <form name="form1"> <p style='font-size:10pt'>क्रुतिदेव-०१० (Kruti Dev 010) फॉन्ट में टंकिट टेक्स्ट को "क्रुतिदेव-०१०" नामक टेक्स्ट बॉक्स में टाईप या पेस्ट करें तथा इसे यूनिकोड में रूपांतरित करने के लिए अधोमुख तीर वाल...