# 先存后付

{% hint style="info" %}
&#x20; 该功能受商户地区/行业/卡种等因素限制，需要向客户经理申请开通
{% endhint %}

Step 1. 收集用户的卡号信息，通过js sdk获取到 **customerPaymentMethodId**。

![保存卡号](/files/WcneYzkHOyfAxuxIGjwP)

Step 2.在未来需要付款的业务环节，调用接口进行扣款。

![在之后的场景付款](/files/CoNyPmUWo2onmTpTAW7s)

### 1. 创建customer <mark style="color:blue;">**`server`**</mark>

&#x20;         商户服务端调用 创建客户接口：[/customers](https://asiabill.gitbook.io/api-explorer/api-reference/jiao-yi/customer)，获取customerId。

{% hint style="info" %}
该 **customerId** 应该与商户网站用户唯一标识互相绑定。
{% endhint %}

### 2. 创建paymentMethod <mark style="color:blue;">**`server`**</mark>

&#x20;         商户服务端调用 创建支付方式接口：[/payment\_methods](https://asiabill.gitbook.io/api-explorer/api-reference/jiao-yi/payment-methods)，获取customerPaymentMethodId

{% hint style="warning" %}
调用当前接口时如果传入 **customerId**，AsiaBill将对 **customerId** 和 **customerPaymentMethodId** 进行自动绑定。
{% endhint %}

{% hint style="info" %}
站内支付模式请参考站内支付接入流程：[创建支付方式](https://asiabill.gitbook.io/docs/zhi-fu/geng-duo-zhi-fu-chang-jing/pages/PA7mltdpHYzwQKE6F8QT#4.-chuang-jian-zhi-fu-fang-shi-web)
{% endhint %}

### 3. 在未来的业务场景中扣款 <mark style="color:blue;">**`server`**</mark>

&#x20;          商户服务端调用[/confirmCharge](https://asiabill.gitbook.io/api-explorer/api-reference/jiao-yi/confirm-charge)发起扣款业务在

{% hint style="info" %}
在步骤2中对 **customerId** 和 **customerPaymentMethodId** 进行绑定后，立即扣款是非必要的，商户可自行保存 **customerId** 和 **customerPaymentMethodId**，以便在未来的场景中进行扣款。
{% endhint %}


---

# 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://asiabill.gitbook.io/docs/zhi-fu/geng-duo-zhi-fu-chang-jing/xian-cun-hou-fu.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.
