{ "createTransactionRequest": { "merchantAuthentication": { "name": "ApiLoginHere", "transactionKey": "TransactionKeyHere" }, "refId": "123456", "transactionRequest": { "transactionType": "authCaptureTransaction", "amount": "0.01", "payment": { "opaqueData": { "dataDescriptor": "COMMON.APPLE.INAPP.PAYMENT", "dataValue": "eyJ2ZX...GEifX0=" } }, "lineItems": { "lineItem": { "itemId": "1", "name": "Donation", "description": "Donation", "quantity": "1", "unitPrice": "0.01" } } } } }
{ "transactionResponse": { "responseCode": "3", "authCode": "", "avsResultCode": "P", "cvvResultCode": "", "cavvResultCode": "", "transId": "0", "refTransID": "", "transHash": "3C0B543D31B546B9FB07763547E76925", "testRequest": "0", "accountNumber": "", "accountType": "", "errors": [{ "errorCode": "153", "errorText": "There was an error processing the payment data. Required fields are missing from decrypted data." }], "transHashSha2": "" }, "refId": "123456", "messages": { "resultCode": "Error", "message": [{ "code": "E00027", "text": "The transaction was unsuccessful." }] } }
self.donationAmount = [NSDecimalNumber decimalNumberWithString:@"0.01"]; PKPaymentRequest *request = [[PKPaymentRequest alloc] init]; request.countryCode = @"US"; request.currencyCode = @"USD"; request.supportedNetworks = @[PKPaymentNetworkAmex, PKPaymentNetworkMasterCard, PKPaymentNetworkVisa]; request.merchantCapabilities = PKMerchantCapabilityEMV; request.merchantIdentifier = @"merchant.mymerchantidentifier.org"; PKPaymentSummaryItem *paymentTotal = [PKPaymentSummaryItem summaryItemWithLabel:@"" amount:self.donationAmount]; request.paymentSummaryItems = @[paymentTotal]; PKPaymentAuthorizationViewController *paymentPane = [[PKPaymentAuthorizationViewController alloc] initWithPaymentRequest:request]; paymentPane.delegate = self; [self presentViewController:paymentPane animated:TRUE completion:nil];
PKPaymentToken *paymentToken = payment.token; NSData *data = paymentToken.paymentData; NSString *base64Encoded = [data base64EncodedStringWithOptions:0]; NSString *body = [NSString stringWithFormat: @"{\"createTransactionRequest\": {" "\"merchantAuthentication\": {" "\"name\": \"ApiLoginIdHere\"," "\"transactionKey\": \"TransactionKeyHere\"" "}," "\"refId\": \"123456\"," "\"transactionRequest\": {" "\"transactionType\": \"authCaptureTransaction\"," "\"amount\": \"0.01\"," "\"payment\": {" "\"opaqueData\": {" "\"dataDescriptor\": \"COMMON.APPLE.INAPP.PAYMENT\"," "\"dataValue\": \"%@\"" "}" "}," "\"lineItems\": {" "\"lineItem\": {" "\"itemId\": \"1\"," "\"name\": \"Donation\"," "\"description\": \"Donation\"," "\"quantity\": \"1\"," "\"unitPrice\": \"0.01\"" "}" "}" "}" "}" "}", base64Encoded]; NSString *requestURI = @"https://apitest.authorize.net/xml/v1/request.api"; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:requestURI]]; [request setHTTPShouldHandleCookies:NO]; [request setTimeoutInterval:60]; request.HTTPMethod = @"Post"; request.HTTPBody = [body dataUsingEncoding:NSUTF8StringEncoding]; [request setValue:@"application/json; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; [[[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler: ^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) { NSString *responseStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; NSLog(@"Data received: %@", responseStr); }] resume];
Solved! Go to Solution.
08-25-2017 11:02 AM
Thanks Aaron! I got it to work!
My Apple Merchant ID was correct, but I think there was something wrong with my certificates. After re-generating my certificates I was able to get it to work. Thanks for letting me know that the Apple Merchant ID is tied to decrypting the payment data - that was what tipped me off to start looking there.
I still haven't been able to get the sandbox environment to work, but that is probably another certificate-related issue.
The only other thing I needed to do to make the transaction go through was to add the "billTo" fields in the JSON.
08-28-2017 11:29 AM
A couple of things to look at:
Let me know if this helps at all, or if I'm completely off the mark.
08-25-2017 04:29 PM
Thanks Aaron! I got it to work!
My Apple Merchant ID was correct, but I think there was something wrong with my certificates. After re-generating my certificates I was able to get it to work. Thanks for letting me know that the Apple Merchant ID is tied to decrypting the payment data - that was what tipped me off to start looking there.
I still haven't been able to get the sandbox environment to work, but that is probably another certificate-related issue.
The only other thing I needed to do to make the transaction go through was to add the "billTo" fields in the JSON.
08-28-2017 11:29 AM
I'm getting the following error:
Failed Transaction. Error Code: 153 Error message: There was an error processing the payment data. Unable to decrypt data.
Your help is much appreciated.
And I'm sending the opaquedata.dataValue as the base64 encoded data that contains the version, data, signature, header(ephemeralPublicKey, publicKeyHash, transactionId).
02-15-2018 11:49 AM - edited 02-15-2018 11:52 AM
We generated the token using apple pay and transaction is successful for sandbox environment.We used exactly the same process for token generation for live environment but we get the above error:
"Required fields are missing from decrypted data".In sandbox mode
PKMerchantCapability.capability3DS works, while in live mode we get below error:
"This processor does not support this method of submitting payment data."
As mentioned in possible solutions for error codes,
Changing it to PKMerchantCapability.capabilityEMV does not help and gives the below response:
"Required fields are missing from decrypted data".We have set all possible values of
PKPaymentRequest including shippingAddress,Billing contact,etc.Also ensured that merchant account is card not present & encrypted data belongs to merchant.
In live environment,we are setting location of device to US and using US credit card details.Device is located in India.
Sample Response:
{
"transactionResponse": {
"responseCode": "3",
"authCode": "",
"avsResultCode": "P",
"cvvResultCode": "",
"cavvResultCode": "",
"transId": "0",
"refTransID": "",
"transHash": "817E4EEE366139A5598A43F3CA026D41",
"testRequest": "0",
"accountNumber": "",
"accountType": "",
"errors": [
{
"errorCode": "153",
"errorText": "There was an error processing the payment data. Required fields are missing from decrypted data."
}
],
"userFields": [
{
"name": "MerchantDefinedFieldName1",
"value": "MerchantDefinedFieldValue1"
},
{
"name": "favorite_color",
"value": "blue"
}
],
"transHashSha2": "0F4059266DB96EC3DF32F9B4A39F61E3BF26FF67523C31A42FCBBABDC841D3719038BE788DD47BC5227A05042B1BA2198AD4A137A6926BBC39E2C171ED9176B6"
},
"refId": "123456",
"messages": {
"resultCode": "Error",
"message": [
{
"code": "E00027",
"text": "The transaction was unsuccessful."
}
]
}
}
04-02-2018 04:19 AM - edited 04-02-2018 04:26 AM
Hi, did you figure this out? I haven't had any luck talking to them. I never got the transactions to work when i use discover card but there is no problem processing visa card. It is pretty strange and very similar to what you're experiencing.
07-13-2018 01:53 PM