PHP mpgRequest throwing error in toXML: Undefined index: <order_id>.

I can't get the Hosted Tokenization working (in test mode. haven't tried production yet). It's throwing the above error when running this code:

 

        $transaction = new mpgTransaction([
            'order_id' => $orderId,
            'amount' => $amount,
            // purchase through the vault
            'type' => 'res_purchase_cc',
            // credit card number / expiry date / cvv token
            'data_key' => $dataKey,
            // SSL enabled merchant
            'crypt_type' => "7",
        ]);

        $mpgRequest = new mpgRequest($transaction);
        $mpgRequest->setProcCountryCode("CA");

        // false or comment out this line for production transactions
        $mpgRequest->setTestMode(true);

        $mpgHttpPost = new mpgHttpsPost(
            $ini['store_id'],    // "LGHAHtore3"
            $ini['api_token'], // "yesguy"
            $mpgRequest
        );

  • Hi, can you try putting the elements in this order in your array:
    // purchase through the vault
    'type' => 'res_purchase_cc',
    // credit card number / expiry date / cvv token
    'data_key' => $dataKey,
    'order_id' => $orderId,
    'amount' => $amount,
    // SSL enabled merchant
    'crypt_type' => "7"

    also you had a comma after your last element in the array.

    For the store ID, you are passing the ps_store_id value of a hosted config... however it should the store ID (the Gateway account identifier). For example, "store3"
  • In reply to RR_Moneris:

    Thank you. This fixed it.