I have web application in c# and angular Views. the application about reservation of Hotels. My Manager assign me a Task to integrate google pay in This application But after hitting googlepay button popup appaers but after filling the information i a getting error Chose Other payment Metod.
Please help me in this how i can process
Thanks
I am using this scripts to show button in my web controller page
<% if (IsSeamless == 1) { %>
<script async
src=”https://pay.google.com/gp/p/js/pay.js”
onload=”onGooglePayLoaded()”>
<script>
/**
* Define the version of the Google Pay API referenced when creating your
* configuration
*
* @see {@link https://developers.google.com/pay/api/web/reference/request-objects#PaymentDataRequest|apiVersion in PaymentDataRequest}
*/
const baseRequest = {
apiVersion: 2,
apiVersionMinor: 0
};
const allowedCardNetworks = ["AMEX", "DISCOVER", "INTERAC", "JCB", "MASTERCARD", "VISA"];
const allowedCardAuthMethods = ["PAN_ONLY", "CRYPTOGRAM_3DS"];
const tokenizationSpecification = {
//type: 'PAYMENT_GATEWAY',
//parameters: {
// "gateway": "payu",
// "gatewayMerchantId": "134806"
//}
type: 'PAYMENT_GATEWAY',
parameters: {
'gateway': 'example',
'gatewayMerchantId': 'exampleGatewayMerchantId'
}
};
const baseCardPaymentMethod = {
type: 'CARD',
parameters: {
allowedAuthMethods: allowedCardAuthMethods,
allowedCardNetworks: allowedCardNetworks
}
};
const cardPaymentMethod = Object.assign(
{},
baseCardPaymentMethod,
{
tokenizationSpecification: tokenizationSpecification
}
);
let paymentsClient = null;
function getGoogleIsReadyToPayRequest() {
return Object.assign(
{},
baseRequest,
{
allowedPaymentMethods: [baseCardPaymentMethod]
}
);
}
function getGooglePaymentDataRequest() {
const paymentDataRequest = Object.assign({}, baseRequest);
paymentDataRequest.allowedPaymentMethods = [cardPaymentMethod];
paymentDataRequest.transactionInfo = getGoogleTransactionInfo();
paymentDataRequest.merchantInfo = {
merchantId: 'BCR2DN4T7WMLX7YI',
merchantName: 'ZainKhan.co'
};
return paymentDataRequest;
}
function getGooglePaymentsClient() {
if (paymentsClient === null) {
paymentsClient = new google.payments.api.PaymentsClient({ environment: 'TEST' });
}
console.log(paymentsClient);
return paymentsClient;
}
function onGooglePayLoaded() {
const paymentsClient = getGooglePaymentsClient();
paymentsClient.isReadyToPay(getGoogleIsReadyToPayRequest())
.then(function (response) {
if (response.result) {
addGooglePayButton();
}
})
.catch(function (err) {
console.error(err);
});
}
function addGooglePayButton() {
const paymentsClient = getGooglePaymentsClient();
const button =
paymentsClient.createButton({ onClick: onGooglePaymentButtonClicked });
document.getElementById('container').appendChild(button);
}
function getGoogleTransactionInfo() {
return {
countryCode: 'AE',
currencyCode: 'AED',
totalPriceStatus: 'FINAL',
// set to cart total
totalPrice: '10.00'
};
}
function prefetchGooglePaymentData() {
const paymentDataRequest = getGooglePaymentDataRequest();
paymentDataRequest.transactionInfo = {
totalPriceStatus: 'NOT_CURRENTLY_KNOWN',
currencyCode: 'AED'
};
const paymentsClient = getGooglePaymentsClient();
paymentsClient.prefetchPaymentData(paymentDataRequest);
}
function onGooglePaymentButtonClicked() {
const paymentDataRequest = getGooglePaymentDataRequest();
paymentDataRequest.transactionInfo = getGoogleTransactionInfo();
const paymentsClient = getGooglePaymentsClient();
paymentsClient.loadPaymentData(paymentDataRequest)
.then(function (paymentData) {
// handle the response
processPayment(paymentData);
})
.catch(function (err) {
// show error in developer console for debugging
console.error(err);
});
}
function processPayment(paymentData) {
debugger
console.log(paymentData);
// @todo pass payment token to your gateway to process payment
paymentToken = paymentData.paymentMethodData.tokenizationData.token;
}
</script>
<% } %>
zain Ul Hasan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.