<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Kathiravan Ramaswamy on Medium]]></title>
        <description><![CDATA[Stories by Kathiravan Ramaswamy on Medium]]></description>
        <link>https://medium.com/@kathiravan-ramaswamy?source=rss-40d5d612a583------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*8BeX_XPWU0kPdUJcPhngng.jpeg</url>
            <title>Stories by Kathiravan Ramaswamy on Medium</title>
            <link>https://medium.com/@kathiravan-ramaswamy?source=rss-40d5d612a583------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 18:22:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kathiravan-ramaswamy/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Generating Crystal Reports using ASP.NET(4.7.2) Web API]]></title>
            <link>https://kathiravan-ramaswamy.medium.com/generating-crystal-reports-using-asp-net-4-7-2-web-api-4c4755a7eafd?source=rss-40d5d612a583------2</link>
            <guid isPermaLink="false">https://medium.com/p/4c4755a7eafd</guid>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[asp-net-web-api]]></category>
            <category><![CDATA[sap]]></category>
            <dc:creator><![CDATA[Kathiravan Ramaswamy]]></dc:creator>
            <pubDate>Fri, 26 Feb 2021 10:38:10 GMT</pubDate>
            <atom:updated>2021-02-26T10:38:10.835Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello there, welcome to another story, I am glad to publish this story since I struggled to find documentation, To make generating crystal reports using ASP.NET Web follow the Given steps</p><p>Pre-requisites:</p><ol><li>Visual Studio 2019</li><li>ASP.NET SDK(4.6 or higher)</li><li>Crystal Reports Runtime(32 bit or 64 bit)</li></ol><h4>Steps to be followed:</h4><p>Once all the pre-requisites are ready in the machine, Create a new ASP.Net project using Visual Studio 2019 available templates as shown in the below Picture</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pSKjxcssAb3mDqaLrY7JOw.png" /><figcaption>Step-1:Creating a new Project</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MAy0Qx5Sx_8y-vwexXzg2Q.png" /></figure><p>Enter the Project Name and Click Next…</p><p>Once Project is opened in Visual Studio 2019, Go to the Controllers folder and Create a Controller named respective to the report which you are creating</p><pre>[Route(&quot;api/&lt;routename&gt;/{userID}&quot;)]</pre><pre>[HttpGet, HttpPost]//based on the Usecase How the Parameter is passed</pre><pre>[EnableCors(origins: &quot;*&quot;, headers: &quot;*&quot;, methods: &quot;*&quot;)]<br>//to Access across different origins</pre><pre>public HttpResponseMessage Get(string userID)//the type you are using to filter in Report File</pre><pre>{</pre><pre>try</pre><pre>{</pre><pre>//Step -1 Instantiate a object of DataAccesslayer<br>//Step -2 Store the response as per the Type returned in DataAccessLayer<br>//Step -3 Call GetReportContent(Stream stream, string filename, string downloadType, string media)<br>//Step -4 Return HttpResponseMessage OK once the dataaccess returns the result</pre><pre>}</pre><pre>catch(Exception ex)</pre><pre>{</pre><pre>return new HttpResponseMessage(HttpStatusCode.BadRequest);</pre><pre>}</pre><pre>}</pre><p>In DataAccess, Do the following</p><pre>ReportDocument reportDocument = new ReportDocument();<br>reportDocument.Load(HttpContext.Current.Server.MapPath(&quot;~/Reports&quot;), &lt;reportFilename&gt;);<br>ReportFormula = &quot;&lt;SelectionFormula&gt;&quot; + &lt;Parameter From Controller&gt;;                reportDocument.DataSourceConnections[0].SetConnection(//Databse Credentials);<br>reportDocument.RecordSelectionFormula = ReportFormula;<br>Stream stream =reportDocument.ExportToStream(//#exportformattype);<br>stream.Seek(0, SeekOrigin.Begin);<br>return stream;</pre><p>To view or Download, report use the following Function from a common Helper Folder or based on you convenience</p><pre>public HttpResponseMessage GetReportContent(Stream stream, string filename, string downloadType, string media)<br>{<br> try<br> {<br>         var result = new HttpResponseMessage(HttpStatusCode.OK);<br>         result.Content = new StreamContent(stream);<br>         var headers = result.Content.Headers;<br>         headers.ContentDisposition = new ContentDispositionHeaderValue(downloadType);         headers.ContentDisposition.FileName = filename;<br>         headers.ContentType = new MediaTypeHeaderValue(media);<br>         headers.ContentLength = stream.Length;<br>         return result;<br>    }<br>    catch(Exception ex)<br>    {<br>        return new HttpResponseMessage(HttpStatusCode.BadRequest);<br>    }<br>}</pre><p>To download give attachment instead of inline in ‘<strong>downloadType</strong>’ parameter</p><p>Parameters used in GetReportContent Function:</p><ol><li><strong>downloadType = attachment/inline(string)</strong></li><li><strong>Stream</strong> = the reportDocument Loaded in Data Access layer with SelectionFormula(System.IO.Stream)</li><li><strong>filenam</strong>e =if downloadType is an attachment(string)</li><li><strong>media </strong>= ExportFormatType.PortableDocFormat(#exportformattype) or provided in CrystalDecisions.Shared DLL.(string)</li></ol><p>Cheers!! we have done the web API part successfully for the positive scenarios, welcoming the viewers to post the what if the ID and Database connectivity has failed during generating the reports from any FrontEnd Web Application since we have written as REST Service</p><p>Thank you Looking for the response!!!</p><p>Have a great day and Happy Coding:)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c4755a7eafd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basic Validations in Angular Reactive Forms]]></title>
            <link>https://kathiravan-ramaswamy.medium.com/basic-validations-in-angular-reactive-forms-ef13f6c49783?source=rss-40d5d612a583------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef13f6c49783</guid>
            <category><![CDATA[reactive-forms]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Kathiravan Ramaswamy]]></dc:creator>
            <pubDate>Mon, 01 Feb 2021 04:52:13 GMT</pubDate>
            <atom:updated>2021-05-04T06:02:39.011Z</atom:updated>
            <content:encoded><![CDATA[<h3>Angular Reactive Forms</h3><p>Hi everyone out there, in this story I gonna explain how to implement Angular Reactive Forms with validation.</p><p>Let’s dive into what is Reactive forms?</p><p>Reactive Forms in Angular is also known as <strong>Model-Driven</strong> Forms where the forms we design and develop are much reliable than the <strong>Template-Driven</strong> Forms in Angular, Preferably I would suggest Angular Techies can go with Reactive Form rather than the <strong>Template-Driven</strong> Approach</p><p>Difference between Template and Reactive Forms</p><blockquote>Reactive forms differ from <a href="https://angular.io/guide/forms">template-driven forms</a> in distinct ways. Reactive forms provide more predictability with synchronous access to the data model, immutability with observable operators, and change tracking through observable streams.</blockquote><blockquote>Template-driven forms allow direct access to modify data in your template, but are less explicit than reactive forms because they rely on directives embedded in the template, along with mutable data to track changes asynchronously. See the <a href="https://angular.io/guide/forms-overview">Forms Overview</a> for detailed comparisons between the two paradigms.</blockquote><p>Now, Before proceeding to Reactive Forms Let us create an Angular project using the Angular CLI command as below in a specified path you want to:</p><pre>ng new demo-forms</pre><p>Open your Project in your Favourite Editor, where I will use Visual Studio Code since it is user-friendly where It provides a lot of boiler-plates to increase our productivity.</p><p>Once you opened your Angular project in the VSCode, Create a new Component or design a form in the default app.component.html file by removing the existing code as follows, I used Angular Material Here you can use your choice :)</p><p>Before creating a form make sure that we have imported the necessary import has done in the app.module.ts file, Else our form will not render</p><pre>&lt;form novalidate&gt;<br>  &lt;mat-form-field&gt;<br>    &lt;mat-label&gt;Enter your email&lt;/mat-label&gt;<br>    &lt;input matInput placeholder=&quot;Enter Email Address&quot;&gt;<br>  &lt;/mat-form-field&gt;</pre><pre>&lt;mat-form-field&gt;<br>    &lt;mat-label&gt;Enter Password&lt;/mat-label&gt;<br>    &lt;input matInput placeholder=&quot;Enter Password&quot;&gt;<br>  &lt;/mat-form-field&gt;<br>&lt;/form&gt;</pre><pre>&lt;button type=&quot;submit&quot; (click)=&quot;&lt;your submit function in ts file&gt;&quot;&gt;&lt;/button&gt;</pre><p>Here, <strong>novalidate</strong> attribute is used to disable the browser’s native form validation</p><p>You could add your own style to your form as this story is not going to highlight those things</p><p>Now create a FormGroup instance in your app.component.ts</p><pre>loginForm: FormGroup</pre><p>Inject FormBuilder in the constructor</p><pre>constructor(private _fb:FormBuilder){}</pre><p>Now initialize the FormGroup in the ngOnInit lifecycle hook as follows,</p><pre>this.loginForm = this._fb.group({<br>email: new FormControl(),<br>password:new FormControl(),<br>})</pre><p>Now, in app.component.html, modify the form with your formgroup and FormControl</p><pre>&lt;form novalidate [formGroup]=&quot;loginForm&quot;&gt;<br>  &lt;mat-form-field&gt;<br>    &lt;mat-label&gt;Enter your email&lt;/mat-label&gt;<br>    &lt;input matInput placeholder=&quot;Enter Email Address&quot; formControlName=&quot;email&quot;&gt;<br>  &lt;/mat-form-field&gt;</pre><pre>&lt;mat-form-field&gt;<br>    &lt;mat-label&gt;Enter Password&lt;/mat-label&gt;<br>    &lt;input matInput placeholder=&quot;Enter Password&quot; formControlName]=&quot;password&quot;&gt;<br>  &lt;/mat-form-field&gt;<br>&lt;/form&gt;</pre><p>Till now we have not applied validation to the form, let us do in the next step as follows: Modify the loginForm as,</p><pre>this.loginForm = this._fb.group({<br>email: new FormControl(&#39;&#39;, Validators.required),<br>password:new FormControl(&#39;&#39;, Validators.required),<br>})</pre><p>We have applied a basic validation where we required both values to proceed, In order to trigger the validation we need getter as follows,</p><pre>get f(){<br>   return this.loginForm.controls;<br>}</pre><p>To display error controls while submitting, include the mat-error element in mat-form-field</p><pre>&lt;form novalidate [formGroup]=&quot;loginForm&quot;&gt;<br>  &lt;mat-form-field&gt;<br>    &lt;mat-label&gt;Enter your email&lt;/mat-label&gt;<br>    &lt;input matInput placeholder=&quot;Enter Email Address&quot; formControlName=&quot;email&quot;&gt;<br>&lt;mat-error *ngIf=&quot;f.email.errors?.required&quot;&gt;<br>Enter Email Address<br>&lt;/mat-error&gt;  <br>&lt;/mat-form-field&gt;</pre><pre>&lt;mat-form-field&gt;<br>    &lt;mat-label&gt;Enter Password&lt;/mat-label&gt;<br>    &lt;input matInput placeholder=&quot;Enter Password&quot; formControlName]=&quot;password&quot;&gt;<br>&lt;mat-error *ngIf=&quot;f.password.errors?.required&quot;&gt;<br>Enter Email Address<br>&lt;/mat-error&gt;  <br>&lt;/mat-form-field&gt;<br>&lt;/form&gt;</pre><p>This applies only when the field is not supplied with value and when the user makes a touch on the field but what if the straight away clicks on the Submit button</p><p>Let us write a function for this app.component.ts to achieve the above case</p><pre>validateAllFormFields(formGroup: FormGroup) {</pre><pre>Object.keys(formGroup.controls).forEach((field) =&gt; {</pre><pre>const control = formGroup.get(field);</pre><pre>if (control instanceof FormControl) {</pre><pre>control.markAsTouched({</pre><pre>onlySelf: true</pre><pre>});</pre><pre>} else if (control instanceof FormGroup) { this.validateAllFormFields(control); }</pre><pre>});</pre><pre>}</pre><p>Just pass the formGroup created Here it is <strong>loginForm </strong>in the else part or in your failure section in submit function</p><p>To call the function inside the component,</p><pre>this.validateAllFormFields(this.loginForm)</pre><p>There are a lot of features available in Reactive Forms, the mentioned controls are very basic to learn in Reactive Forms. Let us discuss one by one in the next story. Have a good day and do like the post or pass your views in the comment section. Thank you</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef13f6c49783" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Must-Know JavaScript Array Methods]]></title>
            <link>https://kathiravan-ramaswamy.medium.com/must-know-javascript-array-methods-522ce7c46261?source=rss-40d5d612a583------2</link>
            <guid isPermaLink="false">https://medium.com/p/522ce7c46261</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[javascript-development]]></category>
            <dc:creator><![CDATA[Kathiravan Ramaswamy]]></dc:creator>
            <pubDate>Tue, 20 Oct 2020 13:56:54 GMT</pubDate>
            <atom:updated>2020-10-22T10:39:24.668Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oIO6CyXM7_ywVCyr" /><figcaption>Photo by <a href="https://unsplash.com/@mr_vero?utm_source=medium&amp;utm_medium=referral">Irvan Smith</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Welcome Coders to my second pat of tricks that we haven’t noticed in Javascript. In the <a href="https://medium.com/@kathiravan.ramaswamy/top-tricks-in-javascript-that-we-havent-noticed-f850848b48fd"><strong><em>first</em></strong></a> part, I have covered the tricks that we don&#39;t notice in JavaScript. In this story, we are going to see the important methods of Array in Javascript.</p><p>Come on!!! Let’s go and learn some interesting methods of Array that JavaScript holds.</p><p>Open Visual Studio Code and let us learn the methods of Array</p><h4>1. Filter</h4><p>The <em>filter()</em> method creates an array filled with all array elements that pass a test whereas it doesn&#39;t change the original array,</p><p>For Example, here is an example array of Cricket players with their best scores, if we need to filter with best which players are holding more than 180 can be done as follows</p><pre>const players = [<br>{name : ‘Ricky Ponting’, Best: 160},<br>{name : ‘Mathew Hayden’, Best: 180},<br>{name : ‘Adam Gilchrist’, Best: 183},<br>{name : ‘Saurav Ganguly’, Best: 183},<br>{name : ‘MS Dhoni’, Best: 183},<br>{name : ‘Virat Kohli’, Best: 183},<br>{name : ‘Sachin Tendulkar’, Best: 200},<br>{name : ‘Yuvaraj Singh’, Best: 150},<br>{name : ‘Rohit Sharma’, Best: 264},]</pre><pre>console.log(players)</pre><p>the console for the above snippet would be</p><pre>[<br>{name : ‘Ricky Ponting’, Best: 160},<br>{name : ‘Mathew Hayden’, Best: 180},<br>{name : ‘Adam Gilchrist’, Best: 183},<br>{name : ‘Saurav Ganguly’, Best: 183},<br>{name : ‘MS Dhoni’, Best: 183},<br>{name : ‘Virat Kohli’, Best: 183},<br>{name : ‘Sachin Tendulkar’, Best: 200},<br>{name : ‘Yuvaraj Singh’, Best: 150},<br>{name : ‘Rohit Sharma’, Best: 264},]</pre><p>To Filter the array as per the condition is as follows</p><pre>const filter = players.filter((player) =&gt; {<br>return player.Best &gt; 180;<br>});</pre><pre>console.log(filter);</pre><p>the following output is logged in the console</p><pre>[ { name: ‘Adam Gilchrist’, Best: 183 },<br> { name: ‘Saurav Ganguly’, Best: 183 },<br> { name: ‘MS Dhoni’, Best: 183 },<br> { name: ‘Virat Kohli’, Best: 183 },<br> { name: ‘Sachin Tendulkar’, Best: 200 },<br> { name: ‘Rohit Sharma’, Best: 264 } ]</pre><p>we can notice that the original array is not changed</p><h4><strong>2. Map</strong></h4><p>The <em>map()</em> method creates a new array with the results of calling a function for every array element whereas it does not execute the function for array elements without values</p><p>We can take the same array, for example, to get the names of the players in the array,</p><pre>const map = players.map((playerName) =&gt; {<br>return playerName.name;<br>});</pre><pre>console.log(map)</pre><p>it returns the following</p><pre>[ &#39;Ricky Ponting&#39;,<br>  &#39;Mathew Hayden&#39;,<br>  &#39;Adam Gilchrist&#39;,<br>  &#39;Saurav Ganguly&#39;,<br>  &#39;MS Dhoni&#39;,<br>  &#39;Virat Kohli&#39;,<br>  &#39;Sachin Tendulkar&#39;,<br>  &#39;Yuvaraj Singh&#39;,<br>  &#39;Rohit Sharma&#39; ]</pre><p>we can get the value with help of key in array items</p><p><strong>3. find</strong></p><p>The find() method returns the value of the first element in an array that passes a test (provided as a function).</p><p>The find() method executes the function once for each element present in the array:</p><ul><li>If it finds an array element where the function returns a <em>true</em> value, find() returns the value of that array element (and does not check the remaining values)</li><li>Otherwise, it returns undefined</li></ul><p><strong>Note:</strong> find() does not execute the function for empty arrays.</p><p><strong>Note:</strong> find() does not change the original array</p><p>For Example,</p><p>let me take the previous example in which the array of items containing the best scores of each player from different countries</p><pre>const score = players.find((value)=&gt;{return value.Best === 183 })</pre><p>it returns the first item in an array as below,</p><pre>{name : ‘Adam Gilchrist’, Best: 183}</pre><p><strong>4.forEach</strong></p><p>Unlike the other listed above methods, the forEach returns nothing rather it is similar to the for loop, To avoid more lines we can populate the items in an array using this method</p><pre>players.forEach((value) =&gt; {<br>//your logic goes here<br>})</pre><p>The value returns based on the logic you written inside the forEach method</p><p>Thank you Enjoy Scripting!!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=522ce7c46261" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Accepting ACH and Card Payments Angular and Dotnet Core using Stripe]]></title>
            <link>https://kathiravan-ramaswamy.medium.com/accepting-ach-and-card-payments-angular-and-dotnet-core-using-stripe-9979064ea5e2?source=rss-40d5d612a583------2</link>
            <guid isPermaLink="false">https://medium.com/p/9979064ea5e2</guid>
            <category><![CDATA[stripe]]></category>
            <category><![CDATA[dotnet-core]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Kathiravan Ramaswamy]]></dc:creator>
            <pubDate>Thu, 23 Jul 2020 12:08:19 GMT</pubDate>
            <atom:updated>2020-11-03T05:54:47.518Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello everyone, In this story, we gonna see about the Stripe integration in your web Application, In this story Card checkout integration and Making ACH Charges in Stripe has explained.</p><p><strong>Technologies used:-</strong></p><ul><li>Angular 9</li><li>Dotnet core</li></ul><p><strong>Pre-requisites:-</strong></p><ul><li>Node.js</li><li>Visual Studio Code</li><li>Visual Studio 2019</li><li>Sign up a new Stripe Account in <a href="https://stripe.com/">https://stripe.com/</a></li><li>Stripe.net Nuget package</li></ul><p>Stripe make Charge and Payment intent only through the server-side code, If you have queries related to Stripe you can go this <a href="https://webchat.freenode.net/">https://webchat.freenode.net/</a> and post your errors or queries for integrating Stripe in the Application.</p><p>To ask any queries in the above Site</p><p>Step 1: Give your Nickname</p><p>Step 2: Enter #stripe in Channel and verify yourself.</p><p>Now you can post your queries by entering in the Message Box</p><p><strong>Steps Involved to Integrate Stripe in Angular Application(Client Side)</strong></p><p>Step 1: Include Stripe.js link in your Index.html else you can load the script whenever you are going to Payment Component, Here I have included in the index.html</p><pre>&lt;script src=&quot;https://js.stripe.com/v3/&quot;&gt;&lt;/script&gt;</pre><p>Step 2: Create a typings.d.ts under the src directory in your Angular folder Structure and make the file look like below:</p><pre>declare var module: NodeModule</pre><pre>interface NodeModule {</pre><pre>id: string;</pre><pre>}</pre><pre>declare var Stripe: any</pre><p>Step 3: Generate a service name PaymentService or give the name on your own.</p><pre>ng g s payment</pre><p>Step 4: Declare a variable in Service as follows, You can find the Stripe Key in your Stripe Dashboard <strong>Developers-&gt; API Keys -&gt; Publishable Keys</strong></p><pre>stripe = Stripe(‘your stripe Publishable key’);</pre><p>Step 5: Inject the Service in the constructor of your Component</p><pre>constructor(private pmt: PaymentService){}</pre><h4>Card Payment</h4><p>Step 1: Import <strong>AfterViewInit, Input, ViewChild</strong> in your Component and implement AfterViewInit in the Component as below,</p><pre>export class CardPayComponent implements AfterViewInit</pre><p>Step 2: In the corresponding HTML enter the below tag</p><pre>&lt;div #payElement&gt;</pre><pre>&lt;!-- Your Stripe Elemnt render here --&gt;</pre><pre>&lt;/div&gt;</pre><p>Step 3: Create a <strong>ViewChild </strong>element in the component</p><pre>@ViewChild(&#39;payElement&#39;) payElement;</pre><p>Step 4: Declare the following variable in your Component</p><pre>@Input() amount: number;<br>@Input() label: string;<br>elements: any;<br>paymentRequest: any;<br>prButton: any</pre><p>Step 5: Now in ngAfterViewInit(), Do the following as given in the below snippet</p><pre>ngAfterViewInit() {</pre><pre>//1. Instantiate the Payment Object</pre><pre>this.paymentRequest = this.pmt.stripe.paymentRequest({</pre><pre>country: &#39;US&#39;,</pre><pre>currency: &#39;usd&#39;,</pre><pre>total: {</pre><pre>amount: this.amount,</pre><pre>label: this.label</pre><pre>}</pre><pre>});</pre><pre>//2.Initialize elements</pre><pre>this.elements = this.pmt.stripe.elements();</pre><pre>//3.register event listener</pre><pre>this.paymentRequest.on(&#39;source&#39;, async (event) =&gt; {</pre><pre>console.log(event);</pre><pre>setTimeout(() =&gt; {</pre><pre>event.complete(&#39;success&#39;)</pre><pre>}, 1000)</pre><pre>});</pre><pre>//4.create the Button</pre><pre>this.prButton = this.elements.create(&#39;paymentRequestButton&#39;, {</pre><pre>paymentRequest: this.paymentRequest,</pre><pre>style: {</pre><pre>paymentrequestButton: {</pre><pre>type: &#39;buy&#39;,</pre><pre>theme: &#39;dark&#39;//optional</pre><pre>}</pre><pre>}</pre><pre>});</pre><pre>//mount the button asynchronously<br>this.mountButton();</pre><pre>}</pre><p>Step 5.1: Implement an async Method as below,</p><pre>async mountButton() {</pre><pre>const result = await this.paymentRequest.canMakePayment();</pre><pre>if (result) {</pre><pre>this.prButton.mount(this.payElement.nativeElement)</pre><pre>} else {</pre><pre>console.error(&#39;Something went wrong&#39;)</pre><pre>}</pre><pre>}</pre><p>To render the checkout in page do the following</p><pre>&lt;app-card-pay [amount]=&quot;1&quot;, [label]=&quot;&#39;TEST&#39;&quot;&gt;&lt;/app-card-pay&gt;</pre><p>The above template reference will render the Pay Now Check out Button.</p><p><strong>Note: Make Sure you are running the application in HTTPS</strong></p><p>Will update the create payment intent soon which is server-side coding.</p><h4>Making ACH payment</h4><p>Step 1: Refer ACh guide provided by Stripe in their official documentation in <a href="https://stripe.com/docs/ach">https://stripe.com/docs/ach</a></p><p>Step 2: For making ACH charges, the bank account should be verified and authorized So create a bank account form in the application to get the routing number, Account Number, Account Type(individual or company) and Account Holder name, The Form should look like as mentioned below:(Here the verification is done Manually). Stripe allows two kinds of verification</p><ul><li>Using Plaid</li><li>Manually verifying bank Account</li></ul><p>Step 2.1: Create a bank account token</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*B0ZyVKbnf7tvHiUAId_i9A.png" /></figure><p>The HTML as follows:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*A3m84PpWjCI3QkSLd89Stw.png" /><figcaption>Generating Bank Token Form</figcaption></figure><p>Here I have used ReactiveForms to get the value</p><p>In your Component, Create a Formgroup</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/489/1*vX2aO1VqltAzT3gPvUzbzQ.png" /></figure><p>Create a Submit Button as below,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/593/1*Hz0pJWCT-LH0ceFfugpMOA.png" /></figure><p>Create a click event in the Component named<strong><em> bankAccount()[Client-Side]</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f_3kn9Yokg99rcwuJQ-zeA.png" /></figure><p>Note: Create a token based on your use case</p><p>Step 2.2: Create a Customer in Stripe by passing the token.id from the result in bankAccount() method<strong><em>[Client-Side], the token id looks like b_tokxxxx</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/669/1*6F9b6fzWk-t8SwMLH_aO_w.png" /></figure><p>Step 2.3: On the server-side, Browse Nuget package in the package manager Stripe.net</p><ul><li>Right-click your solution and click,</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/310/1*jr37IRMx8epKw2BJBv-5mw.png" /></figure><ul><li>Enter Stripe.net in the search bar and install the highlighted package</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5Biarjd7Z4cd9PqqeSeRVg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Uy12z7TMVUEsOp75tY0Eiw.png" /><figcaption>.NetCore Method to create a Customer</figcaption></figure><p>Repace Email with your own Email and pass the itemDataSource mentioned in bankVerification() as Parameter for createCustomer() method in service</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*a0iNuL73oaiOylUSDLoEvw.png" /></figure><p>Step 2.4: Verification of Micro deposit amount[Client-Side]</p><ul><li>Create a method in Service</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qqYaF6gKAVg408JBzy4QmA.png" /></figure><ul><li>Create verifyAmount(amount1, amount2) method in your Component</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/905/1*eOdhRTPQRK1F6FGkizfbpQ.png" /></figure><p>For example, your customer id looks like cus_xxxx and itemDataSource as ba_xxxxx, You should design verification with two input fields Amount 1 and Amount 2 as below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/921/1*Z2sZAOmk9of5cTrsYUWMuw.png" /><figcaption>verification form</figcaption></figure><p>Here I have designed in a modal, you can do it as a Multistep reactive form or based on your convenience, if the user pops out from verification then they should continue from where they left(Own logic based on Use-case), since the mico-deposit may take one to two days in live mode.</p><p>On the Server-side Implement the following</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/427/1*PC0q0TBGUBs5ZbFiMxEUjA.png" /><figcaption>.NetCore Method to verify a created Customer</figcaption></figure><p>Once the amount is verified, we should make a charge for the verified bank account, We should manually authorize the user before making a charge for the created bank Account</p><p>Create a method in service</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iGOvGY8KneNZt1B966yqAg.png" /><figcaption>Angular Service for creating a Charge</figcaption></figure><p>On the Client-side, the chargeAmount method looks like this in Component</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*2eYyruUkRnnfqHoIAhqJ9g.png" /><figcaption>Charge Amount event in Component</figcaption></figure><p>Note: Make sure you have authorized to Collect ACH payment</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/733/1*kfQLGReJOUq1nNTcG8ppdA.png" /><figcaption>Manual Payment Authorization</figcaption></figure><p>In Server-Side,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*snVNWPWFaBN7AZnC7l8f3w.png" /><figcaption>Charge Amount Method in .NetCore</figcaption></figure><p>Note: The <strong>StripApikey </strong>refers to you secret key in your Stripe Dashboard <strong>Developers-&gt; API Keys -&gt; Secret Keys</strong></p><p>Store the response for your future reference in your Database</p><p>Thank you for reading the post, Building webhooks and refunds, disputes will be covered in the upcoming story</p><p>HereBy I thank my contributor(thulasik8@gmail.com) for supporting me in server-side coding</p><p>Have a wonderful day!….</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9979064ea5e2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Paypal Checkout Client-Side Integration(Angular)]]></title>
            <link>https://kathiravan-ramaswamy.medium.com/paypal-checkout-client-side-integration-angular-2e71b597032e?source=rss-40d5d612a583------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e71b597032e</guid>
            <category><![CDATA[payments]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[paypal]]></category>
            <dc:creator><![CDATA[Kathiravan Ramaswamy]]></dc:creator>
            <pubDate>Thu, 23 Jul 2020 08:54:49 GMT</pubDate>
            <atom:updated>2020-07-23T08:56:05.845Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello everyone, In this story, we gonna see about the PayPal integration in your web Application, where you can accept payments to send and receive money from clients</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/283/1*Ku3BkY_4jOcP-AKr-LjZfQ.jpeg" /></figure><p><strong>Technologies used:-</strong></p><ul><li>Angular 9</li></ul><p><strong>Pre-requisites:-</strong></p><ul><li>Node.js</li><li>Visual Studio Code</li></ul><p>Steps Involved</p><p><strong>Step 1</strong>: Create a PayPal account</p><p><strong>Step 2</strong>: Log in to developer dashboard and click Accounts under Sandbox</p><p><strong>Step 3</strong>: Create a Personal and Buyer Account matches your case</p><p><strong>Step 4</strong>: Go to My Apps and Credentials -&gt; Create Rest API app in Sandbox for mock transactions</p><p><strong>Step 5</strong>: Give Name of the Application and choose the Business account in Sandbox Business Account DropDown</p><p><strong>Step 6</strong>: Create an App</p><p>Once the App created successfully log in to your sandbox account by entering the following URL: <a href="https://www.sandbox.paypal.com/signin">https://www.sandbox.paypal.com/signin</a></p><p>Enter the Username and Password you gave in Step 3.</p><p>Note: By default, the amount sent will be transferred to the business account Created.</p><p>Go to your Angular Application</p><p><strong>In your index.html</strong></p><p>Add the script tag as below</p><pre>&lt;script src=”https://www.paypal.com/sdk/js?client-id=&lt;your_client_id&gt;&quot;&gt;&lt;/script&gt;</pre><p><strong>In your Component</strong></p><ul><li>Import ViewChild in your Component</li><li>Define a Property as described in the given snippet below, you can make it dynamic by making an API call based on your condition</li></ul><p><strong>Note: You can initialize the Paypal Checkout Button based on your condition</strong></p><pre>@ViewChild(‘paypal’, { static: true }) paypalElement: ElementRef //html ement Paypal Smart button</pre><pre>product = {</pre><pre>price: ‘1.00’,</pre><pre>description: ‘Check Amount’</pre><pre>}// this property can be make dynamically from your web api</pre><pre>payeeEmail: string = &lt;Merchant Account to credit the charge Amount&gt;</pre><pre>paidFor: boolean = false; //Payment Successful Message handling</pre><pre>paypalConfig = {//Configuration for paypal Smart Button</pre><pre><strong>createOrder</strong>: (data, actions) =&gt; {</pre><pre><strong>return actions.order.create({</strong></pre><pre><strong>purchase_units: [{</strong></pre><pre><strong>description: &#39;Manager To Owner Payment&#39;,</strong></pre><pre><strong>amount: {</strong></pre><pre><strong>currency_code: &#39;USD&#39;,</strong></pre><pre><strong>value: amt</strong></pre><pre><strong>}, payee: {</strong></pre><pre><strong>email_address: this.payeeEmail // to send amout to corresponding Merchant</strong></pre><pre><strong>},</strong></pre><pre><strong>invoice_id: &lt;You can geneate on your Own Logic&gt;</strong>,</pre><pre>}]</pre><pre>});</pre><pre>},</pre><pre><strong>onApprove</strong>: async (data, actions) =&gt; {</pre><pre><strong>const order = await actions.order.capture();</strong></pre><pre><strong>this.paidFor = true;</strong></pre><pre>console.log(order)</pre><pre>},</pre><pre>onError: err =&gt; {</pre><pre>console.log(err)</pre><pre>}</pre><pre>}</pre><pre>constructor() { }</pre><pre>ngOnInit() {</pre><pre>paypal.Buttons(this.paypalConfig).render(this.paypalElement.nativeElement)</pre><pre>}</pre><p><strong>In your HTML</strong></p><pre>&lt;div *ngIf=”!paidFor”&gt;</pre><pre>&lt;h1&gt;Buy this for — ${{product.price}} OBO&lt;/h1&gt;</pre><pre>&lt;p&gt;{{product.description}}&lt;/p&gt;</pre><pre>&lt;/div&gt;</pre><pre>&lt;div *ngIf=”paidFor”&gt;</pre><pre>&lt;h1&gt;Amount Transferred Successfully&lt;/h1&gt;</pre><pre>&lt;/div&gt;</pre><pre>&lt;div #paypal&gt;&lt;/div&gt;</pre><p>Start your Angular App</p><pre>ng serve --o</pre><p>your app will be listening on <a href="http://localhost:4200/">http://localhost:4200</a></p><p><strong>Note: Make sure you have replaced the your_client_id in index.html</strong></p><p>Thank you :) For reading the story, Let me know here if you have any concerns or discussions about this.</p><p>Have a great day!!!…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e71b597032e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Top Tricks in JavaScript that we haven’t Noticed]]></title>
            <link>https://kathiravan-ramaswamy.medium.com/top-tricks-in-javascript-that-we-havent-noticed-f850848b48fd?source=rss-40d5d612a583------2</link>
            <guid isPermaLink="false">https://medium.com/p/f850848b48fd</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[javascript-tips]]></category>
            <dc:creator><![CDATA[Kathiravan Ramaswamy]]></dc:creator>
            <pubDate>Mon, 16 Mar 2020 19:51:43 GMT</pubDate>
            <atom:updated>2020-11-03T05:51:36.007Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xJUg5oONmM6kZDNWOOYqHQ.jpeg" /></figure><p>Hey everyone out there, Have a great day….</p><p>Here we gonna see the top tricks in JavaScript that every web developers should get to know,</p><p>Open your favorite editor, Here I recommend you to download Visual Studio Code from the below link:</p><p><a href="https://code.visualstudio.com/Download">Download Visual Studio Code - Free AI Code Editor for Mac, Linux, Windows</a></p><p>Come on!!! Let’s go and learn some interesting tricks that JavaScript holds.</p><ol><li><strong>Ternary Magic</strong></li></ol><p>Normally we use <em>if..else</em> for conditioning where we use the ternary operator to optimize our coding skills,</p><p>here’s a snippet to explain how to use the ternary operator</p><pre>const age = 18;</pre><pre>age &lt; 18 ? console.log(‘you are not eligible to cast a Vote’) : console.log(‘you are eligible to cast a Vote’)</pre><p>The above snippet explains the simple <em>if..else</em> condition where the age for casting Vote is constant in India, if you are less than 18, then you are not eligible to vote else, we get you are eligible to vote.</p><p>Similarly, Even <em>nested if-else</em> using ternary is possible, let’s see the magic,</p><pre>const age = 49;</pre><pre>age &gt; 50</pre><pre>? age &gt; 70</pre><pre>? console.log(&quot;you are getting really old&quot;)</pre><pre>: console.log(&quot;you are between 50 and 70&quot;)</pre><pre>: console.log(&#39;you are younger&#39;);</pre><p>The above snippet says, if you are above 50 and 70, the script returns “you are getting really old”, else if, “you are between 50 and 70” else “you are younger”</p><p>2. <strong>Number to String</strong></p><p>It’s very simple, find below how to convert Number to string</p><p>Append a “” to convert a number to a string</p><pre>const num = 60 + “”</pre><pre>console.log(typeof num);</pre><p>the above snippet returns “string” in console</p><p>3. <strong>Fill Arrays</strong></p><p>To fill the arrays with empty spaces or any values, this is achieved by</p><pre>const arr = Array(&lt;index&gt;).fill(‘ ‘);</pre><pre>console.log(arr);</pre><p>we can add value to the array by</p><pre>//const arr = Array(&lt;index&gt;).fill(&lt;fill value&gt;);</pre><pre>const arr = Array(6).fill(6)</pre><p><strong>Note</strong>: The fill value can be anything…</p><p>4.<strong> Unique Arrays</strong></p><p>Initialize an array of integers or string,</p><pre>const array = [&lt;Array values&gt;]</pre><pre>const unique = Array.from(new Set(array))</pre><pre>console.log(unique);</pre><p><strong>The set </strong>doesn’t return the duplicate values.</p><p>5. <strong>Dynamic Objects</strong></p><p>create an object and a variable, for example,</p><pre>const dynamicKey = “&lt;your key value&gt;”</pre><pre>const object = {</pre><pre>key: “”,</pre><pre>key : “”,</pre><pre>[dynamicKey] : ‘’</pre><pre>}</pre><p>to make a dynamic object, surround the dynamicKey with square brackets as mentioned in the object defined,</p><pre>console.log(object);</pre><p>Thus the console returns the object with const <strong>dynamicKey </strong>defined.</p><p>6. <strong>Array to Object</strong></p><p>Initialize an array and object variable, where we use <strong>spread operator(…)</strong> in defining the object</p><pre>const array = [2,3,4,53,3,6];</pre><pre>const arrayObject = {…array};</pre><pre>console.log(arrayObject);</pre><p>the reverse is possible in scripting which is,</p><p>7. <strong>Object to Array</strong></p><pre>const directors = {</pre><pre>name: “Akon”,</pre><pre>song: ‘Smack That’</pre><pre>}</pre><pre>const directorKeys = Object.keys(directors)</pre><pre>console.log(directorKeys)</pre><p>This will return the keys of the object and to return the values of the</p><p>object, just do</p><pre>const directorValues = Object.values(directors)</pre><pre>console.log(directorValues)</pre><p>8. <strong>Template Literals</strong></p><p>Javascript allows both multiline strings and string interpolation</p><p>For Example, consider you want to print the string or number along with a note, it can be done as follows</p><pre>var a = 2;<br>console.log(`Number:${a}`);</pre><p>Thank you and hereby I attach the script file path</p><p><a href="https://github.com/kathiravan1797/jstricks/blob/master/script.js">kathiravan1797/jstricks</a></p><p>In the next part, we will see about the <a href="https://kathiravan-ramaswamy.medium.com/must-know-javascript-array-methods-522ce7c46261?source=your_stories_page-------------------------------------"><strong>Array methods in Javascript</strong></a></p><p>Enjoy scripting!!!..</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f850848b48fd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Start Angularjs using Grunt without using Visual Studio 2015]]></title>
            <link>https://kathiravan-ramaswamy.medium.com/start-angularjs-using-grunt-without-using-visual-studio-2015-4ae705157899?source=rss-40d5d612a583------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ae705157899</guid>
            <category><![CDATA[angularjs]]></category>
            <category><![CDATA[vs2015]]></category>
            <category><![CDATA[npm]]></category>
            <category><![CDATA[grunt]]></category>
            <dc:creator><![CDATA[Kathiravan Ramaswamy]]></dc:creator>
            <pubDate>Tue, 28 Jan 2020 16:17:37 GMT</pubDate>
            <atom:updated>2020-01-29T05:49:49.748Z</atom:updated>
            <content:encoded><![CDATA[<p>Grunt is a JavaScript task runner, a tool used to automatically perform frequent tasks such as minification, compilation, unit testing, and linting. It uses a command-line interface to run custom tasks defined in a file. Grunt was created by Ben Alman and is written in Node.js. It is distributed via npm</p><h3>Pre-requisites</h3><ol><li>Visual Studio Code(1.41[recommended])</li><li>Visual Studio 2015</li><li>Node.js</li></ol><h3>Steps to be followed:</h3><ul><li>Open <strong>Visual Studio Code</strong> and open the <strong>wwwroot </strong>folder in <strong>Visual Studio 2015</strong></li><li>create a new file package.json to mention the dev dependencies as shown in the project structure</li></ul><pre>{<br>    &quot;version&quot;: &quot;1.0.0&quot;,<br>    &quot;name&quot;: &quot;asp.net&quot;,<br>    &quot;private&quot;: true,<br>    &quot;devDependencies&quot;: {<br>        &quot;grunt&quot;: &quot;^1.0.4&quot;,<br>        &quot;grunt-autoprefixer&quot;: &quot;^3.0.4&quot;,<br>        &quot;grunt-bower-task&quot;: &quot;0.5.0&quot;,<br>        &quot;grunt-cli&quot;: &quot;^1.3.2&quot;,<br>        &quot;grunt-contrib-cssmin&quot;: &quot;^3.0.0&quot;,<br>        &quot;grunt-contrib-jshint&quot;: &quot;^2.1.0&quot;,<br>        &quot;grunt-contrib-uglify&quot;: &quot;^4.0.1&quot;,<br>        &quot;grunt-contrib-watch&quot;: &quot;^1.1.0&quot;,<br>        &quot;grunt-sass&quot;: &quot;^3.1.0&quot;,<br>        &quot;grunt-serve&quot;: &quot;^0.1.6&quot;<br>    }<br>}</pre><ul><li>Open command prompt and route to wwwroot</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*ew7iU9rrvKCGqMBTgqe6bQ.png" /></figure><pre>npm install</pre><ul><li>Now create a new file gruntfile.js and paste the below code and save it</li></ul><pre>module.exports = function (grunt) {<br> grunt.initConfig({<br> serve: {<br> options: {<br> port: 65498<br> }<br> }<br> });<br> grunt.loadNpmTasks(“grunt-serve”);<br>};</pre><p>Enter command prompt and follow</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/398/1*-RCyomIJQF6iyVeqqaN-TA.png" /></figure><p>Open localhost:65498/index.html in you browser.</p><p>My project looks like as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/379/1*Q8WqeC1kNJQ_KIx5jv4JTg.png" /><figcaption>wwwroot structure</figcaption></figure><p><strong>Note:</strong>Here only the Web part has been served in the browser, the minification and compilation will be covered in next part.</p><p>Thanks…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ae705157899" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flask Restful RequestParser accepting tuple and String in GET requests]]></title>
            <link>https://kathiravan-ramaswamy.medium.com/flask-restful-requestparser-accepting-tuple-and-string-in-get-requests-bd831d2cea96?source=rss-40d5d612a583------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd831d2cea96</guid>
            <category><![CDATA[flask-restful]]></category>
            <category><![CDATA[flask]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Kathiravan Ramaswamy]]></dc:creator>
            <pubDate>Thu, 17 Oct 2019 06:37:23 GMT</pubDate>
            <atom:updated>2020-01-18T09:27:40.720Z</atom:updated>
            <content:encoded><![CDATA[<p>Flask-RESTful’s request parsing interface, <a href="https://flask-restful.readthedocs.io/en/0.3.6/api.html#module-reqparse"><strong>reqparse</strong></a>, is modeled after the <a href="http://docs.python.org/dev/library/argparse.html">argparse</a> interface. It’s designed to provide simple and uniform access to any variable on the <strong>flask.request</strong> object in Flask</p><p><strong>Usage</strong></p><pre>from flask_restful import reqparse, Resource, Api<br>from flask import Flask</pre><pre>app = Flask(__name__)<br>rest = Api(app)</pre><pre># Define parser and request args<br>reqparser = reqparse.RequestParser()<br>reqparser.add_argument(&#39;input&#39;, type=str)<br>reqparser.add_argument(&#39;type&#39;, type=str)</pre><pre>class Search(Resource):<br>     def get():<br>         args = reqparser.parse_args()<br>         s = args[&#39;input&#39;].split(&#39;,&#39;)<br>         types = args[&#39;type]<br>         # do your stuff ...</pre><pre>#just mention the trailing point<br>rest.add_resource(Search, &#39;/search&#39;)</pre><pre>#run the flask app<br>if __name__ == &#39;__main__&#39;:<br>      app.run(debug=True, port=8080, host=&#39;0.0.0.0&#39;)</pre><p>sample url: <a href="http://localhost:8080/search?input=thermostat&amp;type=pdf">http://localhost:8080/search?input=thermostat&amp;type=pdf</a></p><p>This done my work.</p><p>Thanks.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd831d2cea96" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Configuring Node.js server with Firebase Admin SDK to send Push Notifications To Android Mobile]]></title>
            <link>https://kathiravan-ramaswamy.medium.com/configuring-node-js-server-with-firebase-admin-sdk-to-send-push-notifications-to-android-mobile-546e4c233450?source=rss-40d5d612a583------2</link>
            <guid isPermaLink="false">https://medium.com/p/546e4c233450</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[firebasecloudmessaging]]></category>
            <category><![CDATA[firebase]]></category>
            <dc:creator><![CDATA[Kathiravan Ramaswamy]]></dc:creator>
            <pubDate>Thu, 05 Sep 2019 05:11:34 GMT</pubDate>
            <atom:updated>2021-02-02T06:06:20.764Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_9J4Zpijs25MZJrAk9X1aA.png" /><figcaption>FCM WorkFlow</figcaption></figure><p>Here, I am using Admin Node.js SDK to send Push Notifications to Android Mobile.</p><pre>npm install firebase-admin --save</pre><p>Run the above command to install Admin Node.js SDK. Create a file named on your own, here i named <strong>pushnotification.ts.</strong></p><h3>Initialize the SDK</h3><p>Once you have created a Firebase project, you can initialize the SDK with an authorization strategy that combines your service account file together with <a href="https://cloud.google.com/docs/authentication/production#providing_credentials_to_your_application">Google Application Default Credentials</a>.</p><p>To authenticate a service account and authorize it to access Firebase services, you must generate a private key file in JSON format.</p><p><strong>To generate a private key file for your service account:</strong></p><ol><li>In the Firebase console, open <strong>Settings &gt; </strong><a href="https://console.firebase.google.com/project/_/settings/serviceaccounts/adminsdk"><strong>Service Accounts</strong></a>.</li><li>Click <strong>Generate New Private Key</strong>, then confirm by clicking <strong>Generate Key</strong>.</li><li>Securely store the JSON file containing the key.</li></ol><p>There are some recommended ways to initialize the admin SDK, here I have initialized through a variable config in my Typescript file as follows:</p><pre>var admin = require(‘firebase-admin’);</pre><pre>var config = <br>{<br> apiKey: “my_api_key”,<br> storageBucket: “project.appspot.com”,<br> private_key_id: “my_private_key_id”,<br> private_key: “my_private_key generated from Firebase console”,<br> client_email: “my_client_email”,<br> client_id: “my_client_id”,<br> auth_uri: “https://accounts.google.com/o/oauth2/auth”,<br> token_uri: “https://oauth2.googleapis.com/token&quot;,<br> auth_provider_x509_cert_url: “&lt;Do not Change in JSON File&gt;,<br> client_x509_cert_url: “&lt;Do not Change in JSON File&gt;&quot;<br>};</pre><p>The values initialized in config are available in the generated JSON file,</p><p>In case, if you try to use the credentials of the application simply point to the JSON file or set the environment variable as follows:</p><pre>Linux or macOS:<br><em>export GOOGLE_APPLICATION_CREDENTIALS=&quot;/home/user/Downloads/service-account-file.json&quot;</em></pre><pre>Windows:(with Powershell)<br>$env:GOOGLE_APPLICATION_CREDENTIALS=&quot;C:\Users\username\Downloads\service-account-file.json&quot;</pre><p>Initialize the SDK as shown:</p><pre>const app = admin.initializeApp({<br>credential: admin.credential.cert(config),<br>});</pre><p>To send messages to Single Device using send() method:</p><pre>var token = ‘device token’;<br> var message = {<br> data: {<br> score: ‘850’,<br> time: ‘2:45’<br> },<br> token: token<br> };<br> const messaging = app.messaging();<br> messaging.send(message)<br> .then((response) =&gt; {<br> // Response is a message ID string.<br> console.log(‘Successfully sent message:’, response);<br> })<br> .catch((error) =&gt; {<br> console.log(‘Error sending message:’, error);<br> });</pre><p>To send messages to Single Device using sendToDevice() method:</p><pre>var deviceId = registrationToken;<br>payload = {data: { title: &quot;your message&quot;}};<br>app.messaging().sendToDevice(deviceId, payload)<br>.then(function (response) {<br>if (response) {<br>console.log(&quot;Successfully sent message:&quot;, response);<br>app.delete();<br>}<br>else {console.log(&quot;Error&quot;, response);}})<br>.catch(function (error) <br>{console.log(&quot;Error sending message:&quot;, error);});</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=546e4c233450" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>