Pre-authorize a payment

1 Create a pre-authorized payment

When creating Checkout session, set the value of preAuth property to 'y'.

  • The value is y:indicates that the current payment is pre-authorized. After the cardholder completes the authorization, the status of the payment is'uncaptured'. And you need to capture funds, the payment can be finalized.

  • The value is n:indicates this is an ordinary payment and 'n'is the default value.

// Use your private key
MoneyCollect.apiKey = "test_pr_NWZsa******";

SessionCreateParams params =
                    SessionCreateParams.builder()
                            .setReturnUrl("http://localhost:4242/success.html")
                            .setCancelUrl("http://localhost:4242/cancel.html")
                            .setNotifyUrl("http://localhost:4242/success.html")
                            .setAmountTotal(19 * 100L)
                            .setCurrency("USD")
                            .setOrderNo("C"+System.currentTimeMillis())
                            .setWebsite("https://www.mc.com")
                            .setPreAuth(SessionCreateParams.PreAuth.YES)
                            .build();
Session session = Session.create(params);

When a payment is pre-authorized, but it cannot be captured or canceled in 7days, MoneyCollect will automatically cancel this payment.

2 Capture a pre-authorized payment

  1. Use API Capture a Payment to capture payment in 'uncaptured' status.

  • paymentId The ID of the payment you capture.

  • comment the description for capture.

2. Use MoneyCollect Dashboard to capture

Capture a pre-authorized payment, only supports to capture full amount. That is to say, we don't support partially capture a payment.

3 Cancel the pre-authorization

Use API Cancel a Payment to cancel the payment in 'uncaptured' status.

  • paymentId the ID of the payment you cancel.

  • cancellationReason The reason why you cancel the pre-authorization.

You can also cancel a Pre-auth payment in your MoneyCollect Dashboard.

Zero-Amount Authorization

This section describes how to perform zero-amount authorization to validate and bind a customer’s payment method without charging any funds, and how to reuse the saved payment method for future transactions.

1. Merchant Tokenization Configuration

Before using zero-amount authorization, the merchant must enable the Tokenization capability.

Configuration Requirement: Please contact your account manager to apply for activation of the Tokenization product.

2. Zero-Amount Authorization Creation Flow

The zero-amount authorization flow consists of the following steps:

  1. Create a Customer

  2. Create a PaymentMethod

  3. Create a Payment (Zero-Amount Authorization)

2.1 Create Customer

Description: Create a customer object to represent an end user. The returned customerId should be uniquely mapped to the merchant’s internal user identifier.

Request Example

Response Example


2.2 Create PaymentMethod

Description: Create a payment method object to securely collect and store the customer’s card information. A paymentMethod ID will be returned for future use.

Request Example

Response Example


2.3 Create Payment (Zero-Amount Authorization)

Description: Create a payment request to perform zero-amount authorization. When both customerId and paymentMethod are provided and setupFutureUsage is set to on, the system will bind the payment method to the customer for future transactions.

Important Parameters

Parameter
Description

customerId

The unique identifier of the customer. Used to bind the payment method to a specific end user.

paymentMethod

The identifier of the payment method (card) to be authorized and bound to the customer.

setupFutureUsage

Indicates that the payment method will be saved and tokenized for future use. Must be set to on.

amount

The transaction amount. Can be set to 0 for card validation without charging the customer.

Request Example

Response Example


3. Charging with a Saved Payment Method in Future Scenarios

After completing zero-amount authorization, merchants can initiate future payments by reusing the saved customerId and paymentMethod.

Note: Subsequent transactions may trigger 3D Secure authentication, depending on the card network and risk evaluation.


Request Example

Response Example

Last updated