Documentation
HOMEAPI ReferencePayment Demo
English
English
  • 📖Home
  • API Reference
  • Wallet
    • Activate Account
    • Multi-currency Balance
    • Global Collection Account
    • Payout
    • Account settings
  • Payment
    • Get started
    • Accept a payment
      • Hosted payment page
      • In-page checkout
      • iOS
      • Android
      • API-Direct
    • Save a card during payment
      • iOS
      • Android
    • Pre-authorize a payment
    • 3D secure authentication
      • iOS
      • Android
    • Subscriptions
      • Recurring
    • Add payment methods
      • Supported APM codes and attributes list
      • APM Integration Guide
    • After the payment
      • Webhook
      • Refunds
      • Response handling
    • About the APIs
      • Currencies
      • Payments
        • How payments work
  • Business Operation
    • MoneyCollect dashboard
      • Home
      • Mobile apps
    • Account
      • Your account
      • Multiple Accounts
      • Account security
    • Alternative payment methods
      • Apply for APMs from your dashboard
        • Google pay
    • Customers
      • Customer portal
    • Products & Prices
      • Pricing table
    • Invoicing
      • How invoicing works
      • Use the dashboard
        • Customers
        • Products and prices
        • Invoice page
      • Hosted Invoice Page
      • No-code quickstart guide
    • Subscriptions
      • Subscription status
      • Subscription settings
      • Create a subscription
    • Pricing
      • Reserves
      • Fees for APMs
    • Payouts
    • Financial reports
      • Select preferred report
      • Balance summary
      • Payout reconciliation
    • Partners
      • Partner pricing
    • Risk management
      • Disputes
        • How disputes work
        • Respond to disputes
          • Dispute reasons
        • Measuring disputes
      • Fraud
        • Monitoring programs
        • High risk merchant lists
        • Tools
        • Fraud prevention
    • Start a team
      • Teams
      • User roles
    • Startup incorporation
  • Developer tools
    • API-Keys
    • Libraries
    • Plugins
      • WooCommerce
      • Magento
        • Using Magento 2 Admin Panel
      • Shopify
        • MoneyCollect Payments App
        • Legacy Version
          • Credit Card Direct Payments App
          • Credit Card Redirected Payments App
          • Alternative Payment Methods App
      • Wix
      • SHOPLINE
      • SHOPLAZZA
      • Xshoppy
      • ShopBase
      • PrestaShop
      • OpenCart
      • AllValue
        • Using Allvalue Panel
Powered by GitBook
On this page
  • 1 Create a pre-authorized payment
  • 2 Capture a pre-authorized payment
  • 3 Cancel the pre-authorization
  1. Payment

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 creating Payment, 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 payment, 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******";

PaymentCreateParams params = 
             PaymentCreateParams.builder()
                    .setAmount(14 * 100L)
                    .setCurrency("USD")
                    .setOrderNo("MC"+System.currentTimeMillis()) 
                    .setIp("103.48.140.12")
                    .setPaymentMethod("{PAYMENT_METHOD_ID}")
                    .setConfirmationMethod(PaymentCreateParams.ConfirmationMethod.AUTOMATIC)
                    .setPreAuth(PaymentCreateParams.PreAuth.YES)
                    .build();
Payment payment =  Payment.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.

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

PaymentCaptureParams params = PaymentCaptureParams.builder()
                          .setPaymentId("py_1451067513881452545")
                          .setComment("capture all")
                          .build();
Payment payment = Payment.capture(params);
return JSONObject.toJSONString(payment);

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.

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

PaymentCancelParams params = PaymentCancelParams.builder()
                    .setPaymentId("py_1451067513881452545")
                    .setCancellationReason("I want to cancel.")
                    .build();
Payment payment = Payment.cancel(params);
return JSONObject.toJSONString(payment);

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

PreviousAndroidNext3D secure authentication

Last updated 2 years ago