· 6 years ago · May 19, 2019, 06:42 PM
1GooglePayRequest googleRequest = new GooglePayRequest("alias", "secret_key", "terminalId", "EUR","IT", 1, "Merchant Name", "CODTRANS"+System.currentTimeMillis());
2//Imposto ambiente
3googleRequest.setEnvironment(EnvironmentUtils.Environment.TEST);
4// Imposto parametri di fatturazione
5JSONObject billingParameters = new JSONObject();
6try {
7billingParameters.put("format", "FULL");
8billingParameters.put("format", "FULL");
9billingParameters.put("phoneNumberRequired", true);
10} catch (JSONException e) {
11e.printStackTrace();
12}
13googleRequest.setBillingParameters(billingParameters);
14buttonGooglePay.setOnClickListener(new View.OnClickListener() {
15@Override
16public void onClick(View v) {
17payWithGoogle(mContext, googleRequest, new GooglePayCallback() {
18@Override
19public void onCancel() {
20Log.i("GOOGLEPAY", "CANCEL");
21}
22@Override
23public void onSuccess(ApiGooglePayResponse response) {
24Log.i("GOOGLEPAY", "OK");
25}
26@Override
27public void onError(ApiErrorResponse error) {
28Log.e("GOOGLEPAY", "ERROR" + error.getError().getMessage());
29}
30});
31}});