Wednesday 24 August 2016

Braintree payment with Paypal OR Credit card - Easy Payment


Braintree Payment Form

Braintree Payment Form


Pay with Credit Card

Pay with Credit Card


Pay with Paypal

Pay with Paypal


<div>
<form action="/payment.php" id="checkout" method="post">
<div id="payment-form">
</div>
<input type="submit" value="Pay $10" />
    </form>
</div>
<script src="https://js.braintreegateway.com/js/braintree-2.27.0.min.js"></script>
<script>
    var clientToken = "eyJ2ZXJzaW9uIjoyLCJhdXRob3JpemF0aW9uRmluZ2VycHJpbnQiOiJlZDMyNDY2YmY3NjEyODAxZTk1YmVkMzYyY2Y2NzQ5OThjZWJlZGU2OTgzMDI4MzY3NmJmOTZhNDI0NzI1YTJkfGNyZWF0ZWRfYXQ9MjAxNi0wOC0yNFQwNjowNzo1NS43MTUzNDUyNDIrMDAwMFx1MDAyNm1lcmNoYW50X2lkPTM0OHBrOWNnZjNiZ3l3MmJcdTAwMjZwdWJsaWNfa2V5PTJuMjQ3ZHY4OWJxOXZtcHIiLCJjb25maWdVcmwiOiJodHRwczovL2FwaS5zYW5kYm94LmJyYWludHJlZWdhdGV3YXkuY29tOjQ0My9tZXJjaGFudHMvMzQ4cGs5Y2dmM2JneXcyYi9jbGllbnRfYXBpL3YxL2NvbmZpZ3VyYXRpb24iLCJjaGFsbGVuZ2VzIjpbXSwiZW52aXJvbm1lbnQiOiJzYW5kYm94IiwiY2xpZW50QXBpVXJsIjoiaHR0cHM6Ly9hcGkuc2FuZGJveC5icmFpbnRyZWVnYXRld2F5LmNvbTo0NDMvbWVyY2hhbnRzLzM0OHBrOWNnZjNiZ3l3MmIvY2xpZW50X2FwaSIsImFzc2V0c1VybCI6Imh0dHBzOi8vYXNzZXRzLmJyYWludHJlZWdhdGV3YXkuY29tIiwiYXV0aFVybCI6Imh0dHBzOi8vYXV0aC52ZW5tby5zYW5kYm94LmJyYWludHJlZWdhdGV3YXkuY29tIiwiYW5hbHl0aWNzIjp7InVybCI6Imh0dHBzOi8vY2xpZW50LWFuYWx5dGljcy5zYW5kYm94LmJyYWludHJlZWdhdGV3YXkuY29tLzM0OHBrOWNnZjNiZ3l3MmIifSwidGhyZWVEU2VjdXJlRW5hYmxlZCI6dHJ1ZSwicGF5cGFsRW5hYmxlZCI6dHJ1ZSwicGF5cGFsIjp7ImRpc3BsYXlOYW1lIjoiQWNtZSBXaWRnZXRzLCBMdGQuIChTYW5kYm94KSIsImNsaWVudElkIjpudWxsLCJwcml2YWN5VXJsIjoiaHR0cDovL2V4YW1wbGUuY29tL3BwIiwidXNlckFncmVlbWVudFVybCI6Imh0dHA6Ly9leGFtcGxlLmNvbS90b3MiLCJiYXNlVXJsIjoiaHR0cHM6Ly9hc3NldHMuYnJhaW50cmVlZ2F0ZXdheS5jb20iLCJhc3NldHNVcmwiOiJodHRwczovL2NoZWNrb3V0LnBheXBhbC5jb20iLCJkaXJlY3RCYXNlVXJsIjpudWxsLCJhbGxvd0h0dHAiOnRydWUsImVudmlyb25tZW50Tm9OZXR3b3JrIjp0cnVlLCJlbnZpcm9ubWVudCI6Im9mZmxpbmUiLCJ1bnZldHRlZE1lcmNoYW50IjpmYWxzZSwiYnJhaW50cmVlQ2xpZW50SWQiOiJtYXN0ZXJjbGllbnQzIiwiYmlsbGluZ0FncmVlbWVudHNFbmFibGVkIjp0cnVlLCJtZXJjaGFudEFjY291bnRJZCI6ImFjbWV3aWRnZXRzbHRkc2FuZGJveCIsImN1cnJlbmN5SXNvQ29kZSI6IlVTRCJ9LCJjb2luYmFzZUVuYWJsZWQiOmZhbHNlLCJtZXJjaGFudElkIjoiMzQ4cGs5Y2dmM2JneXcyYiIsInZlbm1vIjoib2ZmIn0";

    braintree.setup(clientToken, "dropin", {
        container: "payment-form"
    });
