{"_id":"@bkamenov/cordova-plugin-google-pay","_rev":"1-37ec65f4201a78e135b0315f39b93eb0","name":"@bkamenov/cordova-plugin-google-pay","description":"Cordova plugin for GooglePay","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@bkamenov/cordova-plugin-google-pay","version":"1.0.0","keywords":["ecosystem:cordova","cordova-android","google","pay","payments"],"author":{"name":"Boris Kamenov"},"license":"Apache 2.0","_id":"@bkamenov/cordova-plugin-google-pay@1.0.0","maintainers":[{"name":"bkamenov","email":"boriskamenov@abv.bg"}],"homepage":"https://github.com/bkamenov/cordova-plugin-google-pay","bugs":{"url":"https://github.com/bkamenov/cordova-plugin-google-pay/issues"},"dist":{"shasum":"6420cb1a61b16b70673d7f15fd6390830b76701f","tarball":"https://registry.npmjs.org/@bkamenov/cordova-plugin-google-pay/-/cordova-plugin-google-pay-1.0.0.tgz","fileCount":6,"integrity":"sha512-H74WddwXGXhTKSu7dy19DFp+HEQFLBxBQhdj5Srlea987WZeuqITTWNaX6wztvfnQiYYcSe6culgS+/AojfGbA==","signatures":[{"sig":"MEUCIB7bDovKEH1Lj4E8nGdsqzzDBtW+rLdZ8DYqSOoOX5VIAiEA3ppAxJifXMtGEEnyqz7wu2SOrT+YOnHMdn7YZWQ0auU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13038},"cordova":{"id":"cordova-plugin-google-pay","platforms":["android"]},"engines":{"cordova":">=9.0.0"},"gitHead":"1db8bd3f92a2ad378a197a8161ea93b30985b8df","_npmUser":{"name":"bkamenov","email":"boriskamenov@abv.bg"},"repository":{"url":"git+https://github.com/bkamenov/cordova-plugin-google-pay.git","type":"git"},"_npmVersion":"10.3.0","description":"Cordova plugin for GooglePay","directories":{},"_nodeVersion":"20.11.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/cordova-plugin-google-pay_1.0.0_1716992316002_0.203972152805304","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"@bkamenov/cordova-plugin-google-pay","version":"1.0.1","description":"Cordova plugin for GooglePay","cordova":{"id":"cordova-plugin-google-pay","platforms":["android"]},"keywords":["ecosystem:cordova","cordova-android","google","pay","payments"],"engines":{"cordova":">=9.0.0"},"author":{"name":"Boris Kamenov"},"license":"Apache 2.0","repository":{"type":"git","url":"git+https://github.com/bkamenov/cordova-plugin-google-pay.git"},"bugs":{"url":"https://github.com/bkamenov/cordova-plugin-google-pay/issues"},"homepage":"https://github.com/bkamenov/cordova-plugin-google-pay","_id":"@bkamenov/cordova-plugin-google-pay@1.0.1","gitHead":"8044a7d7068b4ecad2e3fd412f0fa3f02d2dbd55","_nodeVersion":"20.11.0","_npmVersion":"10.3.0","dist":{"integrity":"sha512-v2LGEZpc8bIHJ5ocaIMkntC4kNxG66jdSX6iQa76JAUMmGStBi0KrGLwZhb/WULg5jwtM23cLmzVkoU9B+XDig==","shasum":"ff0597eb6e2aa987e0695417a1b95b9f693efd28","tarball":"https://registry.npmjs.org/@bkamenov/cordova-plugin-google-pay/-/cordova-plugin-google-pay-1.0.1.tgz","fileCount":6,"unpackedSize":13043,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAGrJta0bLXdM5L37S70rySzmTyR3i1BnAHi9l4zxt53AiBPu1sFKxwzVbRmso58+xzeMlmMr1IxKFbvc/lWgUVhXw=="}]},"_npmUser":{"name":"bkamenov","email":"boriskamenov@abv.bg"},"directories":{},"maintainers":[{"name":"bkamenov","email":"boriskamenov@abv.bg"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cordova-plugin-google-pay_1.0.1_1716992748346_0.9105780252637927"},"_hasShrinkwrap":false}},"time":{"created":"2024-05-29T14:18:35.903Z","modified":"2024-05-29T14:25:48.671Z","1.0.0":"2024-05-29T14:18:36.155Z","1.0.1":"2024-05-29T14:25:48.491Z"},"maintainers":[{"name":"bkamenov","email":"boriskamenov@abv.bg"}],"author":{"name":"Boris Kamenov"},"repository":{"type":"git","url":"git+https://github.com/bkamenov/cordova-plugin-google-pay.git"},"keywords":["ecosystem:cordova","cordova-android","google","pay","payments"],"license":"Apache 2.0","homepage":"https://github.com/bkamenov/cordova-plugin-google-pay","bugs":{"url":"https://github.com/bkamenov/cordova-plugin-google-pay/issues"},"readme":"An Android only plugin for processing Google Pay payments from your app.\n\n### Installation:\n\nFor stable relases type:\n\n```shell\ncordova plugin add @bkamenov/cordova-plugin-google-pay\n```\n\nFor latest releases type:\n\n```shell\ncordova plugin add https://github.com/bkamenov/cordova-plugin-google-pay\n```\n\nAfter install, the plugin will be using the **TEST** environment of GooglePay.\n\nTo make it more obvious what environment you are currently using edit your app's **config.xml** as follows:\n\nFor **PRODUCTION**:\n\n```xml\n<platform name=\"android\">\n    ...\n    <preference name=\"GooglePayEnvironment\" value=\"PRODUCTION\"/>\n</platform>\n```\n\nFor **TEST**:\n\n```xml\n<platform name=\"android\">\n    ...\n    <preference name=\"GooglePayEnvironment\" value=\"TEST\"/>\n</platform>\n```\n\n### Usage:\n\n```js\n//You can adjust it as you wish (see google.payments.api.PaymentDataRequest)\nconst paymentDataRequest = {\n  apiVersion: 2,\n  apiVersionMinor: 0,\n  allowedPaymentMethods: [\n    {\n      type: 'CARD',\n      parameters: {\n        allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'],\n        allowedCardNetworks: ['AMEX', 'MASTERCARD', 'VISA']\n      },\n      tokenizationSpecification: {\n        type: 'PAYMENT_GATEWAY',\n        parameters: {\n          gateway: 'example', //This is your payment service provider e.g. \"stripe\"\n          gatewayMerchantId: 'exampleGatewayMerchantId' //Your merchant ID within \"stripe\n        }\n      }\n    }\n  ],\n  merchantInfo: {\n    //merchantId: '01234567890123456789', //Your Google merchant ID. Uncomment in PRODUCTION with real ID.\n    merchantName: 'Example Merchant' //Your Google merchant name\n  },\n  transactionInfo: {\n    totalPriceStatus: 'FINAL',\n    totalPrice: '12.34',\n    currencyCode: 'USD',\n    countryCode: 'US'\n  }\n};\n\n//Just make a copy of some portions of the above request (see google.payments.api.IsReadyToPayRequest)\nconst canMakePaymentRequest = {\n  apiVersion: paymentDataRequest.apiVersion,\n  apiVersionMinor: paymentDataRequest.apiVersionMinor,\n  allowedPaymentMethods: [\n    {\n      type: paymentDataRequest.allowedPaymentMethods[0].type,\n      parameters: {\n        allowedCardNetworks: paymentDataRequest.allowedPaymentMethods[0].parameters.allowedCardNetworks,\n        allowedAuthMethods: paymentDataRequest.allowedPaymentMethods[0].parameters.allowedAuthMethods\n      }\n    }\n  ]\n};\n\n//Call this when you want to display the button.\ncordova.plugins.GooglePayPlugin.canMakePayment(canMakePaymentRequest,\n(result) => {\n  if(result.canMakePayments) {\n\n    const gpayButton = document.getElementById(\"myGooglePayButton\");\n    if(!gpayButton)\n      return; //This should not happen.\n\n     gpayButton.onclick = () => {\n      cordova.plugins.GooglePayPlugin.requestPayment(paymentDataRequest,\n      (paymentData) {\n        //Pass this to the payment gateway (e.g. your backend) and from there to the payment service provider\n        const paymentToken = paymentData.paymentMethodData.tokenizationData.token;\n        //console.log(JSON.stringify(paymentData)); //Uncomment to take a look what is inside\n        //...or see google.payments.api.PaymentData\n      },\n      (error) => {\n        if(error === \"Payment cancelled\") {\n          return; //Payment was cancelled\n        }\n\n        //Show to the user that there was a payment problem\n        ...\n\n        console.error(\"There was an error while processing your payment. Details: \" + error);\n      });\n    };\n\n    //Make your button visible\n    gpayButton.style.visibility = \"visible\";\n  }\n  else {\n    //Show that this device does not support the desired payment methods.\n    ...\n  }\n},\n(error) => {\n  console.error(\"An error occured while chcking if payment methods are supported by GooglePay. Details: \" + error);\n});\n\n\n```\n\n```html\n...\n<button id=\"myGooglePayButton\" style=\"visibility:hidden\">Place order</button>\n...\n```\n","readmeFilename":"README.md"}