Server-side configuration
ImportantYour integration may be impacted by upcoming certificate changes. Visit our best practices guide to learn more.
1. Place transaction
- Ruby
result = gateway.transaction.sale( { amount: "10.00", payment_method_nonce: params[:payment_method_nonce], device_data: params[:device_data], order_id: "Mapped to PayPal Invoice Number", options: { submit_for_settlement: true, paypal: { custom_field: "PayPal custom field", description: "Description for PayPal email receipt", }, }, line_items: [{ quantity: 1, name: "name", kind: "debit", unit_amount: "10.00", total_amount: "10.00", upc_code: "01234567891", # new field upc_type: "UPC-A", # new field url: "https://example.com", # new field image_url: "https://example.com/product1.jpeg" # new field }] }) if result.success? # Assuming you have a method to create tracking for the transaction create_tracking(result.transaction.id) "Success ID: #{result.transaction.id}" else result.message end # Method to create tracking for the transaction def create_tracking(transaction_id) # Your implementation here end2. Create tracking for transaction after submitting for settlement:
- Ruby
# Send the package tracking request for the transaction packageResult = Braintree::Transaction.package_tracking( transactionId, # Create a Package Tracking request with optional line items { carrier: "UPS", notify_payer: true, tracking_number: "tracking_number_1", line_items: [ # Optionally create line items { product_code: "ABC 01", name: "Product Name", quantity: "1", description: "Product Description", upc_code: "01234567891", # new field upc_type: "UPC-A", # new field url: "https://example.com", # new field image_url: "https://example.com/product1.jpeg" # new field }, { product_code: "ABC 01", name: "Product Name", quantity: "1", description: "Product Description", } ], } ) packages = packageResult.transaction.packages; id = packages[0].id; tracking_number = packages[0].tracking_number; carrier = packages[0].carrier; # The PayPal tracker ID will not be immediately available in response to # package_tracking(). But it should be there when the merchant does a findTransaction # request at a later stage.3. Retrieve transactions with package trackers:
- Ruby
# Get more details of the individual packages like so, # replace 0 with the element index transaction = Braintree::Transaction.find(transactionId); id = transaction.packages[0].id; tracking_number = transaction.packages[0].tracking_number; carrier = transaction.packages[0].carrier; paypal_tracker_id = transaction.packages[0].paypal_tracker_id; # The PayPal tracker ID will not be immediately available in response to # package_tracking(). But should be there when merchant does a findTransaction # request at a later stage.