Card Loyalty Point Payment
The 2C2P PGW SDK allows merchants to accept card loyalty point payments.
API Method
References
1. Generate Payment Token
To prepare a payment token request, refer to the required parameters below.
Payment Token API
Refer to: 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": ["GCARD"],
"request3DS": "Y",
"loyaltyPoints": [{
"providerID": "DGC",
"externalMerchantId": "2C2P-Outlet",
"accountNo": "501105",
"redeemAmount": 1.00,
"rewards": [{
"quantity": 1.00
}]
}]
}
2. Receive Payment Token Response
To receive a payment token response, refer to the sample payment token response below. The response will contain the payment token ID which must be passed to the merchant application.
String paymentToken = "roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL";
val 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"
String paymentToken = 'roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL';
let paymentToken = 'roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL';
3. Construct Loyalty Point Payment Request
To prepare a payment request, refer to the sample code below.
Payment Request Parameters
Refer to: Payment Request API Parameters
Loyalty Point Information API
Refer to: Loyalty Point Information API
Payment Channel Matrix
To see supported card options, Refer to below
PaymentCode paymentCode = new PaymentCode("CC");
ArrayList<LoyaltyPoint> loyaltyPoints = new ArrayList<>();
ArrayList<LoyaltyPointReward> rewards = new ArrayList<>();
//Loyalty point reward info can be retrieve from Loyalty Point Info API
LoyaltyPointReward reward = new LoyaltyPointReward();
reward.setId("1792e2b5-8b41-4712-9b44-4c857ce90c3e");
reward.setQuantity(1);
rewards.add(reward);
//Loyalty point info can be retrieve from Loyalty Point Info API
LoyaltyPoint loyaltyPoint = new LoyaltyPoint();
loyaltyPoint.setProviderId("DGC");
loyaltyPoint.setRedeemAmount(1.00);
loyaltyPoint.setRewards(rewards);
loyaltyPoints.add(loyaltyPoint);
PaymentRequest paymentRequest = new LoyaltyPointPaymentBuilder(paymentCode)
.setCardNo("4111111111111111")
.setExpiryMonth(12)
.setExpiryYear(2026)
.setSecurityCode("123")
.setLoyaltyPoints(loyaltyPoints)
.build();
val paymentCode = PaymentCode("CC")
val loyaltyPoints = arrayListOf<LoyaltyPoint>()
val rewards = arrayListOf<LoyaltyPointReward>()
//Loyalty point reward info can be retrieve from Loyalty Point Info API
val reward = LoyaltyPointReward().apply {
id = "1792e2b5-8b41-4712-9b44-4c857ce90c3e"
quantity = 1.0
}
rewards.add(reward)
//Loyalty point info can be retrieve from Loyalty Point Info API
val loyaltyPoint = LoyaltyPoint().apply {
providerId = "DGC"
redeemAmount = 1.00
this.rewards = rewards
}
loyaltyPoints.add(loyaltyPoint)
val paymentRequest = LoyaltyPointPaymentBuilder(paymentCode).apply {
cardNo("4111111111111111")
expiryMonth(12)
expiryYear(2026)
securityCode("123")
loyaltyPoints(loyaltyPoints)
}.build()
PaymentCode *paymentCode = [[PaymentCode alloc] initWithChannelCode: @"CC"];
NSMutableArray<LoyaltyPoint *> *loyaltyPoints = [[NSMutableArray alloc] init];
NSMutableArray<LoyaltyPointReward *> *rewards = [[NSMutableArray alloc] init];
//Loyalty point reward info can be retrieve from Loyalty Point Info API
LoyaltyPointReward *reward = [[LoyaltyPointReward alloc] init];
reward.id = @"1792e2b5-8b41-4712-9b44-4c857ce90c3e";
reward.quantity = 1.00;
[rewards addObject: reward];
//Loyalty point info can be retrieve from Loyalty Point Info API
LoyaltyPoint *loyaltyPoint = [[LoyaltyPoint alloc] init];
loyaltyPoint.providerId = @"DGC";
loyaltyPoint.redeemAmount = 1.00;
loyaltyPoint.rewards = rewards;
[loyaltyPoints addObject: loyaltyPoint];
PaymentRequest *paymentRequest = [[[[[[[[LoyaltyPointPaymentBuilder alloc] initWithPaymentCode: paymentCode]
cardNo: @"4111111111111111"]
expiryMonth: 11]
expiryYear: 2026]
securityCode: @"123"]
loyaltyPoints: loyaltyPoints]
build];
let paymentCode: PaymentCode = PaymentCode(channelCode: "CC")
var loyaltyPoints: [LoyaltyPoint] = [LoyaltyPoint]()
var rewards: [LoyaltyPointReward] = [LoyaltyPointReward]()
//Loyalty point reward info can be retrieve from Loyalty Point Info API
let reward: LoyaltyPointReward = LoyaltyPointReward()
reward.id = "1792e2b5-8b41-4712-9b44-4c857ce90c3e"
reward.quantity = 1.00
rewards.append(reward)
//Loyalty point info can be retrieve from Loyalty Point Info API
let loyaltyPoint: LoyaltyPoint = LoyaltyPoint()
loyaltyPoint.providerId = "DGC"
loyaltyPoint.redeemAmount = 1.00
loyaltyPoint.rewards = rewards
loyaltyPoints.append(loyaltyPoint)
let paymentRequest: PaymentRequest = LoyaltyPointPaymentBuilder(paymentCode: paymentCode)
.cardNo("4111111111111111")
.expiryMonth(11)
.expiryYear(2026)
.securityCode("123")
.loyaltyPoints(loyaltyPoints)
.build()
Map<String, dynamic> paymentCode = {
'channelCode': 'CC'
};
List loyaltyPoints = [];
List rewards = [];
//Loyalty point reward info can be retrieve from Loyalty Point Info API
Map<String, dynamic> reward = {
'id': '1792e2b5-8b41-4712-9b44-4c857ce90c3e',
'quantity': 1.00
};
rewards.add(reward);
//Loyalty point info can be retrieve from Loyalty Point Info API
Map<String, dynamic> loyaltyPoint = {
'providerId': 'DGC',
'redeemAmount': 1.00,
'rewards': rewards
};
loyaltyPoints.add(loyaltyPoint);
Map<String, dynamic> paymentRequest = {
'cardNo': '4111111111111111',
'expiryMonth': 12,
'expiryYear': 2026,
'securityCode': '123',
'loyaltyPoints': loyaltyPoints
};
let paymentCode = {
'channelCode': 'CC'
};
let loyaltyPoints = [];
let rewards = [];
//Loyalty point reward info can be retrieve from Loyalty Point Info API
let reward = {
'id': '1792e2b5-8b41-4712-9b44-4c857ce90c3e',
'quantity': 1.00
};
rewards.push(reward);
//Loyalty point info can be retrieve from Loyalty Point Info API
let loyaltyPoint = {
'providerId': 'DGC',
'redeemAmount': 1.00,
'rewards': rewards
};
loyaltyPoints.push(loyaltyPoint);
let paymentRequest = {
'cardNo': '4111111111111111',
'expiryMonth': 12,
'expiryYear': 2026,
'securityCode': '123',
'loyaltyPoints': loyaltyPoints
};
4. Construct Transaction Request
To prepare a transaction request, refer to the parameters and sample code below.
Transaction Request API Parameters
Refer to: Do Payment Request API Parameter
TransactionResultRequest transactionResultRequest = new TransactionResultRequestBuilder(paymentToken)
.with(paymentRequest)
.build();
val transactionResultRequest = TransactionResultRequestBuilder(paymentToken).apply {
with(paymentRequest)
}.build()
TransactionResultRequest *transactionResultRequest = [[[[TransactionResultRequestBuilder alloc] initWithPaymentToken: paymentToken]
withPaymentRequest: paymentRequest]
build];)
let transactionResultRequest: TransactionResultRequest = TransactionResultRequestBuilder(paymentToken: paymentToken)
.with(paymentRequest)
.build()
Map<String, dynamic> transactionResultRequest = {
'paymentToken': paymentToken,
'payment': {
'code': {
...paymentCode
},
'data': {
...paymentRequest
}
}
};
let transactionResultRequest = {
'paymentToken': paymentToken,
'payment': {
'code': {
...paymentCode
},
'data': {
...paymentRequest
}
}
};
5. Execute Payment Request
To receive a transaction request response, refer to the parameters below.
Transaction Response API Parameters
Refer to: Do Payment Response API Parameter
References
Response Code
To view payment process flows based on response code, refer to: Payment Flow Response Codes
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.TransactionCompleted)) {
//Inquiry payment result by using invoice no.
} else {
//Get error response and display error.
}
}
@Override
public void onFailure(Throwable error) {
//Get error response and display error.
}
});
PGWSDK.getInstance().proceedTransaction(transactionResultRequest, object : APIResponseCallback<TransactionResultResponse> {
override fun onResponse(response: TransactionResultResponse) {
if (response.responseCode == APIResponseCode.TransactionAuthenticateRedirect || response.responseCode == APIResponseCode.TransactionAuthenticateFullRedirect) {
val redirectUrl = response.data //Open WebView
} else if (response.responseCode == APIResponseCode.TransactionCompleted) {
//Inquiry payment result by using invoice no.
} else {
//Get error response and display error.
}
}
override fun onFailure(error: Throwable) {
//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.TransactionCompleted]) {
//Inquiry payment result by using invoice no.
} 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 {
let redirectUrl: String = response.data //Open WebView
} else if response.responseCode == APIResponseCode.TransactionCompleted {
//Inquiry payment result by using invoice no.
} else {
//Get error response and display error.
}
}) { (error: NSError) in
//Get error response and display error.
}
PGWSDK().proceedTransaction(transactionResultRequest, (response) {
if (response['responseCode'] == APIResponseCode.transactionAuthenticateRedirect || response['responseCode'] == APIResponseCode.transactionAuthenticateFullRedirect) {
String redirectUrl = response['data']; //Open WebView
} else if (response['responseCode'] == APIResponseCode.transactionCompleted) {
//Inquiry payment result by using invoice no.
} else {
//Get error response and display error.
}
}, (error) {
//Get error response and display error.
});
await RTNPGW.proceedTransaction(JSON.stringify(transactionResultRequest)).then((response: string) => {
let transactionResultResponse = JSON.parse(response);
if (transactionResultResponse?.responseCode == APIResponseCode.transactionAuthenticateRedirect || transactionResultResponse?.responseCode == APIResponseCode.transactionAuthenticateFullRedirect) {
let redirectUrl = transactionResultResponse?.data; //Open WebView
} else if (transactionResultResponse?.responseCode == APIResponseCode.transactionCompleted) {
//Inquiry payment result by using invoice no.
} else {
//Get error response and display error.
}
}).catch ((error: Error) => {
//Get error response and display error
});
Callback for PGW Payment Authentication
Refer to: Handle PGW Payment Authentication
6. Initiate Transaction Status Inquiry
To retrieve transaction details and status, merchants must initiate the Transaction Status Inquiry API. Refer to the sample code below.
Transaction Status Inquiry API
Refer to: Transaction Status Inquiry API
Full Sample Code
The following sample code demonstrates requests and parameters for each step of the process.
//Step 1: Generate payment token.
String paymentToken = "roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL";
//Step 2: Construct loyalty point payment request.
PaymentCode paymentCode = new PaymentCode("CC");
ArrayList<LoyaltyPoint> loyaltyPoints = new ArrayList<>();
ArrayList<LoyaltyPointReward> rewards = new ArrayList<>();
//Loyalty point reward info can be retrieve from Loyalty Point Info API
LoyaltyPointReward reward = new LoyaltyPointReward();
reward.setId("1792e2b5-8b41-4712-9b44-4c857ce90c3e");
reward.setQuantity(1);
rewards.add(reward);
//Loyalty point info can be retrieve from Loyalty Point Info API
LoyaltyPoint loyaltyPoint = new LoyaltyPoint();
loyaltyPoint.setProviderId("DGC");
loyaltyPoint.setRedeemAmount(1.00);
loyaltyPoint.setRewards(rewards);
loyaltyPoints.add(loyaltyPoint);
PaymentRequest paymentRequest = new LoyaltyPointPaymentBuilder(paymentCode)
.setCardNo("4111111111111111")
.setExpiryMonth(12)
.setExpiryYear(2026)
.setSecurityCode("123")
.setLoyaltyPoints(loyaltyPoints)
.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.TransactionCompleted)) {
//Inquiry payment result by using invoice no.
} else {
//Get error response and display error.
}
}
@Override
public void onFailure(Throwable error) {
//Get error response and display error.
}
});
//Step 1: Generate payment token.
val paymentToken = "roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL"
//Step 2: Construct loyalty point payment request.
val paymentCode = PaymentCode("CC")
val loyaltyPoints = arrayListOf<LoyaltyPoint>()
val rewards = arrayListOf<LoyaltyPointReward>()
//Loyalty point reward info can be retrieve from Loyalty Point Info API
val reward = LoyaltyPointReward().apply {
id = "1792e2b5-8b41-4712-9b44-4c857ce90c3e"
quantity = 1.0
}
rewards.add(reward)
//Loyalty point info can be retrieve from Loyalty Point Info API
val loyaltyPoint = LoyaltyPoint().apply {
providerId = "DGC"
redeemAmount = 1.00
this.rewards = rewards
}
loyaltyPoints.add(loyaltyPoint)
val paymentRequest = LoyaltyPointPaymentBuilder(paymentCode).apply {
cardNo("4111111111111111")
expiryMonth(12)
expiryYear(2026)
securityCode("123")
loyaltyPoints(loyaltyPoints)
}.build()
//Step 3: Construct transaction request.
val transactionResultRequest = TransactionResultRequestBuilder(paymentToken).apply {
with(paymentRequest)
}.build()
//Step 4: Execute payment request.
PGWSDK.getInstance().proceedTransaction(transactionResultRequest, object : APIResponseCallback<TransactionResultResponse> {
override fun onResponse(response: TransactionResultResponse) {
if (response.responseCode == APIResponseCode.TransactionAuthenticateRedirect || response.responseCode == APIResponseCode.TransactionAuthenticateFullRedirect) {
val redirectUrl = response.data //Open WebView
} else if (response.responseCode == APIResponseCode.TransactionCompleted) {
//Inquiry payment result by using invoice no.
} else {
//Get error response and display error.
}
}
override fun onFailure(error: Throwable) {
//Get error response and display error.
}
})
//Step 1: Generate payment token.
NSString *paymentToken = @"roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL";
//Step 2: Construct loyalty point payment request.
PaymentCode *paymentCode = [[PaymentCode alloc] initWithChannelCode: @"CC"];
NSMutableArray<LoyaltyPoint *> *loyaltyPoints = [[NSMutableArray alloc] init];
NSMutableArray<LoyaltyPointReward *> *rewards = [[NSMutableArray alloc] init];
//Loyalty point reward info can be retrieve from Loyalty Point Info API
LoyaltyPointReward *reward = [[LoyaltyPointReward alloc] init];
reward.id = @"1792e2b5-8b41-4712-9b44-4c857ce90c3e";
reward.quantity = 1.00;
[rewards addObject: reward];
//Loyalty point info can be retrieve from Loyalty Point Info API
LoyaltyPoint *loyaltyPoint = [[LoyaltyPoint alloc] init];
loyaltyPoint.providerId = @"DGC";
loyaltyPoint.redeemAmount = 1.00;
loyaltyPoint.rewards = rewards;
[loyaltyPoints addObject: loyaltyPoint];
PaymentRequest *paymentRequest = [[[[[[[[LoyaltyPointPaymentBuilder alloc] initWithPaymentCode: paymentCode]
cardNo: @"4111111111111111"]
expiryMonth: 11]
expiryYear: 2026]
securityCode: @"123"]
loyaltyPoints: loyaltyPoints]
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.TransactionCompleted]) {
//Inquiry payment result by using invoice no.
} else {
//Get error response and display error.
}
} failure: ^(NSError * _Nonnull error) {
//Get error response and display error.
}];
//Step 1: Generate payment token.
let paymentToken: String = "roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL"
//Step 2: Construct loyalty point payment request.
let paymentCode: PaymentCode = PaymentCode(channelCode: "CC")
var loyaltyPoints: [LoyaltyPoint] = [LoyaltyPoint]()
var rewards: [LoyaltyPointReward] = [LoyaltyPointReward]()
//Loyalty point reward info can be retrieve from Loyalty Point Info API
let reward: LoyaltyPointReward = LoyaltyPointReward()
reward.id = "1792e2b5-8b41-4712-9b44-4c857ce90c3e"
reward.quantity = 1.00
rewards.append(reward)
//Loyalty point info can be retrieve from Loyalty Point Info API
let loyaltyPoint: LoyaltyPoint = LoyaltyPoint()
loyaltyPoint.providerId = "DGC"
loyaltyPoint.redeemAmount = 1.00
loyaltyPoint.rewards = rewards
loyaltyPoints.append(loyaltyPoint)
let paymentRequest: PaymentRequest = LoyaltyPointPaymentBuilder(paymentCode: paymentCode)
.cardNo("4111111111111111")
.expiryMonth(11)
.expiryYear(2026)
.securityCode("123")
.loyaltyPoints(loyaltyPoints)
.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 {
let redirectUrl: String = response.data //Open WebView
} else if response.responseCode == APIResponseCode.TransactionCompleted {
//Inquiry payment result by using invoice no.
} else {
//Get error response and display error.
}
}) { (error: NSError) in
//Get error response and display error.
}
//Step 1: Generate payment token.
String paymentToken = 'roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL';
//Step 2: Construct loyalty point payment request.
Map<String, dynamic> paymentCode = {
'channelCode': 'CC'
};
List loyaltyPoints = [];
List rewards = [];
//Loyalty point reward info can be retrieve from Loyalty Point Info API
Map<String, dynamic> reward = {
'id': '1792e2b5-8b41-4712-9b44-4c857ce90c3e',
'quantity': 1.00
};
rewards.add(reward);
//Loyalty point info can be retrieve from Loyalty Point Info API
Map<String, dynamic> loyaltyPoint = {
'providerId': 'DGC',
'redeemAmount': 1.00,
'rewards': rewards
};
loyaltyPoints.add(loyaltyPoint);
Map<String, dynamic> paymentRequest = {
'cardNo': '4111111111111111',
'expiryMonth': 12,
'expiryYear': 2026,
'securityCode': '123',
'loyaltyPoints': loyaltyPoints
};
//Step 3: Construct transaction request.
Map<String, dynamic> transactionResultRequest = {
'paymentToken': paymentToken,
'payment': {
'code': {
...paymentCode
},
'data': {
...paymentRequest
}
}
};
//Step 4: Execute payment request.
PGWSDK().proceedTransaction(transactionResultRequest, (response) {
if (response['responseCode'] == APIResponseCode.transactionAuthenticateRedirect || response['responseCode'] == APIResponseCode.transactionAuthenticateFullRedirect) {
String redirectUrl = response['data']; //Open WebView
} else if (response['responseCode'] == APIResponseCode.transactionCompleted) {
//Inquiry payment result by using invoice no.
} else {
//Get error response and display error.
}
}, (error) {
//Get error response and display error.
});
//Step 1: Generate payment token.
let paymentToken = 'roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL';
//Step 2: Construct loyalty point payment request.
let paymentCode = {
'channelCode': 'CC'
};
let loyaltyPoints = [];
let rewards = [];
//Loyalty point reward info can be retrieve from Loyalty Point Info API
let reward = {
'id': '1792e2b5-8b41-4712-9b44-4c857ce90c3e',
'quantity': 1.00
};
rewards.push(reward);
//Loyalty point info can be retrieve from Loyalty Point Info API
let loyaltyPoint = {
'providerId': 'DGC',
'redeemAmount': 1.00,
'rewards': rewards
};
loyaltyPoints.push(loyaltyPoint);
let paymentRequest = {
'cardNo': '4111111111111111',
'expiryMonth': 12,
'expiryYear': 2026,
'securityCode': '123',
'loyaltyPoints': loyaltyPoints
};
//Step 3: Construct transaction request.
let transactionResultRequest = {
'paymentToken': paymentToken,
'payment': {
'code': {
...paymentCode
},
'data': {
...paymentRequest
}
}
};
//Step 4: Execute payment request.
await RTNPGW.proceedTransaction(JSON.stringify(transactionResultRequest)).then((response: string) => {
let transactionResultResponse = JSON.parse(response);
if (transactionResultResponse?.responseCode == APIResponseCode.transactionAuthenticateRedirect || transactionResultResponse?.responseCode == APIResponseCode.transactionAuthenticateFullRedirect) {
let redirectUrl = transactionResultResponse?.data; //Open WebView
} else if (transactionResultResponse?.responseCode == APIResponseCode.transactionCompleted) {
//Inquiry payment result by using invoice no.
} else {
//Get error response and display error.
}
}).catch ((error: Error) => {
//Get error response and display error
});
Updated 26 days ago