Master Merchant Payment Request (Non-UI)
We are supporting Master Merchant payment with Sub Merchants.
To request payment , you need to init the property like below
- (void)payment
{
//set mandatory fields
paymentSDK.merchantID = @"JT01";
paymentSDK.uniqueTransactionCode = @"123456789";
paymentSDK.desc = @"product item 1";
paymentSDK.amount = 20.00;
paymentSDK.currencyCode = @"764";
paymentSDK.pan = @"5105105105105100";
paymentSDK.cardExpireMonth = 12;
paymentSDK.cardExpireYear = 2019;
paymentSDK.cardHolderName = @"Mr. John";
paymentSDK.panCountry = @"TH";
paymentSDK.secretKey = @"123456";
paymentSDK.paymentUI = NO;
//mandatory for master merchant
//Total of sub merchant amount must `EQUAL` to Master account amount
NSMutableArray *subMerchants = [[NSMutableArray alloc] initWithCapacity:2];
SubMerchantBuilder *builder1 = [[SubMerchantBuilder alloc] init];
[builder1 setMerchantID:@"JT01SUB1"];
[builder1 setUniqueTransactionCode:@"123456789sub1"];
[builder1 setAmount:10.0];
[builder1 setCurrencyCode:@"764"];
[builder1 setDescription:@"sub product item 1"];
SubMerchantBuilder *builder2 = [[SubMerchantBuilder alloc] init];
[builder2 setMerchantID:@"JT01SUB2"];
[builder2 setUniqueTransactionCode:@"123456789sub2"];
[builder2 setAmount:10.0];
[builder2 setCurrencyCode:@"764"];
[builder2 setDescription:@"sub product item 2"];
SubMerchant *subMerchant1 = [builder1 build];
SubMerchant *subMerchant2 = [builder2 build];
[subMerchants addObject:subMerchant1];
[subMerchants addObject:subMerchant2];
paymentSDK.subMerchantList = subMerchants;
//end master merchant
//set optional fields
paymentSDK.securityCode = @"123";
[paymentSDK requestWithTarget:self onResponse:^(NSDictionary *response)
{
NSLog(@"%@",response);
NSString *message = @"";
if([response[@"respCode"] isEqualToString:@"00"])
{
message = @"Payment Success";
}
else {
message = response[@"failReason"];
}
NSLog(@"Payment status: %@",message);
} onFail:^(NSError *error) {
if(error) {
NSLog(@"%@",error);
}else {
NSLog(@"Cancel The Payment From OTP");
}
}];
}
func payment() {
//set mandatory fields
paymentSDK.merchantID = "JT01"
paymentSDK.uniqueTransactionCode = "123456789"
paymentSDK.desc = "product item 1"
paymentSDK.amount = 20.00;
paymentSDK.currencyCode = "764"
paymentSDK.pan = "5105105105105100"
paymentSDK.cardExpireMonth = 12
paymentSDK.cardExpireYear = 2019
paymentSDK.cardHolderName = "Mr. John"
paymentSDK.panCountry = "TH"
paymentSDK.secretKey = "123456"
paymentSDK.paymentUI = false
//mandatory for master merchant
//Total of sub merchant amount must `EQUAL` to Master account amount
var subMerchants = [SubMerchant].init()
let builder1:SubMerchantBuilder = SubMerchantBuilder.init()
builder1.setMerchantID("JT01SUB1")
builder1.setUniqueTransactionCode("123456789sub1")
builder1.setAmount(10.0)
builder1.setCurrencyCode("764")
builder1.setDescription("sub product item 1")
let builder2:SubMerchantBuilder = SubMerchantBuilder.init()
builder2.setMerchantID("JT01SUB2")
builder2.setUniqueTransactionCode("123456789sub2")
builder2.setAmount(10.0)
builder2.setCurrencyCode("764")
builder2.setDescription("sub product item 2")
let subMerchant1:SubMerchant? = builder1.build()
let subMerchant2:SubMerchant? = builder2.build()
subMerchants.append(subMerchant1!)
subMerchants.append(subMerchant2!)
paymentSDK.subMerchantList = subMerchants
//end master merchant
//set optional fields
paymentSDK.securityCode = "123"
paymentSDK.request(withTarget: self, onResponse: { (response) in
print("response: \(String(describing: response))")
}) { (error) in
if error != nil {
print("error: \(String(describing: error?.localizedDescription))")
}else{
print("user cancel payment")
}
}
}
Check the full Payment Request example and response at Response Dictionary.