Skip to content

Commit

Permalink
add native assets for google-pay (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
bradmartin authored Mar 24, 2021
1 parent 586d077 commit 95af1ba
Show file tree
Hide file tree
Showing 127 changed files with 4,042 additions and 4 deletions.
23 changes: 21 additions & 2 deletions packages/google-pay/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@
ns plugin add @nativescript/google-pay
```

Before you get started, review the following prerequisites:

- Install the Google Play services version 18.1.2 or greater (this should be installed on most Android devices by default).
- [Install the Google Pay app and add a payment method.](https://support.google.com/pay/answer/7625139?visit_id=637522080332272855-2861547127&rd=1)
- [Add a payment method to Google](https://support.google.com/pay/answer/7625139).
- Adhere to the [Google Pay API Acceptable Use Policy](https://payments.developers.google.com/terms/aup) and the [Google Play developer policy](https://support.google.com/googleplay/android-developer/answer/9858738).

### Important Note

When moving to production and using a payment provider you will need a valid payment token. You can view the configuration for a number of [providers in the Google documentation.](https://developers.google.com/pay/api/android/guides/tutorial#tokenization)
During development you can use the example below for the gateway token configuration when creating a payment request.

```ts
parameters: {
gateway: 'example', // in production replace with your gateway provider
gatewayMerchantId: 'exampleGatewayMerchantId' // in production replace with your gateway provider merchant ID
}
```

## Usage

```xml
Expand Down Expand Up @@ -110,8 +129,8 @@ async onGooglePayTap(args) {
tokenizationSpecification: {
type: TokenizationSpecificationType.PAYMENT_GATEWAY,
parameters: {
gateway: 'example',
gatewayMerchantId: EXAMPLE_MERCHANT_ID
gateway: 'example', // in production replace with your gateway provider
gatewayMerchantId: 'exampleGatewayMerchantId' // in production replace with your gateway provider merchant ID
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions packages/google-pay/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@nativescript/google-pay",
"version": "1.0.0",
"description": "Add a plugin description",
"version": "0.1.0",
"description": "Plugin that provides Google Pay support for NativeScript Android applications.",
"main": "index",
"typings": "index.d.ts",
"nativescript": {
Expand Down
6 changes: 6 additions & 0 deletions packages/google-pay/platforms/android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application>
<meta-data android:name="com.google.android.gms.wallet.api.enabled" android:value="true" />
</application>
</manifest>
4 changes: 4 additions & 0 deletions packages/google-pay/platforms/android/include.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dependencies {
implementation 'com.google.android.gms:play-services-wallet:18.1.2'
implementation 'com.android.support:appcompat-v7:24.1.1'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="141dp"
android:height="17dp"
android:viewportWidth="141"
android:viewportHeight="17">
<path
android:pathData="M80.494,11.57C79.663,11.57 79.059,11.491 78.681,11.332C78.303,11.173 78.049,10.921 77.918,10.576C77.61,10.996 77.232,11.267 76.784,11.388C76.336,11.509 75.781,11.57 75.118,11.57C74.614,11.57 74.159,11.526 73.753,11.437C73.347,11.348 72.995,11.176 72.696,10.919C72.397,10.662 72.164,10.287 71.996,9.792C71.66,9.969 71.31,10.161 70.946,10.366C70.582,10.571 70.174,10.765 69.721,10.947C69.268,11.129 68.75,11.278 68.167,11.395C67.584,11.512 66.905,11.57 66.13,11.57C66.125,11.57 66.121,11.57 66.116,11.57C65.724,11.57 65.36,11.493 65.024,11.339C64.688,11.185 64.417,10.931 64.212,10.576C64.007,10.865 63.699,11.106 63.288,11.297C62.877,11.488 62.322,11.584 61.622,11.584C61.137,11.584 60.661,11.523 60.194,11.402C59.727,11.281 59.331,11.108 59.004,10.884L59.606,9.68C59.839,9.82 60.122,9.939 60.453,10.037C60.784,10.135 61.146,10.184 61.538,10.184C62.21,10.184 62.679,10.086 62.945,9.89C63.211,9.694 63.344,9.433 63.344,9.106C63.344,8.854 63.253,8.527 63.071,8.126C62.889,7.725 62.658,7.295 62.378,6.838C62.098,6.381 61.813,5.937 61.524,5.508L62.686,4.738C63.246,5.569 63.699,6.336 64.044,7.041C64.389,7.746 64.637,8.364 64.786,8.896C64.898,9.269 65.036,9.549 65.199,9.736C65.362,9.923 65.537,10.044 65.724,10.1C65.911,10.156 66.088,10.184 66.256,10.184C67.236,10.184 68.183,10.051 69.098,9.785C70.013,9.519 70.843,9.129 71.59,8.616C71.217,8.317 70.766,8.077 70.239,7.895C69.712,7.713 69.135,7.622 68.51,7.622C68.081,7.622 67.637,7.673 67.18,7.776L66.942,6.46C67.203,6.385 67.465,6.329 67.726,6.292C67.987,6.255 68.239,6.236 68.482,6.236C69.098,6.236 69.644,6.322 70.12,6.495C70.596,6.668 71.025,6.864 71.408,7.083C71.791,7.302 72.155,7.498 72.5,7.671C72.845,7.844 73.195,7.93 73.55,7.93L73.914,7.93L74.04,9.19C73.863,9.19 73.69,9.204 73.522,9.232C73.354,9.26 73.195,9.297 73.046,9.344C73.251,9.68 73.524,9.904 73.865,10.016C74.206,10.128 74.67,10.184 75.258,10.184C75.687,10.184 76.028,10.149 76.28,10.079C76.532,10.009 76.73,9.874 76.875,9.673C77.02,9.472 77.141,9.181 77.239,8.798C77.337,8.415 77.442,7.907 77.554,7.272L78.87,7.51C78.814,7.753 78.756,8.033 78.695,8.35C78.634,8.667 78.604,8.943 78.604,9.176C78.604,9.381 78.639,9.559 78.709,9.708C78.779,9.857 78.954,9.974 79.234,10.058C79.514,10.142 79.981,10.184 80.634,10.184C80.654,10.184 80.674,10.184 80.694,10.185C80.993,10.184 81.778,10.161 81.969,10.114C82.16,10.067 82.319,9.958 82.445,9.785C82.571,9.612 82.688,9.337 82.795,8.959C82.902,8.581 83.026,8.065 83.166,7.412L84.44,7.72C84.393,7.953 84.335,8.229 84.265,8.546C84.195,8.863 84.16,9.153 84.16,9.414C84.16,9.647 84.246,9.834 84.419,9.974C84.592,10.114 84.911,10.184 85.378,10.184C85.639,10.184 85.859,10.161 86.036,10.114C86.213,10.067 86.363,9.953 86.484,9.771C86.605,9.589 86.713,9.304 86.806,8.917C86.899,8.53 86.997,7.995 87.1,7.314L88.402,7.538C88.365,7.715 88.327,7.925 88.29,8.168C88.253,8.411 88.22,8.649 88.192,8.882C88.164,9.115 88.15,9.307 88.15,9.456C88.15,9.587 88.18,9.708 88.241,9.82C88.302,9.932 88.423,10.021 88.605,10.086C88.787,10.151 89.06,10.184 89.424,10.184C89.825,10.184 90.143,10.105 90.376,9.946C90.609,9.787 90.726,9.484 90.726,9.036C90.726,8.681 90.647,8.233 90.488,7.692C90.329,7.151 90.143,6.6 89.928,6.04L91.314,5.578C91.445,5.905 91.566,6.271 91.678,6.677C91.79,7.083 91.881,7.48 91.951,7.867C92.021,8.254 92.056,8.593 92.056,8.882C92.056,9.778 91.82,10.45 91.349,10.898C90.878,11.346 90.245,11.57 89.452,11.57C88.901,11.57 88.467,11.5 88.15,11.36C87.833,11.22 87.609,10.991 87.478,10.674C87.235,11.057 86.948,11.302 86.617,11.409C86.286,11.516 85.831,11.57 85.252,11.57C85.037,11.57 84.816,11.547 84.587,11.5C84.358,11.453 84.144,11.362 83.943,11.227C83.742,11.092 83.581,10.889 83.46,10.618C83.199,11.029 82.874,11.29 82.487,11.402C82.1,11.514 80.765,11.57 80.494,11.57ZM96.942,11.57C96.149,11.57 95.544,11.484 95.129,11.311C94.714,11.138 94.424,10.872 94.261,10.513C94.098,10.154 94.007,9.689 93.988,9.12L93.708,1.434L95.094,1.434L95.388,8.532C95.407,8.98 95.451,9.323 95.521,9.561C95.591,9.799 95.743,9.962 95.976,10.051C96.208,10.139 97.313,10.177 97.682,10.184C98.335,10.184 98.797,10.114 99.068,9.974C99.339,9.834 99.474,9.517 99.474,9.022C99.474,8.779 99.437,8.49 99.362,8.154C99.287,7.818 99.192,7.466 99.075,7.097C98.958,6.728 98.835,6.367 98.704,6.012L100.076,5.564C100.197,5.872 100.312,6.222 100.419,6.614C100.526,7.006 100.617,7.4 100.692,7.797C100.767,8.194 100.804,8.551 100.804,8.868C100.804,9.559 100.676,10.1 100.419,10.492C100.162,10.884 99.791,11.162 99.306,11.325C98.821,11.488 98.233,11.57 97.542,11.57C97.259,11.576 96.958,11.57 96.942,11.57ZM121.216,10.184C121.515,10.184 121.76,10.161 121.951,10.114C122.142,10.067 122.301,9.958 122.427,9.785C122.553,9.612 122.67,9.337 122.777,8.959C122.884,8.581 123.008,8.065 123.148,7.412L124.422,7.72C124.375,7.953 124.317,8.229 124.247,8.546C124.177,8.863 124.142,9.153 124.142,9.414C124.142,9.647 124.228,9.834 124.401,9.974C124.574,10.114 124.893,10.184 125.36,10.184C125.621,10.184 125.841,10.161 126.018,10.114C126.195,10.067 126.345,9.953 126.466,9.771C126.587,9.589 126.695,9.304 126.788,8.917C126.881,8.53 126.979,7.995 127.082,7.314L128.384,7.538C128.347,7.715 128.309,7.925 128.272,8.168C128.235,8.411 128.202,8.649 128.174,8.882C128.146,9.115 128.132,9.307 128.132,9.456C128.132,9.587 128.162,9.708 128.223,9.82C128.284,9.932 128.405,10.021 128.587,10.086C128.769,10.151 129.042,10.184 129.406,10.184C129.863,10.184 130.195,10.088 130.4,9.897C130.605,9.706 130.708,9.414 130.708,9.022C130.708,8.695 130.699,8.338 130.68,7.951C130.661,7.564 130.615,7.076 130.54,6.488L131.786,6.404C131.842,7.169 131.91,7.799 131.989,8.294C132.068,8.789 132.176,9.174 132.311,9.449C132.446,9.724 132.633,9.916 132.871,10.023C133.106,10.129 133.416,10.183 133.802,10.184C134.297,10.184 134.649,10.135 134.859,10.037C135.069,9.939 135.193,9.762 135.23,9.505C135.267,9.248 135.277,8.882 135.258,8.406L134.992,1.434L136.378,1.434L136.658,8.364C136.677,8.877 136.658,9.332 136.602,9.729C136.546,10.126 136.415,10.462 136.21,10.737C136.005,11.012 135.699,11.22 135.293,11.36C134.887,11.5 134.348,11.57 133.676,11.57C133.163,11.57 132.715,11.46 132.332,11.241C131.949,11.022 131.665,10.702 131.478,10.282C131.282,10.795 130.993,11.138 130.61,11.311C130.227,11.484 129.784,11.57 129.28,11.57C128.804,11.57 128.412,11.5 128.104,11.36C127.796,11.22 127.577,10.996 127.446,10.688C127.213,11.061 126.928,11.302 126.592,11.409C126.256,11.516 125.794,11.57 125.206,11.57C124.991,11.57 124.772,11.547 124.548,11.5C124.324,11.453 124.114,11.362 123.918,11.227C123.722,11.092 123.563,10.889 123.442,10.618C123.181,11.029 122.856,11.29 122.469,11.402C122.086,11.513 121.628,11.569 121.094,11.57C120.828,11.583 120.522,11.583 120.176,11.57C119.812,11.57 119.506,11.514 119.259,11.402C119.012,11.29 118.813,11.141 118.664,10.954C118.561,11.458 118.363,11.918 118.069,12.333C117.775,12.748 117.427,13.117 117.026,13.439C116.625,13.761 116.207,14.032 115.773,14.251C115.339,14.47 114.921,14.636 114.52,14.748L114.016,13.488C115.267,13.059 116.16,12.527 116.697,11.892C117.234,11.257 117.502,10.599 117.502,9.918C117.502,9.479 117.404,9.027 117.208,8.56C117.012,8.093 116.793,7.641 116.55,7.202L117.81,6.572C118.071,7.057 118.288,7.533 118.461,8C118.634,8.467 118.767,8.84 118.86,9.12C118.991,9.54 119.163,9.822 119.378,9.967C119.593,10.112 119.905,10.184 120.316,10.184L121.216,10.184ZM138.702,11.5L138.422,1.434L139.808,1.434L140.088,11.5L138.702,11.5ZM127.446,3.59C127.241,3.59 127.066,3.518 126.921,3.373C126.776,3.228 126.704,3.053 126.704,2.848C126.704,2.633 126.776,2.454 126.921,2.309C127.066,2.164 127.241,2.092 127.446,2.092C127.651,2.092 127.826,2.164 127.971,2.309C128.116,2.454 128.188,2.633 128.188,2.848C128.188,3.053 128.116,3.228 127.971,3.373C127.826,3.518 127.651,3.59 127.446,3.59ZM126.452,5.214C126.237,5.214 126.058,5.142 125.913,4.997C125.768,4.852 125.696,4.677 125.696,4.472C125.696,4.267 125.768,4.092 125.913,3.947C126.058,3.802 126.237,3.73 126.452,3.73C126.657,3.73 126.832,3.802 126.977,3.947C127.122,4.092 127.194,4.267 127.194,4.472C127.194,4.677 127.122,4.852 126.977,4.997C126.832,5.142 126.657,5.214 126.452,5.214ZM128.44,5.214C128.225,5.214 128.046,5.142 127.901,4.997C127.756,4.852 127.684,4.677 127.684,4.472C127.684,4.267 127.756,4.092 127.901,3.947C128.046,3.802 128.225,3.73 128.44,3.73C128.645,3.73 128.818,3.802 128.958,3.947C129.098,4.092 129.168,4.267 129.168,4.472C129.168,4.677 129.098,4.852 128.958,4.997C128.818,5.142 128.645,5.214 128.44,5.214ZM112.518,11.5L112.238,1.434L113.624,1.434L113.904,11.5L112.518,11.5ZM105.91,12.312L105.504,11.01C106.027,10.889 106.619,10.725 107.282,10.52C106.965,10.361 106.685,10.112 106.442,9.771C106.199,9.43 106.078,9.031 106.078,8.574C106.078,8.089 106.19,7.669 106.414,7.314C106.638,6.959 106.939,6.684 107.317,6.488C107.695,6.292 108.108,6.194 108.556,6.194C108.752,6.194 108.948,6.21 109.144,6.243C109.34,6.276 109.531,6.32 109.718,6.376L109.508,7.65C109.359,7.613 109.205,7.582 109.046,7.559C108.887,7.536 108.747,7.524 108.626,7.524C108.243,7.524 107.949,7.631 107.744,7.846C107.539,8.061 107.436,8.322 107.436,8.63C107.436,8.985 107.562,9.293 107.814,9.554C108.066,9.815 108.355,9.988 108.682,10.072C108.953,9.969 109.226,9.869 109.501,9.771C109.776,9.673 110.045,9.568 110.306,9.456L110.824,10.702C110.525,10.823 110.166,10.961 109.746,11.115C109.326,11.269 108.883,11.423 108.416,11.577C107.949,11.731 107.499,11.873 107.065,12.004C106.631,12.135 106.246,12.237 105.91,12.312ZM99.11,14.356C98.895,14.356 98.711,14.281 98.557,14.132C98.403,13.983 98.326,13.801 98.326,13.586C98.326,13.381 98.403,13.199 98.557,13.04C98.711,12.881 98.895,12.802 99.11,12.802C99.315,12.802 99.495,12.881 99.649,13.04C99.803,13.199 99.88,13.381 99.88,13.586C99.88,13.801 99.803,13.983 99.649,14.132C99.495,14.281 99.315,14.356 99.11,14.356ZM79.08,5.886C78.865,5.886 78.681,5.809 78.527,5.655C78.373,5.501 78.296,5.321 78.296,5.116C78.296,4.911 78.373,4.729 78.527,4.57C78.681,4.411 78.865,4.332 79.08,4.332C79.285,4.332 79.465,4.411 79.619,4.57C79.773,4.729 79.85,4.911 79.85,5.116C79.85,5.321 79.773,5.501 79.619,5.655C79.465,5.809 79.285,5.886 79.08,5.886ZM77.008,5.886C76.793,5.886 76.611,5.809 76.462,5.655C76.313,5.501 76.238,5.321 76.238,5.116C76.238,4.901 76.313,4.717 76.462,4.563C76.611,4.409 76.793,4.332 77.008,4.332C77.213,4.332 77.393,4.409 77.547,4.563C77.701,4.717 77.778,4.901 77.778,5.116C77.778,5.321 77.701,5.501 77.547,5.655C77.393,5.809 77.213,5.886 77.008,5.886ZM68.384,4.78C68.16,4.78 67.971,4.705 67.817,4.556C67.663,4.407 67.586,4.22 67.586,3.996C67.586,3.781 67.663,3.595 67.817,3.436C67.971,3.277 68.16,3.198 68.384,3.198C68.599,3.198 68.783,3.277 68.937,3.436C69.091,3.595 69.168,3.781 69.168,3.996C69.168,4.22 69.091,4.407 68.937,4.556C68.783,4.705 68.599,4.78 68.384,4.78ZM56.274,11.5L55.994,1.434L57.38,1.434L57.66,11.5L56.274,11.5ZM49.022,17.002C48.854,16.377 48.714,15.772 48.602,15.189C48.49,14.606 48.406,14.074 48.35,13.593C48.294,13.112 48.266,12.713 48.266,12.396C48.266,11.799 48.371,11.304 48.581,10.912C48.791,10.52 49.071,10.21 49.421,9.981C49.771,9.752 50.161,9.594 50.59,9.505C51.019,9.416 51.458,9.381 51.906,9.4C52.354,9.419 52.774,9.47 53.166,9.554C53.194,9.143 53.152,8.765 53.04,8.42C52.928,8.075 52.755,7.797 52.522,7.587C52.289,7.377 52.013,7.272 51.696,7.272C51.052,7.272 50.492,7.715 50.016,8.602L48.966,8.014C49.321,7.239 49.752,6.693 50.261,6.376C50.77,6.059 51.276,5.9 51.78,5.9C52.284,5.9 52.709,6.005 53.054,6.215C53.399,6.425 53.677,6.7 53.887,7.041C54.097,7.382 54.251,7.743 54.349,8.126C54.447,8.509 54.496,8.877 54.496,9.232C54.496,9.605 54.435,9.976 54.314,10.345C54.193,10.714 54.081,10.977 53.978,11.136C53.129,10.893 52.38,10.763 51.731,10.744C51.082,10.725 50.574,10.851 50.205,11.122C49.836,11.393 49.652,11.841 49.652,12.466C49.652,12.811 49.68,13.217 49.736,13.684C49.792,14.151 49.869,14.641 49.967,15.154C50.065,15.667 50.184,16.171 50.324,16.666L49.022,17.002Z"
android:fillColor="#3C4043"
android:fillType="nonZero"/>
<path
android:pathData="M18.628,2.742L18.628,6.598 21.063,6.598C21.643,6.598 22.122,6.407 22.502,6.027 22.891,5.647 23.086,5.194 23.086,4.669 23.086,4.155 22.891,3.708 22.502,3.327 22.122,2.936 21.643,2.741 21.063,2.741L18.628,2.741 18.628,2.742zM18.628,7.955L18.628,12.428 17.173,12.428 17.173,1.384 21.031,1.384C22.011,1.384 22.843,1.703 23.529,2.341 24.224,2.978 24.572,3.754 24.572,4.669 24.572,5.605 24.224,6.387 23.529,7.014 22.854,7.641 22.021,7.954 21.031,7.954L18.628,7.954 18.628,7.955zM26.042,10.115C26.042,10.485 26.203,10.793 26.524,11.04 26.846,11.287 27.223,11.41 27.655,11.41 28.266,11.41 28.811,11.189 29.291,10.748 29.77,10.305 30.01,9.786 30.01,9.19 29.556,8.84 28.924,8.666 28.113,8.666 27.522,8.666 27.029,8.805 26.635,9.083 26.24,9.36 26.042,9.703 26.042,10.115M27.924,4.623C28.999,4.623 29.847,4.904 30.47,5.464 31.091,6.025 31.402,6.794 31.402,7.77L31.402,12.428 30.011,12.428 30.011,11.38 29.947,11.38C29.347,12.243 28.545,12.675 27.544,12.675 26.691,12.675 25.976,12.428 25.402,11.935 24.828,11.441 24.541,10.824 24.541,10.084 24.541,9.302 24.843,8.681 25.449,8.218 26.056,7.755 26.864,7.523 27.876,7.523 28.739,7.523 29.451,7.678 30.01,7.986L30.01,7.662C30.01,7.168 29.809,6.749 29.409,6.405 29.008,6.06 28.54,5.888 28.002,5.888 27.19,5.888 26.548,6.222 26.074,6.891L24.793,6.104C25.499,5.117 26.542,4.623 27.924,4.623"
android:fillColor="#5F6368"
android:fillType="nonZero"/>
<path
android:pathData="M39.385,4.87l-4.854,10.89l-1.501,0l1.802,-3.811l-3.194,-7.079l1.581,0l2.308,5.429l0.032,0l2.245,-5.429z"
android:fillColor="#5F6368"
android:fillType="evenOdd"/>
<path
android:pathData="M12.75,6.991C12.75,6.544 12.712,6.113 12.638,5.7L6.504,5.7L6.504,8.145L10.018,8.145C9.867,8.941 9.411,9.619 8.719,10.073L8.719,11.661L10.815,11.661C12.043,10.555 12.75,8.922 12.75,6.991"
android:fillColor="#4285F4"
android:fillType="evenOdd"/>
<path
android:pathData="M6.504,13.192C8.26,13.192 9.738,12.63 10.815,11.661L8.719,10.073C8.135,10.457 7.383,10.68 6.504,10.68C4.808,10.68 3.368,9.565 2.853,8.061L0.693,8.061L0.693,9.696C1.763,11.769 3.963,13.192 6.504,13.192"
android:fillColor="#34A853"
android:fillType="evenOdd"/>
<path
android:pathData="M2.853,8.061C2.721,7.677 2.649,7.268 2.649,6.846C2.649,6.424 2.721,6.015 2.853,5.632L2.853,3.997L0.693,3.997C0.25,4.853 0,5.821 0,6.846C0,7.871 0.25,8.839 0.693,9.696L2.853,8.061Z"
android:fillColor="#FABB05"
android:fillType="evenOdd"/>
<path
android:pathData="M6.504,3.012C7.463,3.012 8.322,3.334 9,3.964L9,3.965L10.856,2.154C9.729,1.129 8.259,0.5 6.504,0.5C3.963,0.5 1.763,1.923 0.693,3.997L2.853,5.632C3.368,4.128 4.808,3.012 6.504,3.012"
android:fillColor="#E94235"
android:fillType="evenOdd"/>
</vector>
Loading

0 comments on commit 95af1ba

Please sign in to comment.