React JS : CCAvenue Payment Integration - javascript

I want to integrate CC Avenue Payment gateway in my React JS Application.
When I click on Payment button, it should open CC Avenue payment window to make payment and after successful of payment , I want to get its response and redirect to thankyou page.
Below is the code i have tried.
I have installed Node CCAvenue plugin.
const nodeCCAvenue = require('node-ccavenue');
const ccav = new nodeCCAvenue.Configure({
merchant_id: XXXXXXX,
working_key: XXXXXXXXXXXXXX,
});
const orderParams = {
order_id: 123456,
currency: 'INR',
amount: '100',
redirect_url: encodeURIComponent(`URL`),
billing_name: 'John Doe',
// etc etc
};
const encryptedOrderData = ccav.getEncryptedOrder(orderParams);
what URL should I put in redirect_url so that it can open Payment window.
Any help would be great.
Thank You.

I'm the author of the node-ccavenue module so I think can answer this.
Don't use the node-ccavenue package on your client side with React. The module uses Node.js' crypto library to encode and decode order information. Additionally, you cannot expose your merchant_id or working_key by putting them in clientside scripts.
Use this in your backend code if your backend is written with Node.js and return the encryptedOrderData to the frontend via an api endpoint

Related

how to i get my vendor(connected account) to the stripe payout page after we onboard them?

how to i direct my vendor to this stripe payout page after I onboard them use the account API?
we are a marketplace with many vendor. i wanted to create a button on the vendor(connected account) page and when they click on the button on our dashboard. it goes to the vendor stripe page but I just cant get the connect account URL for the vendor.
return stripe.accountLinks.create({
type: "account_onboarding",
account: accountID,
refresh_url: `${origin}/`,
return_url: `${origin}/`,
});
example link:
https://connect.stripe.com/express/m7ucEu2cZPbD
Depends on your web server, but you'd just redirect the user when you're ready.
For instance, in express you'd do something like:
const accountLink = await stripe.accountLinks.create({
type: "account_onboarding",
account: accountID,
refresh_url: `${origin}/`,
return_url: `${origin}/`,
});
res.redirect(accountLink.url);
There's more examples with other Node frameworks here: Nodejs - Redirect url

How to integrate Stripe payments with Google Apps Script

According to this answer, Gmail does not expose an API for sending and receiving payments. Therefore, I am trying to use Stripe to accomplish that.
Code.js
// Set your secret key: remember to change this to your live secret key in production
// See your keys here: https://dashboard.stripe.com/account/apikeys
const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');
(async () => {
const product = await stripe.products.create({
name: 'My SaaS Platform',
type: 'service',
});
})();
However, GAS does not directly support async and require at this time. Is there any possible workaround so I can use Stripe to send and receive payments in my GAS app?
If that's not possible, what direction should I go from here?
How about this answer? Please think of this as just one of several answers.
Issue and workaround:
Unfortunately, the module of Node.js cannot be directly used for Google Apps Script. So it is required to prepare the script for Google Apps Script. Fortunately, at the official document of the link in your question, there are several samples. Using this, how about converting to the script of Google Apps Script?
Sample script:
When your script in your question is converted to Google Apps Script, it becomes as follows.
From:
// Set your secret key: remember to change this to your live secret key in production
// See your keys here: https://dashboard.stripe.com/account/apikeys
const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');
(async () => {
const product = await stripe.products.create({
name: 'My SaaS Platform',
type: 'service',
});
})();
To
function myFunction() {
var url = "https://api.stripe.com/v1/products";
var params = {
method: "post",
headers: {Authorization: "Basic " + Utilities.base64Encode("sk_test_4eC39HqLyjWDarjtT1zdp7dc:")},
payload: {name: "My SaaS Platform", type: "service"}
};
var res = UrlFetchApp.fetch(url, params);
Logger.log(res.getContentText())
}
In this case, both requests of Node.js and Google Apps Script are the same.
Note:
At the sample script of Node.js, sk_test_4eC39HqLyjWDarjtT1zdp7dc is used for the key. But in this case, because the basic authorization is used, please use sk_test_4eC39HqLyjWDarjtT1zdp7dc: by adding :.
References:
Billing Quickstart
Class UrlFetchApp
If I misunderstood your question and this was not the direction you want, I apologize.

Paypal Express Checkout - Authorization not appearing in dashboard

