Reply
Member
Posts: 4
Registered: ‎01-22-2017
Accepted Solution

SIM hosted form

I've been looking all around and not really finding posts addressing an issue. There might be a simple thing I should know, but newbie here, so bear with me...

 

I am trying to get a hosted form working with the server integration method. Accept.js requires root access and a VPS, so it's a non-option. From what I've read, SIM is still supported, but there appear to be no working examples with the direct post method.

 

I have Composer installed and have run the update to get a few SDK examples (charge and refund credit card) working. But, in a perfect world, I would be able to put together a hosted payment form with the direct post method in PHP that allows a split tender (partial transaction). Is this even doable anymore?

 

I've gotten around the E00001 error code issue. But now I'm getting a bunch of gibberish every time I test the get-hosted-payment-php.

 

Here's a section of the page, about a third: An+tyYL1oHfNmk4lF0Dy1ltlwleCYxypC3DnZiy3tyw2mPMt5KUZb7Yuq8C2HiInBU9jbVSe0bykIj5rcFv2w9FwpyBcgNF/sMnq02PerLxo5WmvYOXfipPWUxvApS4UF/Snw72hu31dhrqiBcrjf83hxLxr34x7/4Wspr6A3QQKXnROUikzoKru0KFABSGbM7EuswMa2tReyB2aM2BAFKZJjaAyb2/5L40iNM4GLCwSmEEB740ly1QwTfpE3qP08HR

 

So, currently, I can't even get a hosted payment form to show up. All the dependencies should be good. All the files are linked. What else could I possibly need? And is this feasible? Just read that vendors must store payment gateway account data securely. Can I do that without root access on a shared server and, if so, where and how? This is the current code. Only thing I've done is add a require line to the Constants file. Any insight or direction much appreciated. I imagine this looks very amateur-ish, but in my defense, I have gone from knowing nothing to at least knowing how to set up a few transactions and that our options are limited on shared server, in the 20 or so hours I've put towards this so far. And the instructions available for php SIM without using Accept.js seem pretty much non-existent.

 

<?php
  require 'vendor/autoload.php';
  require 'Constants.php';
  use net\authorize\api\contract\v1 as AnetAPI;
  use net\authorize\api\controller as AnetController;

  define("AUTHORIZENET_LOG_FILE", "phplog");
 
  function getHostedPaymentPage($customerprofileid = "123212")
  {
      // Common setup for API credentials
      $merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
      $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID);
      $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY);
      $refId = 'ref' . time();
    
      // Create the payment data for a credit card
      $creditCard = new AnetAPI\CreditCardType();
      $creditCard->setCardNumber("4111111111111111");
      $creditCard->setExpirationDate("1226");
      $creditCard->setCardCode("123");
      $paymentOne = new AnetAPI\PaymentType();
      $paymentOne->setCreditCard($creditCard);

      $order = new AnetAPI\OrderType();
      $order->setDescription("New Item");

      //create a transaction
      $transactionRequestType = new AnetAPI\TransactionRequestType();
      $transactionRequestType->setTransactionType( "authCaptureTransaction");
      $transactionRequestType->setAmount("12.23");

      // Use an existing payment profile ID for this Merchant name and Transaction key
      
      $setting = new AnetAPI\SettingType();
      $setting->setSettingName("hostedPaymentButtonOptions");
      $setting->setSettingValue("{\"text\": \"Pay\"}");
      $setting2 = new AnetAPI\SettingType();
      $setting2->setSettingName("hostedPaymentOrderOptions");
      $setting2->setSettingValue("{\"show\": false}");
      
      //$alist = new AnetAPI\ArrayOfSettingType();
      //$alist->addToSetting($setting);
      
      $request = new AnetAPI\GetHostedPaymentPageRequest();
      $request->setMerchantAuthentication($merchantAuthentication);
      $request->setTransactionRequest($transactionRequestType);

      $request->addToHostedPaymentSettings($setting);
      $request->addToHostedPaymentSettings($setting2);
      
      $controller = new AnetController\GetHostedPaymentPageController($request);
      $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
      
      if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") )
      {
          echo $response->getToken()."\n";
       }
      else
      {
          echo "ERROR :  Failed to get hosted profile page\n";
          $errorMessages = $response->getMessages()->getMessage();
          echo "Response : " . $errorMessages[0]->getCode() . "  " .$errorMessages[0]->getText() . "\n";
      }
      return $response;
  }
  if(!defined('DONT_RUN_SAMPLES'))
      getHostedPaymentPage();    
?>

 

 

Member
Posts: 4
Registered: ‎01-22-2017

Re: SIM hosted form

[ Edited ]

It's starting to look like partial transactions (split tender) is not actually possible with SIM? The instructions on authorize.net are all over the place. There are functions that have been deprecated, code that's no longer supported, references to all kinds of things that no longer exist or aren't supported, etc., etc., etc.

 

As far as I can tell, a request for a hosted form was changed to what they called Payment Form, which then became Simple Checkout. Is that right?

 

