I am trying to integrate the razorPay payment gateway.
payNow( ) {
var options = {
"key": "rzp_test_dveDexCQKoGszl",
"amount":((this.buyNow==1)?this.shared.totalAmountWithDisocuntBuyNow:this.shared.totalAmountWithDisocunt)*100, // 2000 paise = INR 20
"name": " MARKET",
"description": "Order #",
"handler": function (response){
console.log(response);
alert(response.razorpay_payment_id);
this.paid();
this.shared.addOrder(this.buyNow,response.razorpay_payment_id);
},
"prefill": {
"name": this.shared.orderDetails.billing_firstname + " " + this.shared.orderDetails.billing_lastname,
"email": this.shared.customerData.customers_email_address,
"contact": this.shared.customerData.customers_telephone,
},
"notes": {
"address": this.shared.orderDetails.billing_street_address+', '+this.shared.orderDetails.billing_city+', '+this.shared.orderDetails.billing_state+' '+this.shared.orderDetails.billing_postcode+', '+this.shared.orderDetails.billing_country
},
"theme": {
"color": "blue"
}
};
var rzp1 = new Razorpay(options);
rzp1.open();
// body...
}
paid()
{alert();}
I have defined in handler the callback function. But issue is it successfully logs the response and alerts it too but it does not calls
this.paid()
or
this.shared.addOrder(this.buyNow,response.razorpay_payment_id);
There are no console errors nothing. It just does not calls any of above methioned functions.
Call the handler function by binding it to function using following syntax
"handler":this.shared.addOrder.bind(this,this.buyNow) ,
This worked.
Related
I am trying to integrate the Razorpay payment gateway.
The payment process was a success but I don't get razorpay_order_id in response
This is my code
Pay
<script>
var options = {
"key": "YOUR_KEY_ID", // Your Key
"amount": "50000", // Amount is in currency subunits, in Paise
"currency": "INR",
"name": "Acme Corp",
"description": "Test Transaction",
"image": "https://example.com/your_logo",
"razorpay_order_id": "order_9A33XWu170gUtm", //This is a sample Order ID. Pass the `id` obtained in the response of Step 1
"handler": function (response){
alert(response.razorpay_payment_id);
alert(response.razorpay_order_id);
},
"prefill": {
"name": "Gaurav Kumar",
"email": "gaurav.kumar#example.com",
"contact": "9999999999"
},
"notes": {
"address": "Razorpay Corporate Office"
},
"theme": {
"color": "#F37254"
}
};
var rzp1 = new Razorpay(options);
document.getElementById('rzp-button1').onclick = function(e){
rzp1.open();
e.preventDefault();
}
1: Say, user selected a product and order is placed in cart with order_id="user_order_id".
2: Before making payment, first create "razor_order_id" in your database table corresponds to your product order_id=user_order_id.
3: $a = new Api(env('RAZOR_KEY'), env('RAZOR_SECRET'));
$order = $a->order->create(['receipt' => user_order_id,
'amount'=> $cart['total_amount']*100, 'currency'=> 'INR']);
$razor_order_id = $order->id;
$razor_order_status = $order->status;
DB::table('orders')->where('order_id',$user_order_id)->update(['razor_order_id' => $razor_order_id,'razor_order_status'=>$razor_order_status]);
Session::put('razor_order_id',$razor_order_id);
4: now pass your session variable '$razor_order_id'as values to your key "razorpay_order_id" in $options.
5: now run your above script and you will receive 'razorpay_order_id' in response.
I'm trying to run SignalR Service using azure functions with nodeJS to be able send messages to react. doc
Actually I just want to set up backend services ( SignalR + send messages functions ) locally.
For that I have created SignalR function:
module.exports = async function (context, req, connectionInfo) {
console.log(connectionInfo)
context.res.body = connectionInfo;
};
in function.json
{
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "request",
"methods": [
"get",
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "res"
},
{
"type": "signalR",
"name": "signalRMessages",
"connectionStringSetting": "Endpoint=https://xxxx.service.signalr.net;AccessKey=XXXXXXx;Version=1.0;",
"hubName": "XXXXX",
"direction": "out"
}
]
}
Then in my second function which will send messages to SignalR service:
module.exports = async function (context, req) {
context.log('JavaScript HTTP trigger function processed a request.');
const name = (req.query.name || (req.body && req.body.name));
const responseMessage = name
? "Hello, " + name + ". This HTTP triggered function executed successfully."
: "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.";
const updates = [{
target: 'updated',
arguments: [responseMessage]
}];
context.bindings.signalRMessages = updates;
context.done();
}
in function.json
{
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"get",
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "res"
},
{
"type": "signalRConnectionInfo",
"name": "connectionInfo",
"hubName": "xxxxxx", <== here I putted the SignalR service name without the domaine
"direction": "in",
"connectionStringSetting": "Endpoint=https://XXXXX.service.signalr.net;AccessKey=XXXXXX;Version=1.0;"
}
]
}
Then I local.setting.json
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "node",
"AzureSignalRConnectionString": "Endpoint=https://xxxxxx.service.signalr.net;AccessKey=xxxxxxxxx;Version=1.0;"
},
"Host": {
"LocalHttpPort": 7072,
"CORS": "*"
}
}
I have also set service mode to serverless in SignalR Service setting.
Now I'm trying to test that by running the sendmessages function in the browser which should trigger the signalR function
But when I run the sendMessages function on browser the SignalR Serice function is not triggered and context.bindings contains only req( no res and sendMessages listed in function.json)
Am I missing something in my configuration ?
ive been using razor pays normal checkout feature
<script type="text/javascript">
var options = {
"key": "rzp_****_*********",
"amount": 10000,
"currency": "INR",
"name": "XYZ",
"description": "Payment For Appointment at XYZ Limited",
"image": "https://XYZ.in/public/theme/images/re-logo.png",
"handler": function (response) {
var payid = response.razorpay_payment_id;
$('#transaction_id').val(payid);
$('#paymentform').submit();
},
"prefill": {
"name": "Name",
"email": "Email"
},
"notes": {
"address": "note value"
},
"theme": {
"color": "#F37254"
}
};
var rzp1 = new Razorpay(options);
document.getElementById('payonlinebutton').onclick = function (e) {
rzp1.open();
e.preventDefault();
}
</script>
But i want to use route payments now, and on razorpay's document they have only sample code for curl
Can anyone help me with php solution if there is any.
i got his document but the concept is not that clear
https://razorpay.com/docs/server-integration/php/usage/#route
Install PHP SDK https://razorpay.com/docs/server-integration/php/ and call the function as per need
I am New to Integrate Payment Gateway.
How to Redirect a URL after Success or Failure Payments in Razorpay. I want Js Code. I thing handler function can use that redirect. How to Use them
var options = {
"key": "rzp_test_aIfnpuWEudWnID",
"amount": "35000", // 2000 paise = INR 20
"name": "Vanakkam Chennai",
"description": "I Run.. Becasue .. I Care",
"image": "http://vanakkamchennai.com/images/about/chennai_2017.jpg",
"callback_url": 'https://www.google.com',
"handler": function (response){
alert(response.razorpay_payment_id);
},
"prefill": {
"name": "Harshil Mathur",
"email": "harshil#razorpay.com"
},
"notes": {
"address": "Hello World"
},
"theme": {
"color": "#F37254"
}
};
The way to redirect a user is to alter the value of location.href. Remove alert(response.razorpay_payment_id); and redirect the user based on if the payment id is defined or not:
// alert(response.razorpay_payment_id);
if (typeof response.razorpay_payment_id == 'undefined' || response.razorpay_payment_id < 1) {
redirect_url = '/you-owe-money.html';
} else {
redirect_url = '/thnx-you-paid.html';
}
location.href = redirect_url;
My example urls are humorous; replace them with your actual urls. Also, you can read more detailed information on location.href and location redirection here.
I'm doing some screen scraping with phantomjs. I'm trying to implement an error handling system that sends an email with the mandrill api https://mandrillapp.com/api/docs/messages.html when the scraper fails.
The mandrill api takes a post method like the one below.
How would you send a mail through mandrill with phantomjs?
var data = {
"key": "VdFwNvj-dLwaI6caAh8ODg",
"message": {
"html": "This aggression will not stand",
"text": "This aggression will not stand",
"subject": "example subject",
"from_email": "the-dude#gmail.com",
"from_name": "The Dude",
"to": [{
"email": "lebowski#gmail.com",
"name": "lebowski"
}]
},
"async": false
};
$.ajax({
type: "POST",
url: 'https://mandrillapp.com/api/1.0/messages/send.json',
data: data
});
I spent some time trying to get the answer working with no joy. I ended up testing with: http://httpbin.org/post to find out why mandril was failing to handle my requests and it turned out that the data wasn't being sent properly. The PhantomJS docs weren't correct either. It was this example: https://github.com/adrianchung/phantomjs/blob/069ab5dea4c07c61a0ac259df0ff219ade1e8225/examples/postjson.js that ended up giving me the missing piece. The mandrill docs were also very useful: https://mandrillapp.com/api/docs/messages.JSON.html
My completed code:
var page = require('webpage').create();
var email_url = 'https://mandrillapp.com/api/1.0/messages/send.json';
//email_url = 'http://httpbin.org/post'; // When testing
var email_data = {
key: "your-key",
"message": {
"text": email_message_text,
"subject": "Your subject",
"from_email": "your email",
"from_name": "Kris",
"to": [{
"email": "your email",
"name": "Kris"
}]
},
"async": false
};
var email_headers = {
"Content-Type": "application/json"
};
page.open(
email_url,
'post',
JSON.stringify(email_data), // You need to stringify the json or it doesn't work
email_headers,
function (status) {
if (status !== 'success') {
PrintError('FAIL to email results');
} else {
var result = page.evaluate(function () {
return document.body.innerText;
});
Print('Email successfully sent\n' + result);
}
phantom.exit();
}
);
The easiest way is to spin up a new page to make a RESTful call, then you can use page.evaluate to read the result. While it is not as simple as the jQuery ajax method, you could easily create object to simplify its use.
var page = require('webpage').create(),
url = 'https://mandrillapp.com/api/1.0/messages/send.json',
data = {
"key": "VdFwNvj-dLwaI6caAh8ODg",
"message": {
"html": "This aggression will not stand",
"text": "This aggression will not stand",
"subject": "example subject",
"from_email": "the-dude#gmail.com",
"from_name": "The Dude",
"to": [{
"email": "lebowski#gmail.com",
"name": "lebowski"
}]
},
"async": false
};
page.open(url, 'POST', data, function (status) {
if (status !== 'success') {
console.log('FAIL to load the log');
} else {
console.log('Log success');
var result = page.evaluate(function () {
return document.body.innerText;
});
console.log("log Result: " + result);
}
});