</script>


Demo



After Successfully payment with Credit Card OR Paypal, Server will an Get Response similar to below.
Array
(
    [payment_method_nonce] => e91cdbff-d914-485f-817a-51f473b18445
)
This token is known as payment nonce. You can use this nonce once and can be used to get the payment from user account.
$paymentNonce=$POST[payment_method_nonce];//this is nonce
$result = Braintree_Transaction::sale([
  'amount' => '10.00',
  'paymentMethodNonce' => $paymentNonce,
  'options' => [
    'submitForSettlement' => True
  ]
]);

Monday 22 August 2016

MongoDb Technical Interview Questions and Answers

MongoDb Technical Interview Questions and Answers

Question: What is MongoDb in technical terms?
MongoDb is No-SQL database. MongoDb is document oriented means store data in JSON Format called BSON. Designed with High Scalability.


Question: What is Replication?
Replication is the process of synchronizing data across multiple servers. It provides redundancy and increases data availability with multiple copies of data on different database servers.


Question: What are benefits of Replication?
  1. (24*7) availability of data
  2. Disaster Recovery
  3. No downtime for maintenance
Question: What is data warehouse?
A data warehouse is a relational database that is designed for query and analysis rather than for processing. It usually contains historical data derived from transaction data. It separates analysis workload from transaction workload and enables an organization to consolidate data from several sources.


Question: What is auto sharding in MongoDB?
Sharding is a method for distributing data across multiple machines. MongoDB uses sharding to support deployments with very large data sets and high throughput operations.


Question: Why sharding used in MongoDB?
  1. In replication all writes go to master node
  2. Latency sensitive queries still go to master
  3. Memory can't be large enough when active dataset is big
  4. Local Disk is not big enough
  5. Vertical scaling is too expensive



Question: What are data type support by MongoDB?
String : This is most commonly used datatype to store the data.
Integer : This type is used to store a numerical value. Integer can be 32 bit or 64 bit depending upon your server.
Boolean : Store a boolean (true/ false) value.
Double : This type is used to store floating values.
Min/ Max keys : This type is used to compare a value against the lowest and highest BSON elements.
Arrays : This type is used to store multiple values into one key.
Timestamp : ctimestamp. This can be handy for recording when a document has been added or modified.
Object : This datatype is used for embedded documents.
Null : This type is used to store a Null value.
Symbol : This datatype is used identically to a string however, it's generally reserved for languages that use a specific symbol type.
Date : This datatype is used to store the current date or time in UNIX time format.
Object ID : This datatype is used to store the document's ID.
Binary data : This datatype is used to store binay data.
Code : This datatype is used to store javascript code into document.
Regular expression : This datatype is used to store regular expression.



Question: How to connect to MongoDb databae through PHP?
$db = new Mongo('mongodb://localhost', array(
    'username' => 'abc',
    'password' => 'abc@123',
    'db'       => 'abc'
));



Question: How to Export database in MongoDb?
mongodump



Question: How to Import database in MongoDb?
mongorestore