Skip to content
This repository has been archived by the owner on Feb 24, 2021. It is now read-only.

paytm is not defined #44

Open
Rakhi-Pramanik opened this issue Jun 23, 2020 · 1 comment
Open

paytm is not defined #44

Rakhi-Pramanik opened this issue Jun 23, 2020 · 1 comment

Comments

@Rakhi-Pramanik
Copy link

im following ReadMe from here https://github.com/ArunYogi/paytm-cordova-plugin

as u ask to declare "declare var paytm: any;" in the .ts file where we are initiating the transaction.
im getting ReferenceError: paytm is not defined error

can you please suggest me, so i can deal with it.
Thank you

@remorr25
Copy link

remorr25 commented Jul 6, 2020

@Rakhi-Pramanik please look code below

declare var paytm: any;

@Component({
  selector: "app-home",
  templateUrl: "home.page.html",
  styleUrls: ["home.page.scss"]
})
export class HomePage {
  base_url =
    "http://DOMAIN.COM/paytm/paytmChecksum/generateChecksum.php";
   constructor(private http: HttpClient) {
  }

  txnRequest() {
    let txn = {
      MID: "PAYTM_MID", // PayTM Credentials
      //ORDER_ID: "ORDER0000000001", //Should be unique for every order.
      CUST_ID: "CUST0001",
      INDUSTRY_TYPE_ID: "Retail", // PayTM Credentials
      CHANNEL_ID: "WAP", // PayTM Credentials
      TXN_AMOUNT: "10", // Transaction Amount should be a String
      WEBSITE: "APPSTAGING" // PayTM Credentials
    };
     
     this.http.post(this.base_url, txn).subscribe((response: any) => {
       console.log("API -" + JSON.stringify(response));
       paytm.startPayment(response, this.successCallback, this.failureCallback);
     });
   
  }

   successCallback(response) {
      console.log("gateway response", JSON.stringify(response));
     if (response.STATUS == "TXN_SUCCESS") {
        
      var txn_id = response.TXNID;
      var paymentmode = response.PAYMENTMODE;
      console.log("txn_id => ", txn_id);
      alert("txn_id => " + txn_id);
    } else {
      alert("Transaction Failed for reason " + response.RESPMSG);
    }
  }

  failureCallback(error) {

    alert("Transaction Failed for reason " + error.RESPMSG);
  }
   

}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants