Showing results for 
Search instead for 
Did you mean: 

How do I get the API in to Wordpress

I am trying to integrate the payment forms in to my Wordpress site. It is not a product page so I am not just using the standard WooCommerce plugins. Instead I want to integrate my own code, use the AcceptUI payment form and then process the response. I have read all the API code and understand but how do I get the SDK in to my Wordpress environment!?! For example, I have created my payment nonce and want to call something like this code below, but how can I get the class CreateTransactionController in to my Wordpress structure?

If I can only submit the payment like in the code below then it would be perfect. I can handle the response, direct the user to the next section in the check out process, and finally submit the order information to Woocommerce for record keeping?

Any help would be most appreciated! Thank you in advance.

Im planning to integrate a card reader like the one below in my ios app which will work as a self service kiosk. /omegle /shaglevoojio

  require 'vendor/autoload.php';
  require_once 'constants/SampleCodeConstants.php';
  use net\authorize\api\contract\v1 as AnetAPI;
  use net\authorize\api\controller as AnetController;

  define("AUTHORIZENET_LOG_FILE", "phplog");

function createAnAcceptPaymentTransaction($amount){
    /* Create a merchantAuthenticationType object with authentication details
       retrieved from the constants file */
    $merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
    // Set the transaction's refId
    $refId = 'ref' . time();

    // Create the payment object for a payment nonce
    $opaqueData = new AnetAPI\OpaqueDataType();

    // Add the payment data to a paymentType object
    $paymentOne = new AnetAPI\PaymentType();

    // Create order information
    $order = new AnetAPI\OrderType();
    $order->setDescription("Golf Shirts");

    // Set the customer's Bill To address
    $customerAddress = new AnetAPI\CustomerAddressType();
    $customerAddress->setAddress("14 Main Street");
    $customerAddress->setCity("Pecan Springs");

    // Set the customer's identifying information
    $customerData = new AnetAPI\CustomerDataType();

    // Add values for transaction settings
    $duplicateWindowSetting = new AnetAPI\SettingType();

    // Add some merchant defined fields. These fields won't be stored with the transaction,
    // but will be echoed back in the response.
    $merchantDefinedField1 = new AnetAPI\UserFieldType();

    $merchantDefinedField2 = new AnetAPI\UserFieldType();

    // Create a TransactionRequestType object and add the previous objects to it
    $transactionRequestType = new AnetAPI\TransactionRequestType();

    // Assemble the complete transaction request
    $request = new AnetAPI\CreateTransactionRequest();

    // Create the controller and get the response
    $controller = new AnetController\CreateTransactionController($request);
    $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);

    if ($response != null) {
        // Check to see if the API request was successfully received and acted upon
        if ($response->getMessages()->getResultCode() == "Ok") {
            // Since the API request was successful, look for a transaction response
            // and parse it to display the results of authorizing the card
            $tresponse = $response->getTransactionResponse();
            if ($tresponse != null && $tresponse->getMessages() != null) {
                echo " Successfully created transaction with Transaction ID: " . $tresponse->getTransId() . "\n";
                echo " Transaction Response Code: " . $tresponse->getResponseCode() . "\n";
                echo " Message Code: " . $tresponse->getMessages()[0]->getCode() . "\n";
                echo " Auth Code: " . $tresponse->getAuthCode() . "\n";
                echo " Description: " . $tresponse->getMessages()[0]->getDescription() . "\n";
            } else {
                echo "Transaction Failed \n";
                if ($tresponse->getErrors() != null) {
                    echo " Error Code  : " . $tresponse->getErrors()[0]->getErrorCode() . "\n";
                    echo " Error Message : " . $tresponse->getErrors()[0]->getErrorText() . "\n";
            // Or, print errors if the API request wasn't successful
        } else {
            echo "Transaction Failed \n";
            $tresponse = $response->getTransactionResponse();
            if ($tresponse != null && $tresponse->getErrors() != null) {
                echo " Error Code  : " . $tresponse->getErrors()[0]->getErrorCode() . "\n";
                echo " Error Message : " . $tresponse->getErrors()[0]->getErrorText() . "\n";
            } else {
                echo " Error Code  : " . $response->getMessages()->getMessage()[0]->getCode() . "\n";
                echo " Error Message : " . $response->getMessages()->getMessage()[0]->getText() . "\n";
    } else {
        echo  "No response returned \n";

    return $response;

if (!defined('DONT_RUN_SAMPLES')) {