I am creating & sending the following payment via the Express checkout API V4:
return paypal.rest.payment.create(env, client, {
intent: 'authorize',
payer: {
"payment_method": "paypal"
},
transactions: [
{
amount: { total: '0.01', currency: 'GBP' }
}
]
});
and I'm returning the following object:
Which all seems to be on the right track. The problem is, there is no sign of this payment auth in the sandbox dashboard.
I've even tried using a live account, and sending a real penny, but there is no sign of the transaction in either the buyer or seller account.
If this payment is not being successfully created, why am I seeing the object returned with a state of "created"?
FYI: If I send a payment using intent: 'sale' it processes successfully and appears in the dashboard.
I had the same problem. API and documentation of PayPal is something awful...
The logic is this:
1. You have to make execute payment.
I tried to do it in different ways, but the easiest way ended up like this:
In the examples on the Paypal site show your complete code with onAuthorize: function(data, actions) , so this function should look like this:
onAuthorize: function(data, actions) {
return actions.payment.get().then(function(payment) {
console.log(payment);
var b = payment.payer;
var bb = b.payer_info;
// alert (bb.payer_id);
var newUrl = "http://YOURDOMAIN.COM/execute.php?paymentId="+payment.id+"&token=EC-"+payment.cart+"&PayerID="+bb.payer_id;
console.log(newUrl);
// go to the execute.php and send to paypal payment confirmation
window.location.replace(newUrl);
});
}
Once you got the object with a transaction you must still confirm it!
Go here https://github.com/paypal/PayPal-PHP-SDK/wiki/Installation download the PHP SDK, it will need to file execute.php to easily confirm the payment and it showed up in the admin panel PayPal. I downloaded the SDK for a direct link, without Composer.
Then in the newly created file execute.php connect this directly SDK without Composer.
// Use below for direct download installation
require __DIR__ . '/PayPal-PHP-SDK/autoload.php';
Then copy the contents of the file itself execute.php and replace it PayPal client ID and client secret. Full code of execute.php here http://pastebin.com/K750qcxE
I couldn't paste here all the code. Citation of code here is terribly implemented, as well as PayPal API :)
p.s. in the script I sent to return url, but I don't know why paypal did not redirect me to it, so I redirect using javascript when you get the transaction object.
sorry for my english

how can I send an IP messaging using twilio-csharp library

I just start create a live chat app with Twilio.
I have downloaded the twilio-csharp library from twilio.com/docs/csharp/install and started with a sample console application.
code example from Twilio:
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio.IpMessaging;
class Example {
static void Main (string[] args) {
// Find your Account Sid and Auth Token at twilio.com/user/account
const string accountSid = "accountSid";
const string authToken = "authToken";
const string serviceSid = "serviceSid";
const string channelSid = "channelSid";
// List all Messages
var client = new IpMessagingClient(accountSid, authToken);
MessageResult result = client.ListMessages(serviceSid, channelSid);
Console.WriteLine(result);
}
}
But this code doesn't work in my case, I got always an errors "type or namespace could not be found".
I have these like reference:
I tried tutorial of IP Messaging , it works. But in the tutorial, they used Javascript SDK to initialize the IP messaging client
tc.accessManager = new Twilio.AccessManager(tokenResponse.token);
tc.messagingClient = new Twilio.IPMessaging.Client(tc.accessManager);
So I just don't understand how can I use this C# library to send an IP Messaging, or maybe I can just control my IP Messaging applications from the client side?
I unstand why I got this error.
I just follow the steps of installation on twilio-csharp library gitHub. But this project's README is only for SMS project. If we want to use Library for IpMessaging, we must also import another Library, Twilio.IpMessaging.
So What I got know like reference and the project IP Messaging works.
Hope this will help the others.

Braintree in Sandbox with Javascript SDK tokenizeCard return "Unable to tokenize card."

I am using Nodejs + javascript SDK, in which I am creating a new customer using predefined customer ID, which is working fine.
Now, using the same customer Id, I am generating a token at the backend and send it to the client. Now at client I am running .
var card = {
number: '4111111111111111',
cvv: '832',
expirationMonth: '10',
expirationYear: '2020',
cardholderName: 'Ankur Agarwal',
billingAddress: {
postalCode: '560076'
},
};
var client = new braintree.api.Client({clientToken: clientToken});
client.tokenizeCard(card, function (err, nonce) {
// Got Error "Unable to tokenize card"
})
Here is the http response it originally got from the server.
/**/callback_json1({"error":{"message":"User does not have the required permissions for this action"},"fieldErrors":[],"status":403})
I have enabled the API access for the account in the sandbox
There are some extra parameters which are not in docs, due to which its givng such a response. Once I removed the extra parameters from the request, its working fine.
I encountered similar error and it was caused by invalid client token. I was passing MerchantId instead of MerchantAccountId as a parameter.
Gateway.ClientToken.generate(new ClientTokenRequest()
{
MerchantAccountId = "Your MerchantAccountId" // NOT MerchantId
});
To manage your merchant accounts login to your Braintree control panel, go to Settings -> Processing and scroll down to Merchant Accounts

Categories

Resources