• Resolved leavai

    (@lparga)


    Hi!

    I need to send products information (quantity, price) to my Braintree Account after checkout and shipping costs.

    At present, only order ID and customer detail are sended.

    I attach a log about the info is sended by the plugin

    Processing order 6904. Attribs: Array ( [amount] => 148.23 [taxAmount] => 0 [customerId] => 500053593 [customer] => Array ( [firstName] => Luis [lastName] => Perez[phone] => 11445566 [email] => [email protected] [company] => ) [paymentMethodNonce] => 83b0738d-d055-00f5-6797-8f22397112ef [orderId] => WC6904 [billing] => Array ( [firstName] => Luis[lastName] => Perez [locality] => London [postalCode] => 1744 [region] => B [streetAddress] => address [extendedAddress] => [countryCodeAlpha2] => AR ) [shipping] => Array ( [firstName] => Luis[lastName] => Perez[locality] => London [postalCode] => 1744 [region] => B [streetAddress] => address [extendedAddress] => [countryCodeAlpha2] => AR ) [channel] => PaymentPlugins_BT [options] => Array ( [submitForSettlement] => 1 [threeDSecure] => Array ( [required] => 1 ) ) [creditCard] => Array ( [cardholderName] => Luis Perez ) )

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Payment Plugins

    (@mrclayton)

    Hi @lparga,

    Our plugin calls a filter right before the order is processed, which allows merchants to add additional attributes to the transaction.

    apply_filters ( "braintree_woocommerce_{$this->id}_order_attributes", $attribs, $order, $this );

    where $this is a reference to the current payment gateway and $attribs are the transaction attributes.

    You should use this filter to add the lineItems to your transaction and they will show in your Braintree control panel

    You can use the get_items method of the WC_Order to retrieve the items. The following link is from WC’s order code.

    https://docs.woocommerce.com/wc-apidocs/source-class-WC_Abstract_Order.html#708-731

    Here is Braintree’s documentation on lineItems:

    https://developers.braintreepayments.com/reference/request/transaction/sale/php#line_items

    I will look at adding the lineItems as a default attribute in a future release.

    Kind Regards,

    Thread Starter leavai

    (@lparga)

    Hi! thanks for your reply. I found that filter in the class-wc-braintree-gateway file. I added the following code to this line

    $attribs = array( 
    
    'amount' => $order->get_total (), 
    'lineItems' => $order->get_items(), //this is my new line
    
    'taxAmount' => bwc_is_wc_3_0_0_or_more () ? wc_round_tax_total ( $order->get_total_tax () ) : $order->get_total_tax () 
    );

    How could I send only the product info like product name, price, quantity and shipping info?

    Thank you four your help!

    • This reply was modified 5 years, 4 months ago by leavai.
    Plugin Author Payment Plugins

    (@mrclayton)

    Hi @lparga,

    The plugin already populates the amount and taxAmount attributes so you shouldn’t need to do that.

    The link I provided you for Braintree’s developer documentation shows the attribute names you will need to use to add your line items.

    Basically you need to loop through each item of the order then add use the item to populate the transaction attributes.

    Kind Regards,

    Plugin Author Payment Plugins

    (@mrclayton)

    Hi @lparga,

    We added this functionality to the 3.0.0 release candidate. We are asking merchants to test this version before we release to the repository.

    https://support.paymentplugins.com/hc/en-us/articles/360026512014-3-0-0-Release-Candidate

    Here is an example of what the code does:

    $items = array();
    		foreach ( $order->get_items ( 'line_item' ) as $item ) {
    			/**
    			 *
    			 * @var WC_Order_Item_Product $item
    			 */
    			$product = $item->get_product ();
    			$items[] = array( 
    					'description' => sprintf ( '%s x %s', $product->get_name (), $item->get_quantity () ), 
    					'kind' => 'debit', 
    					'name' => $item->get_name (), 
    					'productCode' => $product->get_id (), 
    					'quantity' => $item->get_quantity (), 
    					'totalAmount' => $item->get_total (), 
    					'unitAmount' => $product->get_price () 
    			);
    		}
    		$args[ 'lineItems' ] = $items;

    Kind Regards,

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Send products info’ is closed to new replies.