Use Server to Server : Connect through the JAVA SDK provided by MoneyCollect.

Download our SDK

1. Set up MoneyCollect

Firstly, make sure that you have set up an account name on the MoneyCollect dashboard.

2. Create PaymentMethod

PaymentMethod is the necessary prerequisite to charge.

PaymentMethod can specify different payment methods,such as credit cards, Alipay, WeChat Pay, etc. Different payment methods require different parameters. For example: Billing information and card information are required for credit cards, but not for Alipay.

The following code shows how to create a PaymentMethod through the SDK:

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

// Build card
PaymentMethodCreateParams.Card card = PaymentMethodCreateParams.Card.builder()
// Build billing details for card
PaymentMethodCreateParams.BillingDetails billingDetails = PaymentMethodCreateParams.BillingDetails.builder()
                .setCity("Hong Kong")
                .setLine1("193 Prince Edward Road")
                .setState("Hong Kong").build() )
// Build payment method
PaymentMethodCreateParams params =
// Create payment method
PaymentMethod paymentMethod = PaymentMethod.create(params);

3. Create a payment

 PaymentCreateParams params =
                .setIp("") // customer ip 

Payment payment =  Payment.create(params);  //

Create a payment and automatically charge by setting the "confirm" parameter to true and specifying the "paymentMethod" parameter.

4. Confirm a payment

PaymentConfirmParams paymentConfirmParams = PaymentConfirmParams.builder()
Payment payment = Payment.retrieve({{paymentId}});

If you want to create a transaction and charge automatically, you can refer to the following code:

PaymentCreateParams params =
                .setIp("") // customer ip

Payment payment =  Payment.create(params);  

5. Verification action required

For some transactions, customers may be required to perform verification actions, such as 3D secure authentication or Alipay to scan code. Payment will return nextAction when confirming the charge. At this time, you need to do additional actions, redirect or display the QR code according to the different type of nextAction.

"nextAction": {
    "type": "redirect",
    "redirectToUrl": "

6. Inquire about a transaction

After the payment is completed, we will return the result to thereturnUrlyou set and send a notification tonotifyUrl. You can also inquire the result of this payment through API or SDK.

Payment payment = Payment.retrieve("pt_1497139547656585217");

7.Additional testing resources

There are several test cards you can use to make sure your integration is ready for production. Use them with any CVC, postal code, and future expiration date.

Last updated