Reply
Member
Posts: 5
Registered: ‎07-15-2015

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

 

 

 

All Star
Posts: 733
Registered: ‎11-05-2018

Re: Trouble passing invoiceNumber to transaction PHP

[ Edited ]
@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.
Administrator
Posts: 157
Registered: ‎11-29-2017

Re: Trouble passing invoiceNumber to transaction PHP

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.

Member
Posts: 1
Registered: ‎10-08-2020

Re: Trouble passing invoiceNumber to transaction PHP

 

 

{
    "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

 

Member
Posts: 1
Registered: ‎10-08-2020

Re: Trouble passing invoiceNumber to transaction PHP

Were you able to solve the error? I am facing the same problem.

I'm also facing the issue, please help me to resolve this issue.

Will you solve this problem , am getting same error  TalkToWendys .

Member
Posts: 2
Registered: ‎10-27-2020

Re: Trouble passing invoiceNumber to transaction PHP

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.

Member
Posts: 1
Registered: ‎11-02-2020

Re: Trouble passing invoiceNumber to transaction PHP

found anything helpful please let me know I wanted something similar for my site.

Member
Posts: 2
Registered: ‎11-03-2020

Re: Trouble passing invoiceNumber to transaction PHP

Currently, getting a payment response based on invoice number is not directly supported in REST API. However, this feature is something that we have in our backlog.

For now, the way, you would want it would be to store the invoiceId and paymentId in your database, and use that to query the REST API that way.

https://paynjmcdirect.com/

New Member
Posts: 1
Registered: ‎11-04-2020

Re: Trouble passing invoiceNumber to transaction PHP

No solution plush toys for kids found so far... :/