-1

I'm integrating CC avenue in Ionic4 app with Node JS as my backend. Node JS API is whitelisted with CC avenue as this is the first most step in the integration of CC Avenue. I've methods for fetching the RSA key in the API. I'm not able to figure out how to post the encrypted params and open it in the New browser window with Redirect and Cancel URLs.

  initPayment() {
    this.authService.initPayment().then(
      res => {
        this.paymentParams = new PaymentParams();
        this.paymentParams.orderId = JSON.parse(res).order_id;
        this.paymentParams.amount = JSON.parse(res).amount;
        this.paymentParams.currency = JSON.parse(res).currency;
        this.paymentParams.merchantId = JSON.parse(res).merchant_id;
        this.paymentParams.accessCode = JSON.parse(res).access_code;
        this.paymentParams.cancelUrl = JSON.parse(res).redirect_url;
        this.paymentParams.redirectUrl = JSON.parse(res).cancel_url;
        this.paymentParams.transUrl = JSON.parse(res).trans_url;
        this.paymentParams.rsaKeyURL = JSON.parse(res).rsa_key_uRL;
        alert(JSON.stringify(this.paymentParams));
        this.getRSA(this.paymentParams.orderId); // Gets the RSA key from CC Avenue
        const payLink = this.inappBrowser.create(`${this.paymentParams.transUrl}`); // Here I want toadd the encryption for posting into Webview
      },
      err => {
        alert(JSON.parse(err));
      }
    );
  }

Below is the RSA utility provided by CC avenue written in Java. I'm trying to get the similar encryption using typescript in Ionic4.

public class RSAUtility {
    public static String encrypt(String plainText, String key){
        try{
            PublicKey publicKey = KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(Base64.decode(key, Base64.DEFAULT)));
            Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
            cipher.init(Cipher.ENCRYPT_MODE, publicKey);
            return Base64.encodeToString(cipher.doFinal(plainText.getBytes("UTF-8")),Base64.DEFAULT);
        }catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
halfer
  • 19,824
  • 17
  • 99
  • 186
  • This feels rather too broad for a Stack Overflow question. Have you identified the portion of the CC Avenue documentation that is relevant to your requirement? If so, have you tried implementing that? What problem did you run into? If the above _is_ an attempt at solving the problem, what happens when you run it? – halfer Aug 26 '19 at 21:42
  • Hi @halfer, CC Avenue provide integration kits for Android & IOS separately. As I'm trying to implement in Ionic, I can't make use of them. With the reference of [link](https://stackoverflow.com/questions/39738996/how-to-integrate-ccavenue-to-ionic-app), I'm trying to implement the same but not sure how to proceed with the https://secure.ccavenue.com/transaction/initTrans in the In-App Browser implementation along with encryption & after encryption of parameters. – Shaik Mohammed Ghouse Aug 27 '19 at 05:28

0 Answers0