So the SIM guide is really just a guide for Simple Checkout, and the SDK-PHP files on Github are all for AIM?

 

Has anyone else tried testing the sample-code-php file set, and found them outdated? If they're going to change their services, why wouldn't they update ALL their website pages that refer to ones that have been eliminated?

Developer
Posts: 143
Registered: ‎11-03-2016

Re: SIM hosted form

Hi @mlindberg1,

 

We've created a lot of confusion in the past with references to "SIM", "CIM", "ARB", "AIM", etc. Sorry about that. Generally, those all refer to older ways of interacting with our system.

 

The current, preferred way of interacting with our system is to use our one single Authorize.Net API. That API has multiple ways of interacting with it depending on what transaction scenario you want to use.

 

Our Upgrade Guide mentions that we refer to what SIM does as "Payment Form", but still refers you to the SIM API and its associated documentation. The upgrade guide doesn't specifically mention the tech that we have in the works to replace it. Our Accept Hosted feature is the replacement for SIM and provides a way to get a hosted payment form using our Authorize.Net API.

 

The get-hosted-payment-page.php file in the sample code isn't outdated; it's actually using this newer method. The SDK itself supports the Authorize.Net API as well as older technologies like SIM, but the sample code is always going to show the current recommended way to do things.

 

The sample code makes a call to the getHostedPaymentPageRequest method in our Authorize.Net API to retrieve a token that you can use later to call up the payment form. The token is then used in the page that you serve to the customer in such a way that the customer's browser does an HTTP form POST with that token, sending it to our server. We respond by serving the payment form.

 

Documentation is available at the Accept Hosted page. It's admittedly a little incomplete, although we're adding to it literally daily. If you read through that and it doesn't make sense to you, please come back here and I'll be happy to walk you through it.

-Aaron

Aaron Wright
Developer Evangelist - Authorize.Net

Follow Authorize.Net developer news on Twitter!
Developer
Posts: 143
Registered: ‎11-03-2016

Re: SIM hosted form


mlindberg1 wrote:

I am trying to get a hosted form working with the server integration method. Accept.js requires root access and a VPS, so it's a non-option. From what I've read, SIM is still supported, but there appear to be no working examples with the direct post method.  


 

Incidentally, if you think Accept.js will work better for you, there shouldn't be anything about it that requires root access or a VPS. Your script has to be served from a secure site, yes, but it should work fine with shared hosting and shared certificates and things like that. If you've got a specific scenario where it's not working, please let us know.

 


mlindberg1 wrote:

But now I'm getting a bunch of gibberish every time I test the get-hosted-payment-php.

 

Here's a section of the page, about a third: An+tyYL1oHfNmk4lF0Dy1ltlwleCYxypC3DnZiy3tyw2mPMt5KUZb7Yuq8C2HiInBU9jbVSe0bykIj5rcFv2w9FwpyBcgNF/sMnq02PerLxo5WmvYOXfipPWUxvApS4UF/Snw72hu31dhrqiBcrjf83hxLxr34x7/4Wspr6A3QQKXnROUikzoKru0KFABSGbM7EuswMa2tReyB2aM2BAFKZJjaAyb2/5L40iNM4GLCwSmEEB740ly1QwTfpE3qP08HR 


 

This gibberish is good! It looks like you're calling the getHostedPaymentPageRequest successfully and getting a form token back. The next step would be to have the customer's browser submit that token to us to get a form back.

 

To test this, you could create an HTML page like this:

 

<html>
<head>
<title>Form test page</title>
</head>

<body>
<form method="post" action="https://test.authorize.net/payment/payment">

Token: <input type="text" name="token" />

<input type="submit" />

</form>
</body>

</html>

Load that form up in a browser, copy the token you've received from the initial token request, paste it into the text field, and click submit. The browser will then take you to the payment form corresponding to your initial request.

 

 

-Aaron

Aaron Wright
Developer Evangelist - Authorize.Net

Follow Authorize.Net developer news on Twitter!
Member
Posts: 4
Registered: ‎01-22-2017

Re: SIM hosted form

Well, this IS encouraging. Our hosted server runs Apache with no support for XAMPP, which may mean it's out. Every test I've tried goes immediately to a sessionstart-related header error. Before I dive back in, three more questions, if I may:

1) Are there plans in the future to stop supporting the gethostedpayment function?
2) Does it support partial transactions (split tender), or is it just a way to get to a slightly more customized Simple Checkout form?
3) Is there any documentation that refers to this token, or the exact process for setting up gethostedpayment in php?
Highlighted
Member
Posts: 4
Registered: ‎01-22-2017

Re: SIM hosted form

Finally figured it all out! We switched our service provider to Stripe. Solid, newly-developed technology, easy-to-follow instructions for integration, no out-of-date documentation, simpler pricing structure, more refined code, superb, timely, and knowleadgable code heads always on hand, etc., etc., etc., Total no-brainer! Could have been easier, but at least it's done! Cheers.