0

在我的 Android 应用上使用 Google Pay 进行付款时,付款通过验证后,我会得到一个PaymentData变量,我可以从中获取一些信息,例如电子邮件、送货地址、帐单地址……

有没有办法在我的后端获取这些信息,而不发送它们以避免更改?

例如,当我使用 OAuth 执行 Google Connect 时,我得到一个令牌,它允许我向 Google 的服务器执行请求并自己检索诸如“邮件”之类的数据……这样我可以检查邮件是否被更改.

谢谢,

编辑:这是来自 Android 应用程序的代码

private void payWithGooglePay() {
    PaymentDataRequest.Builder request =
            PaymentDataRequest.newBuilder()
                    .setEmailRequired(true)
                    .setShippingAddressRequired(needShippingAddress)
                    .setTransactionInfo(
                            TransactionInfo.newBuilder()
                                    .setTotalPriceStatus(WalletConstants.TOTAL_PRICE_STATUS_FINAL)
                                    .setTotalPrice(String.valueOf(amountToPay / 100))
                                    .setCurrencyCode(currency.getCurrencyCode())
                                    .build())
                    .addAllowedPaymentMethod(WalletConstants.PAYMENT_METHOD_CARD)
                    .addAllowedPaymentMethod(WalletConstants.PAYMENT_METHOD_TOKENIZED_CARD)
                    .setCardRequirements(
                            CardRequirements.newBuilder()
                                    .setBillingAddressRequired(needBillingAddress)
                                    .addAllowedCardNetworks(Arrays.asList(
                                            WalletConstants.CARD_NETWORK_VISA,
                                            WalletConstants.CARD_NETWORK_MASTERCARD))
                                    .build());

    PaymentMethodTokenizationParameters tokenizationParameters =
            PaymentMethodTokenizationParameters.newBuilder()
                    .setPaymentMethodTokenizationType(WalletConstants.PAYMENT_METHOD_TOKENIZATION_TYPE_PAYMENT_GATEWAY)
                    .addParameter("gateway", "stripe")
                    .addParameter("stripe:publishableKey", liveMode ? getString(R.string.stripe_live_pk_key) : getString(R.string.stripe_test_pk_key))
                    .addParameter("stripe:version", "5.1.0")
                    .build();

    PaymentDataRequest paymentDataRequest = request
            .setPaymentMethodTokenizationParameters(tokenizationParameters)
            .build();

    if (paymentDataRequest == null) {
        return;
    }

    AutoResolveHelper.resolveTask(paymentsClient.loadPaymentData(paymentDataRequest),
            getActivity(), ProgressViewActivity.PAYMENT_WITH_GOOGLE_PAY_REQUEST_CODE);
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    switch (requestCode) {
        case ProgressViewActivity.PAYMENT_WITH_GOOGLE_PAY_REQUEST_CODE:
            if (resultCode == Activity.RESULT_OK) {
                PaymentData paymentData = PaymentData.getFromIntent(data);
                Log.d("MyGooglePay", "Google transaction ID: " + paymentData.getGoogleTransactionId());
                Log.d("MyGooglePay", "mail: " + paymentData.getEmail());
                Log.d("MyGooglePay", "token:" + paymentData.getPaymentMethodToken().getToken());
                Log.d("MyGooglePay", "extra: " + (paymentData.getExtraData() != null ? paymentData.getExtraData().toString() : ""));

                CardInfo cardInfo = paymentData.getCardInfo();
                String description = cardInfo.getCardDescription();
                Log.d("MyGooglePay", description);

                UserAddress shippingAddress = paymentData.getShippingAddress();
                UserAddress billingAddress = cardInfo.getBillingAddress();
                Log.d("MyGooglePay", "shipping: " + shippingAddress);
                Log.d("MyGooglePay", "billing: " + billingAddress);

                String rawToken = paymentData.getPaymentMethodToken().getToken();

                // Now that you have a Stripe token object, charge that by using the id
                Token stripeToken = Token.fromString(rawToken);
                if (stripeToken != null) {
                    // This chargeToken function is a call to your own server, which should then connect
                    // to Stripe's API to finish the charge.
                    Log.d("MyGooglePay", stripeToken.getCard().toJson().toString());
                    //sendFinalRequestAndGoToNext(stripeToken.getId());
                }
                break;
            }
    }
}

为了清楚起见,我想要的是直接从我的后端获取 PaymentData,而不是从应用程序发送到我的后端,以避免更改。

4

1 回答 1

1

这种与处理器和网关分离的行为是有意的,它可以最大限度地提高所有相关代理的兼容性。

从 Google Pay 检索到的敏感信息经过加密,只有付款处理方才能显示有效载荷的内容。篡改中间的内容只会使有效负载无效。

为了能够访问该内容,您还可以选择使用DIRECT集成来实施 Google Pay 。话虽如此,请注意支付处理涉及复杂性和对 PCI DSS 等监管条款的合规性,因此,除非另有必要,否则不推荐。

于 2019-01-06T14:38:20.463 回答