- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
accept.js - SO CLOSE! One small thing and it will work ... $dataValue ??
Using code from github, I've finally gotten (mostly) accept.js to work, except for ONE thing ...
If I get the value from the returned nonce and paste it into the block below, the transaction will clear. So, I know that everything up to this point is correct:
$opaqueData = new AnetAPI\OpaqueDataType(); $opaqueData->setDataDescriptor("COMMON.ACCEPT.INAPP.PAYMENT"); $opaqueData->setDataValue("eyJjb2RlIjoiNTBfMl8wNjAwMDUyNkE5QzdDRUE2Q0E3QUFBMDAyQTkyMjc1OUEyNEFDMDM0NUJFNEUzOUM0RjYwQjlDMzBFMkJBN0U4NjA4QzE1QzQ5OUVBN0FGMDE2NTJBRjYzMkU1REQ2RUI5NkFEREVDIiwidG9rZW4iOiI5NTYxNDcxMDQyMTc4NjQxMDAzNTAxIiwidiI6IjEuMSJ9");
BUT, I need to get that into the block as a variable. Nothing seems to work at the moment.
Checking to see if I've got a variable assigned.
echo 'dataValue '.$dataValue;This correctly displays the returned value ( eyJjb2RlIjoiNTBfMl8wNjAwMDUyNkE5QzdDRUE2Q0E3QUFBMDAyQTkyMjc1OUEyNEFDMDM0NUJFNEUzOUM0RjYwQjlDMzBFMkJBN0U4NjA4QzE1QzQ5OUVBN0FGMDE2NTJBRjYzMkU1REQ2RUI5NkFEREVDIiwidG9rZW4iOiI5NTYxNDcxMDQyMTc4NjQxMDAzNTAxIiwidiI6IjEuMSJ9 ) so it seems my variable is set.
So back to my code block - trying this:
$opaqueData = new AnetAPI\OpaqueDataType(); $opaqueData->setDataDescriptor("COMMON.ACCEPT.INAPP.PAYMENT"); $opaqueData->setDataValue($dataValue);This generates an error:
Notice: Undefined variable: dataValue in /order_receipt.php on line 109
Transaction Failed Error Code : E00003 Error Message : The element 'opaqueData' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has incomplete content. List of possible elements expected: 'dataValue' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'.
Hmmm - right above is my display block, and it's still outputting the correct value.
Just to be SURE I'm not an idiot (and I can be) ... single or double quotes don't work either
$opaqueData->setDataValue("$dataValue");Notice: Undefined variable: dataValue in /order_receipt.php on line 109
Transaction Failed Error Code : E00076 Error Message : dataValue contains invalid value.
06-25-2019 07:16 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Actually, trying to get ANY variables into the code generates the same problem.
For example, I have $firstNAME and $lastNAME set ...
If the names are hard coded in, it works
$customerAddress->setFirstName("Bob"); $customerAddress->setLastName("Jones");
But, trying to get that to work using the variables - ain't working ....
$customerAddress->setFirstName($firstNAME); $customerAddress->setLastName($lastNAME);
06-25-2019 07:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This sounds like a scope issue. If so, there are several ways around it. The first, which will work but is bad practice is to use the global keyword for all the variables you want to use inside that function. So inside the function before you assign those object properties type-
global $firstName, $lastName; //comma separate as many variables as you need.
Since you have a small project this would probably be fine. Using global variables excessively in larger projects will cause bugs that are very difficult to track down. I still advise against it. Another way is to pass all of those variables as parameters in your function.
function createAnAcceptPaymentTransaction($amount, $firstName, $lastName) //use the above when defining the function then call it as in the below. You will // add the rest of your variables as needed if (!defined('DONT_RUN_SAMPLES')) { createAnAcceptPaymentTransaction($amount,$firstName,$lastName); }
06-25-2019 08:26 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Regardless of what I try, I can't get it to include the $dataValue from the nonce
$opaqueData->setDataValue(" WHAT THE HECK DO I PUT RIGHT HERE TO INCLUDE THE VALUE HELD IN THE VARIABLE $dataValue ?");
Adding $dataValue to the globel doesn't help ....
I'm experimenting with it, but no go so far ...
Also, is there a list of the returned data somewhere? Damned authorize.net docs are convoluted ...
06-25-2019 11:06 AM - edited 06-25-2019 11:17 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Also, THIS works and when the receipt comes back, is shown as the correct invoice number:
$order->setInvoiceNumber("$enrID");
So why doesn't it work for the names? Or $dataValue??
$customerAddress->setFirstName("$fNAME"); $customerAddress->setLastName("$lNAME");
06-25-2019 11:19 AM - edited 06-25-2019 11:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This works too:
$order->setDescription("Enrollment Payment $enrID");
... and in the receipt email:
========= ORDER INFORMATION ========= Invoice : 1804875 Description : Enrollment Payment 1804875 Amount : 2.23 (USD) Payment Method: Visa xxxx1111 Transaction Type: Authorization and Capture
06-25-2019 12:18 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2019 12:34 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2019 12:36 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The nonce is a client side output and you and putting it through the server side. How are you assigning the value to the $dataValue variable? Are you posting it with a form? I’m on a phone waiting for my car to get inspected. I may be missing details.
06-25-2019 12:40 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sounds like you are requesting a hosted pay web page where clients can sign in and store their card statistics, generating a relaxed token link, which you could then use for destiny variable expenses. That itself is quite simple.
09-23-2021
04:30 AM
- last edited on
09-10-2022
11:10 AM
by
KH-Taylarie

