cancel
Showing results for 
Search instead for 
Did you mean: 

ARB PHP sample code gives me a blank page

Hello,

using the simple code from the README file of the PHP SDK I've setup 2 pages.

one using ARB the other using AIM, both located in the same folder using the same sdk files.

the AIM works fine and creates a charge on my test account, the ARB gives me a blank page and doesn't create any subscription in my test account.

What I m missing?

 

https://www.eliteproskin.com/product_01/test/index.php

<?php

require_once 'anet_php_sdk/AuthorizeNet.php'; 

    define("AUTHORIZENET_API_LOGIN_ID", "my ID");

    define("AUTHORIZENET_TRANSACTION_KEY", "my key");

    $subscription                          = new AuthorizeNet_Subscription;

    $subscription->name                    = "PHP Monthly Magazine";

    $subscription->intervalLength          = "1";

    $subscription->intervalUnit            = "months";

    $subscription->startDate               = "2011-03-12";

    $subscription->totalOccurrences        = "12";

    $subscription->amount                  = "12.99";

    $subscription->creditCardCardNumber    = "6011000000000012";

    $subscription->creditCardExpirationDate= "2018-10";

    $subscription->creditCardCardCode      = "123";

    $subscription->billToFirstName         = "Rasmus";

    $subscription->billToLastName          = "Doe";

 

 

    // Create the subscription.

    $request = new AuthorizeNetARB;

    $response = $request->createSubscription($subscription);

    $subscription_id = $response->getSubscriptionId();

    echo($subscription_id);

?>

 

https://www.eliteproskin.com/product_01/test/check.php

 

<?php

    require_once 'anet_php_sdk/AuthorizeNet.php'; 

    define("AUTHORIZENET_API_LOGIN_ID", "my ID");

    define("AUTHORIZENET_TRANSACTION_KEY", "My key");

    define("AUTHORIZENET_SANDBOX", true);

    $sale = new AuthorizeNetAIM;

    $sale->amount = "5.99";

    $sale->card_num = '6011000000000012';

    $sale->exp_date = '04/15';

    $response = $sale->authorizeAndCapture();

    if ($response->approved) {

        $transaction_id = $response->transaction_id;

        echo($transaction_id);

    }

    ?>

 

I tried adding the line  

define("AUTHORIZENET_SANDBOX", true);

to the ARB code but same result 

thank you for any help

parabellum
Member
4 REPLIES 4

Well, you might try printing something else at the end to find out if it's getting all the way through and just not passing back a subscription ID. If that fails, then you need to check your error logs to find out what's going on.

TJPride
Expert

Thanks you for the feedback ;-)

What else could I print  ?

I'm learning as I go and was trying to find out how to get a response code but didn't find out how to get that value back yet.

Would that be a good direction for me to pursue?

Thanks

If you're getting a blank page that usually means you have a syntax error and error reporting has been turned off so you can't see the actual error. Place the following code on the line after your opening PHP tag:

 

error_reporting(E_ALL);

That should allow your code to display any errors your have so you can better troubleshoot it.

 

If that doesn't work follow 

 

<?php
    require_once 'anet_php_sdk/AuthorizeNet.php'; 

    define("AUTHORIZENET_API_LOGIN_ID", "my ID");
    define("AUTHORIZENET_TRANSACTION_KEY", "my key");

    echo "Made it to 1\n"; 

    $subscription                          = new AuthorizeNet_Subscription;
    $subscription->name                    = "PHP Monthly Magazine";
    $subscription->intervalLength          = "1";
    $subscription->intervalUnit            = "months";
    $subscription->startDate               = "2011-03-12";
    $subscription->totalOccurrences        = "12";
    $subscription->amount                  = "12.99";
    $subscription->creditCardCardNumber    = "6011000000000012";
    $subscription->creditCardExpirationDate= "2018-10";
    $subscription->creditCardCardCode      = "123";
    $subscription->billToFirstName         = "Rasmus";
    $subscription->billToLastName          = "Doe";

    echo "Made it to 2\n"; 

    // Create the subscription.
    $request = new AuthorizeNetARB;

    echo "Made it to 3\n"; 

    $response = $request->createSubscription($subscription);

    echo "Made it to 4\n"; 

    $subscription_id = $response->getSubscriptionId();

    echo "Made it to 5\n"; 
    
    echo($subscription_id);

    echo "Made it to 6\n"; 
?>

-------------------------------------------------------------------------------------------------------------------------------------------
John Conde :: Certified Authorize.Net Developer (Brainyminds) :: Official Authorize.Net Blogger

NEW! Handling Authorize.Net's Webhooks with PHP

Integrate Every Authorize.Net JSON API with One PHP Class (Sample code included)

Tutorials for integrating Authorize.Net with PHP: AIM, ARB, CIM, Silent Post
All About Authorize.Net's Silent Post
stymiee
Expert
Expert

Was really stupid, as often is ;-)

I found out how to print the $response and found out I was using a start date that was in the past, whooops !

All good now

Thanks for the help