Google pay not visible on android chrome device if the allowedCardAuthMethod is CRYPTOGRAM 3DS - google-pay

In Android Chrome, When trying to initialize Google pay with allowedCardAuthMethod as Cryptogram 3ds, not able to view the google pay button
I am trying from India.
sample code: https://jsfiddle.net/dummy4150/8e2cbs6d/
const baseRequest = {
  apiVersion: 2,
  apiVersionMinor: 0
};
const allowedCardNetworks = ["AMEX", "DISCOVER", "INTERAC", "JCB", "MASTERCARD", "VISA"];
const allowedCardAuthMethods = ["CRYPTOGRAM_3DS"];
const tokenizationSpecification = {
  type: 'PAYMENT_GATEWAY',
  parameters: {
    'gateway': 'example',
    'gatewayMerchantId': 'exampleGatewayMerchantId'
  }
};
const baseCardPaymentMethod = {
  type: 'CARD',
  parameters: {
    allowedAuthMethods: allowedCardAuthMethods,
    allowedCardNetworks: allowedCardNetworks
  }
};
const cardPaymentMethod = Object.assign(
  {},
  baseCardPaymentMethod,
  {
    tokenizationSpecification: tokenizationSpecification
  }
);

Since you've specified allowedCardAuthMethods as CRYPTOGRAM_3DS and that you are trying from India, Here are a couple of things you could try:
Add a tokenized card to Google Pay (one that can be used for Tap and Pay)
Generally, Google Pay isn't currently supported in India, join the googlepay-test-mode-stub-data to use predefined test data that can be used in India (more info)
Create a new Google Account for testing based outside of India (suggest using USA) and add a tokenized card to that account

Related

Why "not defined" error returned when rendering an EJS template from ExpressJS app.locals variable?

ExpressjS Application End-Point (request)
app.get('/', (req, res, next) => {
db.collection('sys_params').find().toArray((err, sysParams) => {
if (err) throw err;
app.locals.landPageRolloverStatus = sysParams[0].landPageRolloverStatus;
app.locals.ludenourOnlineStatus = sysParams[0].ludenourOnlineStatus;
app.locals.ludenourContactUsEnabled = sysParams[0].ludenourContactUsEnabled;
app.locals.ludenourJobsEnabled = sysParams[0].ludenourJobsEnabled;
console.log(sysParams)
app.locals.sysParams = sysParams;
});
res.render('index2');
next()
});
The error is related to the app.locals.sysParams.
ReferenceError: /Users/falswaimil/Documents/Project3X/Master/AIRECP/AirECPRetails/online-store/views/index2.ejs:39
   37|
   38| <a class="navbar-brand float-xs-right float-sm-left" href="http://localhost:3002/?clang=en"><img src="img/lu3.svg" class="img-fluid"/></a>
