title: Apple Pay - authorize.net returns error 153 only when live, sandbox works
body: <p>After searching a lot of articles i couldn't find a solution for my problem.</p>
  
  <p>I have integrated ApplePay button on my site and <strong><em>successfuly made transactions in sandbox mode</em></strong>. I'm using authorize.net php SDK to generate the request. The problems started when i switched to live.
  The message from authorize.net is "<strong>There was an error processing the payment data. Required fields are missing from decrypted data</strong>"</p>
  
  <p>Here what i have done:</p>
  
  <ol>
  <li>Changed the payment processing certificate with one from live authorize.net account</li>
  <li>Changed the credentials i'm using to process authorize.net payments to the same live account i got the payment process certificate</li>
  <li>Use live apple device with real credit card.</li>
  <li>I'm using First data Nashville processor as CC processor which support ApplePay</li>
  </ol>
  
  <p><strong><em>Note that if i switch back to sandbox mode, the transaction passes without issues.</em></strong></p>
  
  <p>The request and the failed response follows:</p>
  
  <p><strong>Request:</strong></p>
  
  <pre><code>{ 
      "createTransactionRequest":{ 
          "merchantAuthentication":{ 
              "name":"xxxxxxxxx",
              "transactionKey":"xxxxxxxxxxx"
          },
          "clientId":"sdk-php-2.0.0",
          "refId":"ref1575669789",
          "transactionRequest":{ 
              "transactionType":"authOnlyTransaction",
              "amount":"14.08",
              "payment":{ 
                  "opaqueData":{ 
                      "dataDescriptor":"COMMON.APPLE.INAPP.PAYMENT",
                      "dataValue":"eyJ2ZXJzaW9u...Q1OSJ9fQ=="
                  }
              },
              "order":{ 
                  "invoiceNumber":"63059-191206",
                  "description":"xxxxxxxxx, xxxxxxxxxxxx v9.0.12 (Order# 63059-191206)"
              },
              "customer":{ 
                  "type":"individual",
                  "email":""
              },
              "billTo":{ 
                  "firstName":"xxxxxxx",
                  "lastName":"xxxxxxx",
                  "address":"xxxx San Remo Cir ",
                  "city":"Vista",
                  "state":"CA",
                  "zip":"92084",
                  "country":"US"
              },
              "retail":{ 
                  "marketType":0,
                  "deviceType":8
              },
              "transactionSettings":{ 
                  "setting":[ 
                      { 
                          "settingName":"duplicateWindow",
                          "settingValue":"60"
                      }
                  ]
              }
          }
      }
  }
  </code></pre>
  
  <p><strong>Response:</strong></p>
  
  <pre><code>{
      "transactionResponse":{
          "responseCode":"3",
          "authCode":"",
          "avsResultCode":"P",
          "cvvResultCode":"",
          "cavvResultCode":"",
          "transId":"0",
          "refTransID":"",
          "transHash":"",
          "testRequest":"0",
          "accountNumber":"",
          "accountType":"",
          "errors":[
              {
                  "errorCode":"153",
                  "errorText":"There was an error processing the payment data. Required fields are missing from decrypted data."
              }
          ],
          "transHashSha2":"",
          "SupplementalDataQualificationIndicator":0
      },
      "refId":"ref1575669789",
      "messages":{
          "resultCode":"Error",
          "message":[
              {
                  "code":"E00027",
                  "text":"The transaction was unsuccessful."
              }
          ]
      }
  }
  </code></pre>
  
  <p>What am i missing?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Here is the code regarding sending opaqueData from ApplePay</p>
  
  <pre><code>$transactionMode = $cc_authorize_mode == $this-&gt;MODE_TEST ? \net\authorize\api\constants\ANetEnvironment::SANDBOX : \net\authorize\api\constants\ANetEnvironment::PRODUCTION;
  $merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
  $merchantAuthentication-&gt;setName($cc_authorize_loginid);
  $merchantAuthentication-&gt;setTransactionKey($cc_authorize_txnkey);
  
  // Set the transaction's refId
  $refId = 'ref' . time();
  $phoneNumber = ! empty($co_b_phone) ? $co_b_phone : $co_phone;
  $customerEmail = ! empty($co_b_email) ? $co_b_email : $co_email;
  $ip = lloader()-&gt;getUtilByName('ip')-&gt;getClientIp();
  
  // Create order information
  $order = new AnetAPI\OrderType();
  $order-&gt;setInvoiceNumber($order_number);
  $order-&gt;setDescription($this-&gt;getOrderPostedByMessage($id_order, $order_number));
  
  // Set the customer's Bill To address
  $customerAddress = new AnetAPI\CustomerAddressType();
  $customerAddress-&gt;setFirstName($co_ccholder_firstname);
  $customerAddress-&gt;setLastName($co_ccholder_lastname);
  if (! empty($co_b_company)) { $customerAddress-&gt;setCompany($co_b_company); }
  $customerAddress-&gt;setAddress($co_b_address." ".$co_b_address2);
  $customerAddress-&gt;setCity($co_b_city);
  $bState = f_isUSState($co_b_state) ? $STATES_XX[$co_b_state] : $STATES[$co_b_state];
  $customerAddress-&gt;setState($bState);
  $customerAddress-&gt;setZip($co_b_zip);
  $customerAddress-&gt;setCountry($countriesISO2[$co_country]);
  $customerAddress-&gt;setPhoneNumber($phoneNumber);
  $customerAddress-&gt;setEmail($customerEmail);
  
  // Set the customer's identifying information
  $customerData = new AnetAPI\CustomerDataType();
  $customerData-&gt;setType("individual");
  if ( ! empty($member_row['id'])) { $customerData-&gt;setId($member_row['id']); }
  $customerData-&gt;setEmail($customerEmail);
  
  
  // Add values for transaction settings
  $duplicateWindowSetting = new AnetAPI\SettingType();
  $duplicateWindowSetting-&gt;setSettingName("duplicateWindow");
  $duplicateWindowSetting-&gt;setSettingValue("60");
  
  // Create a TransactionRequestType object and add the previous objects to it
  $transactionRequestType = new AnetAPI\TransactionRequestType();
  $transactionRequestType-&gt;setCustomerIP($ip);
  $transactionRequestType-&gt;setTransactionType($this-&gt;api_trtype_map[$transactionType]);
  if (empty($this-&gt;applePayPaymentData)) {
              // Normal CC request
              // Create the payment data for a credit card
              ...
  } else {
      $retail = new AnetAPI\TransRetailInfoType();
      $retail-&gt;setMarketType('0');
      $retail-&gt;setDeviceType('8');
      $transactionRequestType-&gt;setRetail($retail);
  
      // Apple Pay Token Request
      $op = new AnetAPI\OpaqueDataType();
      $op-&gt;setDataDescriptor("COMMON.APPLE.INAPP.PAYMENT");
      $paymentToken = base64_encode($this-&gt;applePayPaymentData);
      $op-&gt;setDataValue($paymentToken);
      $payment = new AnetAPI\PaymentType();
      $payment-&gt;setOpaqueData($op);
  }
  
  $transactionRequestType-&gt;setAmount($grandTotal);
  $transactionRequestType-&gt;setOrder($order);
  $transactionRequestType-&gt;setPayment($payment);
  $transactionRequestType-&gt;setBillTo($customerAddress);
  $transactionRequestType-&gt;setCustomer($customerData);
  $transactionRequestType-&gt;addToTransactionSettings($duplicateWindowSetting);
  
  // Assemble the complete transaction request
  $request = new AnetAPI\CreateTransactionRequest();
  $request-&gt;setMerchantAuthentication($merchantAuthentication);
  $request-&gt;setRefId($refId);
  $request-&gt;setTransactionRequest($transactionRequestType);
  
  // Create the controller and get the response
  $controller = new AnetController\CreateTransactionController($request);
  $response = $controller-&gt;executeWithApiResponse($transactionMode);
  if ($response != null) {
      if ($response-&gt;getMessages()-&gt;getResultCode() == "Ok") {
         ...
         if ($tresponse != null &amp;&amp; $tresponse-&gt;getMessages() != null) {
            ...
            return true;
         } else {
            if ($tresponse-&gt;getErrors() != null) {
               ...
            }
         }
          ...
      }
      ...
  }
  </code></pre>
  
  <p><strong>EDIT2:</strong></p>
  
  <p>I added email and phone and ip address in the request with same result. The modified request follows:</p>
  
  <pre><code>{ 
  "createTransactionRequest":{ 
      "merchantAuthentication":{ 
          "name":"**********",
          "transactionKey":"***************"
      },
      "clientId":"sdk-php-2.0.0",
      "refId":"ref1576180306",
      "transactionRequest":{ 
          "transactionType":"authOnlyTransaction",
          "amount":"14.08",
          "payment":{ 
              "opaqueData":{ 
                  "dataDescriptor":"COMMON.APPLE.INAPP.PAYMENT",
                  "dataValue":"eyJ2ZXJzaW9uIj...DFiZiJ9fQ=="
              }
          },
          "order":{ 
              "invoiceNumber":"63117-191212",
              "description":"******************* v9.0.12 (Order# 63117-191212)"
          },
          "customer":{ 
              "type":"individual",
              "email":"*********@gmail.com"
          },
          "billTo":{ 
              "firstName":"Gabe",
              "lastName":"Garcia",
              "address":"********* Cir ",
              "city":"Vista",
              "state":"CA",
              "zip":"92084",
              "country":"US",
              "phoneNumber":"**************",
              "email":"**********@gmail.com"
          },
          "customerIP":"************",
          "retail":{ 
              "marketType":"0",
              "deviceType":"8"
          },
          "transactionSettings":{ 
              "setting":[ 
                  { 
                      "settingName":"duplicateWindow",
                      "settingValue":"60"
                  }
              ]
          }
      }
  }
  </code></pre>
  
  <p>}</p>