cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble passing invoiceNumber to transaction PHP

Hi:

 

Have been using AuthorizeNetAIM successfully for a few years.  I beleive this may be depricated and I need to implement the latest API, which I will do in time.

 

However, I have an urgent need to pass an invoice number to an Authorize and Capture transaction so that it will show up in the transaction report in the  authorize.net merchant account.

 

I am much better at procedural PHP and am struggling with the OOP scripting.  CAn someone look at the following code and advise me what I am doing wrong?  Again, the object is to pass an invoice number to the transaction so it will be reported out.

 

Code:

 

 
    $transaction = new AuthorizeNetAIM;
    // $transaction->setSandbox(AUTHORIZENET_SANDBOX);

	$order = new OrderType();
    $order->getInvoiceNumber('$invoiceNumber'); 
    // temporarily, set invoice number to fixed value to see if we can pass it to transaction
    $order->setInvoiceNumber("10101"); 
    
    $transactionRequestType = new transactionRequestType();
    $transactionRequestType->getOrder($order);
    $transactionRequestType->setOrder($order);
    $transaction->setTransactionRequest($transactionRequestType);
    
    $transaction->setFields(
        array(
        'amount' => $pmt_amt, 
        'card_num' => $_POST['x_card_num'], 
        'exp_date' => $_POST['x_exp_date'],
        'first_name' => $_POST['x_first_name'],
        'last_name' => $_POST['x_last_name'],
        'company' => $_POST['x_company'],
        'address' => $_POST['x_address'],
        'city' => $_POST['x_city'],
        'state' => $_POST['x_state'],
        'country' => $_POST['x_country'],
        'zip' => $_POST['x_zip'],
        'email' => $_POST['x_email'],
        'card_code' => $_POST['x_card_code'],
        )
    );
    $response = $transaction->authorizeAndCapture();
 
 

Thank in advance for your help

 

 

 

SeanF
Member
4 REPLIES 4
@SeanF

When you use getters and setters, the set sets the property value and the get retrieves the property value after it is set. Here you appear to be unnecessarily calling a get method before the property value is set. So first order of business is to remove those getters. I haven’t used any class files for aim, so I can’t tell you if the rest of your code is correct.

You will like the API. Post your code on here when you get started and I will look out for your posts. This is my hobby while waiting at restaurants or having sick days. I can help you much more on the new stuff.
Renaissance
All Star

You'll need to add an invoice parameter to the setFields array. There's likely more to it, but that's what I see from the snippet.

 

The invoice field name for AIM is x_invoice_num, so ultimately you'll need to populate that parameter.

 

You can still find old documentation out in the wild if you search for Authorize.Net Advanced Integration Method (AIM) Developer Guide.

mmcguire
Administrator Administrator
Administrator

 

 

{
    "amount": 1000,
    "amount_capturable": 1000,
    "authorization_reason": "blocking_funds",
    "base_currency_code": "USD",
    "currency_code": "USD",
    "customer_id": "__test__KyVnJjRnFZ3zL6Bq",
    "date": 1578726872,
    "deleted": false,
    "exchange_rate": 1,
    "fraud_reason": "Payment complete.",
    "gateway": "stripe",
    "gateway_account_id": "gw___test__KyVnLVRnFZ3weH8",
    "id": "txn___test__KyVnJjRnFZ4Gc6Bv",
    "id_at_gateway": "ch_1FzeB2Jv9j0DyntJhlx2ZE3G",
    "linked_payments": [],
    "masked_card_number": "************1111",
    "object": "transaction",
    "payment_method": "card",
    "payment_source_id": "pm___test__KyVnJjRnFZ4Fe6Br",
    "resource_version": 1517469273000,
    "status": "success",
    "type": "authorization",
    "updated_at": 1517469273
}

Creates a one-off invoice for multiple 'Non Recurring' addon & ad-hoc charges for a customer. If the 'auto collection' has been turned 'on' for that customer then payment will be immediately collected using the payment method associatepayments alaskasworld.comd with the customer. The invoice will be generated only upon successful collection of alaskasworld.com

 

Ross
Member

Can somebody please review my code and help me to resolve the issue during execution of the same please.

 

return paypal.rest.payment.create(env, client, {

                    // payment options here
                    intent: 'authorize',

                    transactions: [{
                        amount: {
                            total: ngCart.totalCost(),
                            currency: 'EUR',
                            details: {
                                subtotal: ngCart.getSubTotal(),
                                tax: ngCart.getTaxRate(),
                                shipping: ngCart.getShipping()
                            }
                        },
                        description: 'Deine Bestellung bei LChoice',
                        //Pass-through variable you can use to identify your invoice number for this purchase. Default — No variable is passed back to you.
                        invoice_number: '48787589673xbrr',
                        // purchase_order: '48787589673',
                        // CUSTOM: Pass-through variable for your own tracking purposes, which buyers do not see. Default — No variable is passed back to you. 
                        // custom: 'EBAY_EMS_90048630024435',
                        // soft_descriptor: 'ECHI5786786',

                        item_list: {
                            items: i2,
                        }

                    }],
                    // note_to_payer: 'Contact us for any questions on your order.',
                }, {
                    // experience options here
                    input_fields: {
                        no_shipping: 1
                    }
                })

Actually, this code was generated for one of my client Alaskasworld . Originally, the invoice number does not show up in the buyers account. I am trying to correct the issue, however, still the code is not giving the desired result. Please check, if you can able to resolve the issue or can have some better solution. Thanks.

PUKO
Member