# Google Pay API

当你想在你自己的网站上通过使用Google Pay™时，你可以参阅本文档的内容以便集成Google支付。

### 1.流程概览

调用支付接口进行支付，需要重点解决3ds场景

```
customermerchantUseePay ServerIssuer点击支付pay requestpay request返回支付结果resultCode=succeed/failed 同步通知到redirectUrl地址展示支付结果异步通知notifyUrl支付结果customermerchantUseePay ServerIssuer
```

如果返回的参数中的ResultCode = challenge 或者 ResultCode = gather，则代表当前交易触发了3DS挑战，关于3DS挑战的后续处理，请参考：[UseePay 3DS流程](https://app.apifox.com/project/2772040)

### 2.详细流程

#### 1.生成生成Useepay 交易信息

交易信息参数详见[交易参数说明](https://useepay.gitbook.io/developer/reference/api-reference-xin-yong-ka/parameter-description#userinfo)

注：**paymentMethod**应设置为”googlepay“

#### 2.生成Google Pay PaymentData信息

关于网站集成Google Pay的更多信息，请参考：

[Google Pay 网站开发者文档](https://developers.google.com/pay/api/web?hl=zh-cn)

[Google Pay 网站集成核对清单](https://developers.google.com/pay/api/web/guides/test-and-deploy/integration-checklist?hl=zh-cn)

[Google Pay 网站品牌推广指南](https://developers.google.com/pay/api/web/guides/brand-guidelines?hl=zh-cn)

**重点**

下面是关于支付相关的重点配置信息，请在开发时做好相应的适配：

1.由于Useepay支付系统支持3DS，因此在设置**allowedCardAuthMethods**参数时，请设置为：

```
this.allowedCardAuthMethods = ["PAN_ONLY", "CRYPTOGRAM_3DS"];
```

并参考[UseePay 3DS流程](https://app.apifox.com/project/2772040)做好3DS后续流程。

2.在设置交易卡组时，请事先联系Useepay客服，根据相应地区咨询可以使用的卡组，并设置相应的参数，如：

```
this.allowedCardNetworks = ["AMEX", "DISCOVER", "JCB", "MASTERCARD", "VISA"];
```

3.交易的指定付款服务机构需设置为Useepay，并设置相应的参数：

```
const tokenizationSpecification = {
  type: 'PAYMENT_GATEWAY',
  parameters: {
    'gateway': 'useepay',
    'gatewayMerchantId': 'useepayGatewayMerchantId'
  }
};
```

4.如果测试环境，请根据官方文档使用Google Pay Test Merchant ID,在切换生产环境时，请将**merchantInfo**更换为联系Useepay工作人员确定后的merchantId值，并将参数设置为：

```
paymentDataRequest.merchantInfo = {
  merchantName: '指定的merchantName'
  merchantId: '指定的merchantId'
};
```

#### 3.组装参数并加签

生成交易参数和Google Pay paymentData后，你应该得到如下的一个对象：

```
tradeRequest = {
    merchantNo : 'XXXX',
    transactionId : 'XXXX',
    transactionType : 'XXXX',
    ...
    payload : paymentData.paymentMethodData.tokenizationData.token
}
```

对上述参数按照[Useepay签名](https://app.apifox.com/project/2038036/apis/api-67385706)进行加签

#### 4.调用支付接口

> 接口地址：
>
> prod：<https://pay-gateway.useepay.com/googlepay/api>
>
> test：<https://pay-gateway1.uat.useepay.com/googlepay/api>

使用**post**方法将加签后的**tradeRequest**对象请求到对应环境的接口地址中，并进行相应的异常处理及回调处理，如果触发3DS，请进行相应的的3DS处理

<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://useepay.gitbook.io/developer/reference/api-reference-xin-yong-ka/google-pay-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
