- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can't fail
I can't get a credit card to fail. I pre-populate the billing address/info, but when I write over it on the payment form to enter a failing zip code, the new info is ignored. All new info is ignored - name, address, etc. The receipt page shows only the original info. What am I missing?
Thanks for any help.
This is my code requesting a token:
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName($loginid); $merchantAuthentication->setTransactionKey($txkey); //create a transaction $transactionRequestType = new AnetAPI\TransactionRequestType(); $transactionRequestType->setTransactionType("authCaptureTransaction"); $transactionRequestType->setAmount($amount); //Preparing customer information object $cust = new AnetAPI\CustomerAddressType(); $cust->setFirstName($member->f_name); $cust->setLastName($member->l_name); $cust->setAddress($member->address1); $cust->setCity($member->city); $cust->setState($member->state); $cust->setCountry($member->country); $cust->setZip($member->zip); $cust->setPhoneNumber($member->phone); $cust->setEmail($member->email); $transactionRequestType->setBillTo($cust); // Set the customer's identifying information $customerData = new AnetAPI\CustomerDataType(); $customerData->setType("individual"); $customerData->setId($member->id); $customerData->setEmail($member->email); $transactionRequestType->setCustomer($customerData); //Preparing order information object $ord = new AnetAPI\OrderType(); $ord->setDescription("Dues for: ".$yrs); $ord->setInvoiceNumber($refId); $transactionRequestType->setOrder($ord); //Userfields: userFields name value $uf1 = new AnetAPI\UserFieldType(); $uf1->setName('memberid'); $uf1->setValue($member->id); $uf2 = new AnetAPI\UserFieldType(); $uf2->setName('dues_yr'); $uf2->setValue($yrs); $transactionRequestType->addToUserFields($uf1); $transactionRequestType->addToUserFields($uf2); // Set Hosted Form options $setting1 = new AnetAPI\SettingType(); $setting1->setSettingName("hostedPaymentButtonOptions"); $setting1->setSettingValue("{\"text\": \"Pay Dues\"}"); $setting2 = new AnetAPI\SettingType(); $setting2->setSettingName("hostedPaymentOrderOptions"); $setting2->setSettingValue("{\"show\": true}"); $setting3 = new AnetAPI\SettingType(); $setting3->setSettingName("hostedPaymentReturnOptions"); $setting3->setSettingValue("{\"url\": \"https://www.xxxx/members/dues.php?msg=payment\", \"cancelUrl\": \"https://www.xxxx/members/dues.php?refId=$refId\", \"showReceipt\": true}"); $setting4 = new AnetAPI\SettingType(); $setting4->setSettingName("hostedPaymentCustomerOptions"); $setting4->setSettingValue("{\"showEmail\": true}"); $setting5 = new AnetAPI\SettingType(); $setting5->setSettingName("hostedPaymentPaymentOptions"); $setting5->setSettingValue("{\"cardCodeRequired\": true}"); $setting5->setSettingValue("{\"showCreditCard\": true}"); $setting5->setSettingValue("{\"showBankAccount\": false}"); // Build transaction request $request = new AnetAPI\GetHostedPaymentPageRequest(); $request->setMerchantAuthentication($merchantAuthentication); $request->setTransactionRequest($transactionRequestType); $request->setRefId($refId); $request->addToHostedPaymentSettings($setting1); $request->addToHostedPaymentSettings($setting2); $request->addToHostedPaymentSettings($setting3); $request->addToHostedPaymentSettings($setting4); $request->addToHostedPaymentSettings($setting5); //execute request $controller = new AnetController\GetHostedPaymentPageController($request); $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);}
07-31-2018 05:16 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just in case anyone else has this problem, it seems that setting this explicitly to true works:
{ "settingName": "hostedPaymentBillingAddressOptions", "settingValue": "{\"show\": true}" },
It was sort of discussed here: https://community.developer.authorize.net/t5/Integration-and-Testing/Accept-Hosted-Payment-Form-bill...
This thread was from Nov 2017 - and said that even tho the default was 'true', if not set then null was not considered 'true'.
07-31-2018 10:51 PM

