Closed verreliocr closed 3 months ago
what version you using @verreliocr ?
@jukiginanjar using version 1.13.1 on midtrans sdk, and swift 4
can you paste your code here?
you SDK implementation code @verreliocr
MidtransCreditCardConfig.shared().paymentType = .oneclick
MidtransCreditCardConfig.shared().saveCardEnabled = true
//1-click need 3D secure enabled
MidtransCreditCardConfig.shared().tokenStorageEnabled = true
//1-click need 3ds enabled
MidtransCreditCardConfig.shared().secure3DEnabled = true
for 1-click setup
let transactionDetails = MidtransTransactionDetails(orderID: topupId,
andGrossAmount: NSNumber(integerLiteral: grossAmount))
let itemDetails: [MidtransItemDetail] = [MidtransItemDetail(itemID: "topup",
name: "topup",
price: NSNumber(integerLiteral: grossAmount),
quantity: NSNumber(integerLiteral: 1))]
let tokenResponse = MidtransTransactionTokenResponse(dictionary: tokenDict)
tokenResponse!.transactionDetails = transactionDetails
tokenResponse!.itemDetails = itemDetails
var vc = MidtransUIPaymentViewController()
vc = MidtransUIPaymentViewController.init(token: tokenResponse!, andPaymentFeature: `.MidtransPaymentFeatureCreditCard)`
and thats for payment view controller @jukiginanjar
@verreliocr MidtransTransactionTokenResponse is retrieved with this function MidtransMerchantClient.shared().requestTransactionToken...
, you cannot create that method manually.
I used that implementation on other payment channel, and it seems work well
are MidtransTransactionTokenResponse(dictionary: [AnyHashable : Any])
can do it??
ok I'll try to change it
@jukiginanjar
you cannot, MidtransTransactionTokenResponse
is response from token request
let transactionDetails = MidtransTransactionDetails(orderID: topupId,
andGrossAmount: NSNumber(integerLiteral: grossAmount))
let itemDetails: [MidtransItemDetail] = [MidtransItemDetail(itemID: "topup",
name: "topup",
price: NSNumber(integerLiteral: grossAmount),
quantity: NSNumber(integerLiteral: 1))]
let customerDetails = MidtransCustomerDetails()
let getUser = try! Realm().objects(userData.self).last!
customerDetails.firstName = getUser.name
customerDetails.email = getUser.email
customerDetails.phone = getUser.phone
MidtransMerchantClient.shared().requestTransactionToken(with: transactionDetails!, itemDetails: itemDetails, customerDetails: customerDetails) { (response, error) in
if (response != nil) {
var vc = MidtransUIPaymentViewController()
vc = MidtransUIPaymentViewController.init(token: response!, andPaymentFeature: .MidtransPaymentFeatureCreditCard)
let midTransFont: MidtransUIFontSource = MidtransUIFontSource.init(fontNameBold: AppFont.Style.bold.rawValue, fontNameRegular: AppFont.Style.regular.rawValue, fontNameLight: AppFont.Style.light.rawValue)
MidtransUIThemeManager.applyCustomThemeColor(AppColor.atlantis, themeFont: midTransFont)
vc.paymentDelegate = self
self.present(vc, animated: true)
} else {
//handle error
}
I try to use it like that, and it still crash, it says :
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[4]'
@jukiginanjar
@verreliocr can you make sure if you've got the token from response?
oh sorry i didn't mention it, but now it crash when function MidtransMerchantClient.shared().requestTransactionToken
is called
I tried use this way let tokenResponse = MidtransTransactionTokenResponse.modelObject(with: tokenDict, transactionDetails: transactionDetails, customerDetails: customerDetails, itemDetails: itemDetails)
and it didn't crash!
But, it return an alert, the alert says
Transaction unsuccessful. Please try again with another card or with a different payment method
@jukiginanjar
hi @verreliocr I think it's because you create MidtransCustomerDetails
without set all of its properties, I saw you only set firstName, email & phoneNumber there.
I try to specify my payment to credit card, i've tried one-click and 2-click and it still crash... The error says :
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]'