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");
echo 'dataValue '.$dataValue;This correctly displays the returned value ( eyJjb2RlIjoiNTBfMl8wNjAwMDUyNkE5QzdDRUE2Q0E3QUFBMDAyQTkyMjc1OUEyNEFDMDM0NUJFNEUzOUM0RjYwQjlDMzBFMkJBN0U4NjA4QzE1QzQ5OUVBN0FGMDE2NTJBRjYzMkU1REQ2RUI5NkFEREVDIiwidG9rZW4iOiI5NTYxNDcxMDQyMTc4NjQxMDAzNTAxIiwidiI6IjEuMSJ9 ) so it seems my variable is set.
$opaqueData = new AnetAPI\OpaqueDataType(); $opaqueData->setDataDescriptor("COMMON.ACCEPT.INAPP.PAYMENT"); $opaqueData->setDataValue($dataValue);This generates an error:
$opaqueData->setDataValue("$dataValue");Notice: Undefined variable: dataValue in /order_receipt.php on line 109
06-25-2019 07:16 AM
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
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
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
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
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
06-25-2019 12:34 PM
06-25-2019 12:36 PM
06-25-2019 12:40 PM
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