These docs are for v4.0.2. Click to read the latest docs for v4.3.0.

MoMo Wallet

MoMo is a mobile wallet and digital payment application that allows users to make cash transfers, pay more than 100 types of bills, recharge mobile phone accounts, settle personal loans, and purchase services including software licenses, online game vouchers, as well as airline and movie tickets.

 

Here are steps to make a successful payment:

 

Full Sample Code

 

📘

API Method

PGW SDK API Interface

🚧

References

SDK Payment Classes
SDK Payment Enums

 
Step 1 :Generate Payment Token

 
1.1 Generate payment token ID.

📘

Payment Token API

Please refer: Payment Token API

{
    "merchantID": "JT04",
    "invoiceNo": "1595219400",
    "description": "2 days 1 night hotel room",
    "amount": 10.0,
    "currencyCode": "THB",
    "nonceStr": "a8092512-b144-41b0-8284-568bb5e9264c",
    "paymentChannel": ["DPAY"]
}

 
1.2 Get payment token ID from response and pass it to merchant mobile application.

String paymentToken = "roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL";
NSString *paymentToken = @"roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL";
let paymentToken: String = "roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL"

 
Step 2: Construct E-wallet Request.

Below code show how to construct e wallet payment request.

📘

Payment Request Parameter

Please refer: Payment Request API Parameter

🚧

Payment Channel Matrix

Below show the payment channel matrix for MoMo Wallet e-wallet.

Category CodeGroup CodeChannelNameCountry
DPAYEWALLETMOMOMoMo WalletVI
PaymentCode paymentCode = new PaymentCode("MOMO");
 
PaymentRequest paymentRequest = new DigitalPaymentBuilder(paymentCode)
                                .setName("DavidBilly")
                                .setEmail("[email protected]")
                                .setAccountNo("0070000001")
                                .build();
PaymentCode *paymentCode = [[PaymentCode alloc] initWithChannelCode: @"MOMO"];
          
PaymentRequest *paymentRequest = [[[[[[DigitalPaymentBuilder alloc] initWithPaymentCode: paymentCode]
                                       name: @"DavidBilly"]
                                       email: @"[email protected]"]
                                       accountNo: @"0070000001"]
                                       build];
let paymentCode: PaymentCode = PaymentCode(channelCode: "MOMO")
 
let paymentRequest: PaymentRequest = DigitalPaymentBuilder(paymentCode: paymentCode)
                                     .name("DavidBilly")
                                     .email("[email protected]")
                                     .accountNo("0070000001")
                                     .build()

 
Step 3: Construct Transaction Request.

Below code show how to construct transaction request.

📘

Transaction Request API Parameter

Please refer: Do Payment Request API Parameter

TransactionResultRequest transactionResultRequest = new TransactionResultRequestBuilder(paymentToken)
                                                    .with(paymentRequest)
                                                    .build();
TransactionResultRequest *transactionResultRequest = [[[[TransactionResultRequestBuilder alloc] initWithPaymentToken: paymentToken]
                                                         withPaymentRequest: paymentRequest]
                                                         build];
let transactionResultRequest: TransactionResultRequest = TransactionResultRequestBuilder(paymentToken: paymentToken)
                                                         .with(paymentRequest)
                                                         .build()

 
Step 4: Execute Payment Request.

Below code show how to execute payment request and receive API response code.

📘

Transaction Response API Parameter

Please refer: Do Payment Response API Parameter

🚧

References

Response Code
Please refer : Payment Flow Response Code for payment process flow by response code.

PGWSDK.getInstance().proceedTransaction(transactionResultRequest, new APIResponseCallback<TransactionResultResponse>() {
    
     @Override
     public void onResponse(TransactionResultResponse response) {
    
          if(response.getResponseCode().equals(APIResponseCode.TransactionAuthenticateRedirect) || response.getResponseCode().equals(APIResponseCode.TransactionAuthenticateFullRedirect)) {
    
                String redirectUrl = response.getData(); //Open WebView
          } else if(response.getResponseCode().equals(APIResponseCode.TransactionExternalApplication)) {
    
               String appDeepLink = response.getData(); //Open app
          } else {
    
               //Get error response and display error.
          }
     }
    
     @Override
     public void onFailure(Throwable error) {
    
          //Get error response and display error.
     }
});
[[PGWSDK shared] proceedTransactionWithTransactionResultRequest: transactionResultRequest response: ^(TransactionResultResponse * _Nonnull response) {
              
     if([response.responseCode isEqualToString: APIResponseCode.TransactionAuthenticateRedirect] || [response.responseCode isEqualToString: APIResponseCode.TransactionAuthenticateFullRedirect]) {
                  
          NSString *redirectUrl = response.data; //Open WebView
     } else if([response.responseCode isEqualToString: APIResponseCode.TransactionExternalApplication]) {
                  
          NSString *appDeepLink = response.data; //Open app
     } else {
                  
          //Get error response and display error.
     }
} failure: ^(NSError * _Nonnull error) {
              
     //Get error response and display error.
}];
PGWSDK.shared.proceedTransaction(transactionResultRequest: transactionResultRequest, { (response: TransactionResultResponse) in
      
     if response.responseCode == APIResponseCode.TransactionAuthenticateRedirect || response.responseCode == APIResponseCode.TransactionAuthenticateFullRedirect {
                   
           guard let redirectUrl: String = response.data else { return } //Open WebView
     } else if response.responseCode == APIResponseCode.TransactionExternalApplication {
                
           guard let appDeepLink: String = response.data else { return } //Open app
     } else {
                   
           //Get error response and display error.
     }
}) { (error: NSError) in
               
     //Get error response and display error.
}

 
Step 5: Initiate Payment Inquiry.