>> 39|         <% if (sysParams[0].ludenourOnlineStatus == "UC" ) { %>
   40|
   41|             <% if (clang == "en") {  %>
   42|                 <p style="color:red; font-family:Arial Rounded MT Bold; font-size:130%; text-align:center; width: 100%;"><%= __('SiteUnderConstruction') %></p>  
sysParams is not defined
However; when I refresh the page, the page is rendered without errors.
Because I am passing an expressJS application-level variable, it should be available on the EJS template across requests.
The issue with properly handling async operations. After using async/await in my middleware, the error resolved.
const readBootstrap = async(req, res, next) => {
await db.collection('sys_params').find().toArray()
.then(sysParams => {
app.locals.landPageRolloverStatus = sysParams[0].landPageRolloverStatus;
app.locals.ludenourOnlineStatus = sysParams[0].ludenourOnlineStatus;
app.locals.ludenourContactUsEnabled = sysParams[0].ludenourContactUsEnabled;
app.locals.ludenourJobsEnabled = sysParams[0].ludenourJobsEnabled;

Google-script; Conversion from the format application / octet-stream to application / pdf is not supported

I have a similar error to ERROR Get pdf-attachments from Gmail as text but it doesn't work in my case. Drive API's enable. Document has the extension .pdf.
This script works for other documents (also pdf).
Read pdf as text is from Get pdf-attachments from Gmail as text
Please help.
This is my code:
function searchEmails() {
var threads = GmailApp.search('in:inbox newer_than:6d');
if (threads.length > 0) {
for (var t=threads.length-1; t>=0; t--) {
var thread = threads[t];
var message = thread.getMessages()[0];
var from = message.getFrom();
var subject = message.getSubject();
var to = message.getTo();
var date = message.getDate();
var body = message.getBody();
var attachments = message.getAttachments();
if (subject == 'subject') {
Messages(message)
}
}
}
}
function Messages(message) {
var attachments = message.getAttachments();
var blob = attachments[0].getAs(MimeType.PDF);
var body = message.getBody();
var filetext = pdfToText(blob);
filetext = filetext.substr(filetext.search("Title:"));
filetext = filetext.split(' ');
var msgValue = filetext[12];
var msgDate = filetext[6];
var msgID = message.getId();
// rest of my code
function pdfToText (blob, options) {
options = options || {};
var parents = [];
if (options.path) {
parents.push(getDriveFolderFromPath(options.path));
}
var pdfName = blob.getName();
var resource = {
title: pdfName,
mimeType: blob.getContentType(),
parents: parents
};
// Save PDF as GDOC
resource.title = pdfName.replace(/pdf$/, 'gdoc');
var insertOpts = {
ocr: true,
ocrLanguage: options.ocrLanguage || 'pl'
}
var gdocFile = Drive.Files.insert(resource, blob, insertOpts);
// Get text from GDOC
var gdocDoc = DocumentApp.openById(gdocFile.id);
var text = gdocDoc.getBody().getText();
// Delete document.
if (!options.keepGdoc) {
Drive.Files.remove(gdocFile.id);
}
return text;
}
function getDriveFolderFromPath (path) {
return (path || "/").split("/").reduce ( function(prev,current) {
if (prev && current) {
var fldrs = prev.getFoldersByName(current);
return fldrs.hasNext() ? fldrs.next() : null;
}
else {
return current ? null : prev;
}
},DriveApp.getRootFolder());
}
First of all my first code works. However, if there is more than one attachment in email, you will have problems I had originally. Solution below:
function searchEmails() {
var threads = GmailApp.search('in:inbox newer_than:6d');
if (threads.length > 0) {
for (var t=threads.length-1; t>=0; t--) {
var msgs = GmailApp.getMessagesForThreads(threads);   
for (var i = 0 ; i < msgs.length; i++) {   
for (var j = 0; j < msgs[i].length; j++) {     
var attachments = msgs[i][j].getAttachments();               
for (var k = 0; k < attachments.length; k++) {         
var content = attachments[k].getContentType();               
Logger.log(attachments[k].getName()) //check file extension
if (content == 'application/pdf'){
 
/*
you can check if the attachment has the expected name
var attachmentsName = attachments[k].getName();
          if (attachmentsName == 'looking name'){
*/
      var blob = attachments[k].getAs(MimeType.PDF);           
var filetext = pdfToText(blob);           
filetext = filetext.substr(filetext.search("SZCZEGÓŁY"));           
filetext = filetext.split(' ');                       
var msgValue = filetext[14] + filetext[15];           
var msgDate = filetext[6];           
var type = filetext[3];           
// rest of my code
function pdfToText (blob, options) {
options = options || {};
var parents = [];
if (options.path) {
parents.push(getDriveFolderFromPath(options.path));
}
var pdfName = blob.getName();
var resource = {
title: pdfName,
mimeType: blob.getContentType(),
parents: parents
};
// Save PDF as GDOC
resource.title = pdfName.replace(/pdf$/, 'gdoc');
var insertOpts = {
ocr: true,
ocrLanguage: options.ocrLanguage || 'pl'
}
var gdocFile = Drive.Files.insert(resource, blob, insertOpts);
// Get text from GDOC
var gdocDoc = DocumentApp.openById(gdocFile.id);
var text = gdocDoc.getBody().getText();
// Delete document.
if (!options.keepGdoc) {
Drive.Files.remove(gdocFile.id);
}
return text;
}
function getDriveFolderFromPath (path) {
return (path || "/").split("/").reduce ( function(prev,current) {
if (prev && current) {
var fldrs = prev.getFoldersByName(current);
return fldrs.hasNext() ? fldrs.next() : null;
}
else {
return current ? null : prev;
}
},DriveApp.getRootFolder());
}

Powershell: Selecting individual values from JSON response

I'm testing code to send payment details as JSON which is working however I'm struggling to extract information from the JSON response.
I need to extract the content part of the JSON response as individual values so I can assign them to variables then insert them into a SQL table.
The response is assigned to $Result . I've tried $Result.content though obviously this gives you the whole content section. Is there a way to obtain individual values from content without going down the substring route?
Here is an example of a response:
{"transaction":{"id":"83123b05-2435-40c9-851d-a5636f092637","processed_at":"2019-04-05T13:02:19.689188Z","transaction_type":"Debit","currency_code":"GBP","amount":25000,"recipient_id":"8a659242-8e70-47e1-85ca-2fe18cb262a0","status":"Waiting for funds","status_info":"Insufficient Funds To Process","reconciliation":null,"reference":"D000000516","account_id":"07b286ad-dabc-42a7-ab1b-5302fd382e6c","tag":null,"end_balance":null,"idempotent_key":"1f25e9f8-64cf-4e91-b4d3-8753437b6dbb","created_at":"2019-04-05T13:02:19Z","updated_at":"2019-04-05T13:02:19Z"}}
Here is my Powershell Code:
cls
$Uri = "uriaddress"
$Content = Get-content C:\Test\BACS-DC190326093019.TXT | select-object -skip 4 
foreach($line in $Content){
  if($line.Substring(0,1) -match "[0-9]")
  {
  $sorcode = $line.Substring(0,6)
  $sorcode 
  $accountNumber =   $line.Substring(6,8)
  $accountNumber
  $CustomerName = $line.Substring(82,18)
  $CustomerName
  $FundingAmount = $line.Substring(41,5)
  $FundingAmount = $FundingAmount 
  $FundingAmount
  $Identifier = $line.Substring(64,10)
  $idempotent_key = New-Guid
  $body = #{
    "account_id"     = "000000"
    "currency_code"  = "GBP"
    "amount"         = $FundingAmount
    "recipient_name" = $CustomerName
    "account_no"     = $accountNumber
    "sort_code"      = $sorcode
    "idempotent_key" = $idempotent_key
    "reference"      = $Identifier
    "legal_type"     = "PRIVATE"
    }
    $headers = #{}
    $headers.Add("Authorization","00000000")
    $Result = ''
    $Result = Invoke-WebRequest -Uri $Uri -ContentType 'multipart/form-data' -Method Post -Headers $headers -Body $body 
 $Result.Content
    IF ($Result.StatusDescription -eq 'OK') { 
    write-host "Payment Sent Succesfully" -ForegroundColor Green
    } ELSE {
      write-host "Payment Failed Succesfully" -ForegroundColor Red
    }
    write-host ""
  }
}
PowerShell has built in support for processing JSON, so let's run your input through ConvertFrom-Json and see what we get.
$Result = '{"transaction":{"id":"83123b05-2435-40c9-851d-a5636f092637","processed_at":"2019-04-05T13:02:19.689188Z","transaction_type":"Debit","currency_code":"GBP","amount":25000,"recipient_id":"8a659242-8e70-47e1-85ca-2fe18cb262a0","status":"Waiting for funds","status_info":"Insufficient Funds To Process","reconciliation":null,"reference":"D000000516","account_id":"07b286ad-dabc-42a7-ab1b-5302fd382e6c","tag":null,"end_balance":null,"idempotent_key":"1f25e9f8-64cf-4e91-b4d3-8753437b6dbb","created_at":"2019-04-05T13:02:19Z","updated_at":"2019-04-05T13:02:19Z"}}'
$Result = $Result | Convertfrom-json
In your usage, you'd just run the last part to convert $Result into a PowerShell Object.
$Result has one property called .transaction where all of the info lives. We can get this out with the following syntax.
$result.transaction
id : 83123b05-2435-40c9-851d-a5636f092637
processed_at : 2019-04-05T13:02:19.689188Z
transaction_type : Debit
currency_code : GBP
amount : 25000
recipient_id : 8a659242-8e70-47e1-85ca-2fe18cb262a0
status : Waiting for funds
status_info : Insufficient Funds To Process
reconciliation :
reference : D000000516
account_id : 07b286ad-dabc-42a7-ab1b-5302fd382e6c
tag :
end_balance :
idempotent_key : 1f25e9f8-64cf-4e91-b4d3-8753437b6dbb
created_at : 2019-04-05T13:02:19Z
updated_at : 2019-04-05T13:02:19Z
So, now if we want to pull out specific values from there, we run the following.
C:\Users\Stephen> $result.transaction.amount
25000
C:\Users\Stephen> $result.transaction.status
Waiting for funds
C:\Users\Stephen> "Transaction in the amount of $($result.transaction.amount) -- status: $($result.transaction.status)"
Transaction in the amount of 25000 -- status: Waiting for funds
This should get you on your way.
Final tidbit, if you swap out Invoke-WebRequest for Invoke-RestMethod, the conversion from JSON is done for you automatically!

what is Jenkins file and how you will write

What is Jenkins file and How we will write?
How to create Jenkins job dynamically using DSL(I'm not aware of DSL)
From 30 page of Jenkins User Handbook: `Jenkinsfile is a text file that contains the definition of a Jenkins Pipeline and is checked into source control. In his chapter you can find examples of pipelines.
// Declarative //
pipeline {
agent any
  stages {
  stage('Build') {
  steps {
  echo 'Building..'
  }
  }
  stage('Test') {
  steps {
  echo 'Testing..'
  }
  }
  stage('Deploy') {
  steps {
  echo 'Deploying....'
  }
  }
}
// Script //
node {
  stage('Build') {
  echo 'Building....'
  }
  stage('Test') {
  echo 'Building....'
  }
  stage('Deploy') {
  echo 'Deploying....'
  }
}

How to use set_result with transacion in endpoint (Netzke gem)

I have create an endpoint for create new Client.
At first I have create Client and use transaction (see code below).
It's work normally.
# Before add set_result
js_method :on_new_contact, <<-JS
function() {
var form = this.items.first().getForm();
if (form.isValid()) {
this.newContact(form.getFieldValues());
this.closeRes = 'create_user';
this.close();
}
}
JS
endpoint :new_contact do |params|
data_hash = params.to_hash
Client.transaction do
new_client = Client.new
data_hash.each do |field, value|
new_client.__send__("#{field}=", value)
end
if new_client.save!
flash :notice => "Client #{new_client.full_name} has been created"
else
flash :error => new_user.errors.full_messages.to_sentence
end # if
end # transaction
{:netzkeFeedback => #flash}
end # endpoint
And after I have add set result for return new Client id from endpoint.
It's save new Client 3 times to my database.
# After add set_result
js_method :on_new_contact, <<-JS
   function() {
     var form = this.items.first().getForm();
     if (form.isValid()) {
       this.newContact(form.getFieldValues(), function(value){
           alert(form);
           alert(value);
       }, this);
       this.closeRes = 'create_user';
       this.close();
     }
   }
 JS
 endpoint :new_contact do |params|
   data_hash = params.to_hash
   Client.transaction do
     new_client = Client.new
     data_hash.each do |field, value|
       new_client.__send__("#{field}=", value)
     end
     if new_client.save!
       flash :notice => "Client #{new_client.full_name} has been created"
     else
       flash :error => new_user.errors.full_messages.to_sentence
     end # if
   end # transaction
   {:netzkeFeedback => #flash, :set_result => new_client.id}
 end # endpoint
I already try to find what the problem.
And I found it happen when I use set_result with transaction.
If I remove transaction OR set_result code, it will work normally.
Then how can I make it work?