Open RickSaavedraDFA opened 7 years ago
Logan, I have gone ahead and reverted to Cordova 6.5.0 in order to install the plugin without any hacks on my end. I was able to swipe a card and key it in as well but when I go to process a charge I too get the response of :
Amount must be > 0
cardflight.processCharge(
e => console.log('processCharge'),
a => console.log('error processCharge'), {
type: 'swipe',
amount: '20.0,
description: 'This is another test'
});
The plugin hasn't been tested on or updated for Cordova 7 yet, so that will be your best bet for now. The latest known stable version is 6.4.0. Looking into the amount 0 error now to make sure your code makes sense.
Logan, JC tried it with Cordova 6.5.0 and he got the same result. "Amount must be > 0"
Yes, the comment about 7 was unrelated to amount 0. Just responding to the general question about having to hack to make that work.
As for the amount bug, the code looks pretty good. You might try using double quotes to make sure cordova / iOS do not have a problem with single-quote strings, though I don't think that's the issue.
Your next step will be to open the xcode project file, go into Plugins / CDVCardFlight.m and find the - (void)processCharge:(CDVInvokedUrlCommand*)command method. Set a breakpoint there and make sure it's getting your amount into the objective-C code in the first place. I assume you're getting a valid card first as well, via swipe. But stepping through on the Xcode side should get to the bottom of it.
Thanks Logan, but I already did what you mentioned. Used ', ", and none around the value and nothing. I also went into xcode and into the method like you mentioned and saw the value was being sent correctly into that code. In the below code I had breakpoints and saw that the value in amount used for the chargeDict object was 12. When the call to chargeCardWithParameters:chargeDict was executed, it would fail and the message was "Amount must be > 0". Hope this helps.
Rick
NSDictionary *chargeDict = [NSDictionary dictionaryWithObjectsAndKeys:
metadata, @"metadata",
amount, @"amount",
amount, @"Amount",
currency, @"currency",
[options valueForKey:@"description"], @"description", nil];
__weak CDVCardFlight *weakSelf = self;
[_card chargeCardWithParameters:chargeDict success:^(CFTCharge *charge) {
NSLog(@"success");
NSDictionary *resp = [NSDictionary dictionaryWithObjectsAndKeys:
[charge valueForKey:@"referenceID"], @"referenceID", nil];
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:resp];
[result setKeepCallbackAsBool:TRUE];
[weakSelf.commandDelegate sendPluginResult:result callbackId:weakSelf.onTransactionResultCallbackId];
} failure:^(NSError *error) {
NSLog(@"Error:chargeCardWithParameters %@", error);
NSLog(@"%@", error.localizedDescription);
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:error.localizedDescription];
[result setKeepCallbackAsBool:TRUE];
[weakSelf.commandDelegate sendPluginResult:result callbackId:weakSelf.onTransactionResultCallbackId];
}];
Logan, just as an FYI, I had added the extra "amount, @"Amount"," into the code to test if it was case sensitive. But the original code without that still did the same thing.
Rick
I am submitting the following values to processCharge but what is being submitted to CardFlight API endpoint is a value os 0 for amount. Am I doing something wrong or is there a bug?
{ type: "keyed", amount: '12.00', description: 'test' }