Retrieve payment detail, required initiate Payment Inquiry API from merchant server end.

📘

Payment Inquiry API

Please refer : Payment Inquiry API

 

Full Sample Code

Full Sample Code Show below.

//Step 1: Generate payment token id.
String paymentToken = "roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL";
    
//Step 2: Construct e-wallet request.
PaymentCode paymentCode = new PaymentCode("MOMO");
 
PaymentRequest paymentRequest = new DigitalPaymentBuilder(paymentCode)
                                .setName("DavidBilly")
                                .setEmail("[email protected]")
                                .setAccountNo("0070000001")
                                .build();
    
//Step 3: Construct transaction request.
TransactionResultRequest transactionResultRequest = new TransactionResultRequestBuilder(paymentToken)
                                                    .with(paymentRequest)
                                                    .build();
    
//Step 4: Execute payment request.
PGWSDK.getInstance().proceedTransaction(transactionResultRequest, new APIResponseCallback<TransactionResultResponse>() {
    
     @Override
     public void onResponse(TransactionResultResponse response) {
    
          if(response.getResponseCode().equals(APIResponseCode.TransactionAuthenticateRedirect) || response.getResponseCode().equals(APIResponseCode.TransactionAuthenticateFullRedirect)) {
    
                String redirectUrl = response.getData(); //Open WebView
          } else if(response.getResponseCode().equals(APIResponseCode.TransactionExternalApplication)) {
    
               String appDeepLink = response.getData(); //Open app
          } else {
    
               //Get error response and display error.
          }
     }
    
     @Override
     public void onFailure(Throwable error) {
    
          //Get error response and display error.
     }
});
//Step 1: Generate payment token id.
NSString *paymentToken = @"roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL";
   
//Step 2: Construct e-wallet request.
PaymentCode *paymentCode = [[PaymentCode alloc] initWithChannelCode: @"MOMO"];
          
PaymentRequest *paymentRequest = [[[[[[DigitalPaymentBuilder alloc] initWithPaymentCode: paymentCode]
                                       name: @"DavidBilly"]
                                       email: @"[email protected]"]
                                       accountNo: @"0070000001"]
                                       build];
   
//Step 3: Construct transaction request. 
TransactionResultRequest *transactionResultRequest = [[[[TransactionResultRequestBuilder alloc] initWithPaymentToken: paymentToken]
                                                         withPaymentRequest: paymentRequest]
                                                         build];
       
//Step 4: Execute payment request.
[[PGWSDK shared] proceedTransactionWithTransactionResultRequest: transactionResultRequest response: ^(TransactionResultResponse * _Nonnull response) {
              
     if([response.responseCode isEqualToString: APIResponseCode.TransactionAuthenticateRedirect] || [response.responseCode isEqualToString: APIResponseCode.TransactionAuthenticateFullRedirect]) {
                  
          NSString *redirectUrl = response.data; //Open WebView
     } else if([response.responseCode isEqualToString: APIResponseCode.TransactionExternalApplication]) {
                  
          NSString *appDeepLink = response.data; //Open app
     } else {
                  
          //Get error response and display error.
     }
} failure: ^(NSError * _Nonnull error) {
              
     //Get error response and display error.
}];
//Step 1: Generate payment token id.
let paymentToken: String = "roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL"
      
//Step 2: Construct e-wallet request.
let paymentCode: PaymentCode = PaymentCode(channelCode: "MOMO")
 
let paymentRequest: PaymentRequest = DigitalPaymentBuilder(paymentCode: paymentCode)
                                     .name("DavidBilly")
                                     .email("[email protected]")
                                     .accountNo("0070000001")
                                     .build()
           
//Step 3: Construct transaction request.
let transactionResultRequest: TransactionResultRequest = TransactionResultRequestBuilder(paymentToken: paymentToken)
                                                         .with(paymentRequest)
                                                         .build()
           
//Step 4: Execute payment request.
PGWSDK.shared.proceedTransaction(transactionResultRequest: transactionResultRequest, { (response: TransactionResultResponse) in
      
     if response.responseCode == APIResponseCode.TransactionAuthenticateRedirect || response.responseCode == APIResponseCode.TransactionAuthenticateFullRedirect {
                   
           guard let redirectUrl: String = response.data else { return } //Open WebView
     } else if response.responseCode == APIResponseCode.TransactionExternalApplication {
                
           guard let appDeepLink: String = response.data else { return } //Open app
     } else {
                   
           //Get error response and display error.
     }
}) { (error: NSError) in
               
     //Get error response and display error.
}