Paypal Data Options

This topic contains 1 reply, has 2 voices, and was last updated by  Stephen Harris 10 years, 1 month ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #10100

    Hey Stephen!

    I feel like I may be forgetting something obvious, but I cannot figure out with my current configuration (all most recent versions) how to specify which parts of an event are submitted as relevant information in the paypal Item ID and custom info fields. It would be great to know how to control which data gets reported and where.

    Also considering adding a custom field that would be an event id code just for the accountant’s use. Any advice about how to best accomplish that?

    Thank you, as always.

    Ann/Caitlin Wiegand/Everett
    #10155

    Yes, you can use the hook eventorganiser_pre_gateway_checkout_paypal. E.g.:

    function my_alter_paypal_cart( $cart, $booking ){
        //$booking is an array. $booking['booking_id'] contains the booking ID
        /*
        $cart is of the form:
        $cart = array(
             'return' => //return url
             'item_name_0' => //Ticket name,
             'amount_0' => //Ticket price
             'quantity_0' => //Ticket quantity,
             'item_name_1' => //Ticket name (second ticket type),
             'amount_1' => //Ticket price (second ticket type),
             'quantity_1' => //Ticket quantity (second ticket type),
            ....
             'custom' => //custom data as query variables. e.g. booking_id=X&event_id=Y...
        );
        */
        //Adjust $cart and return it        
        return $cart;
    }
    add_filter( 'eventorganiser_pre_gateway_checkout_paypal', 'my_alter_paypal_cart', 5, 2 );

    The custom key allows you to send extra data to PayPal. However, by default, extra data won’t ‘do’ anything. But should be viewable in PayPal. Please note that the value of the custom is key is a query string, e.g. field_1=value_1&field_2=vaue_2..... So if you wish to change the data sent you could do:

     //Turn query string into array in $custom
     parse_str( $cart['custom'], $custom );
    
     //Alter $custom array. Do not change booking_id!
    
     //Re-build custom query string with the altered $custom array
     $cart['custom'] = build_query( $custom );

    Note, you should never alter booking_id, as the plug-in relies on this. By default included data is booking ID, event ID, occurrence ID, (booking) user ID, ticket quantity.

    Does that help?

    Stephen Harris
Viewing 2 posts - 1 through 2 (of 2 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.