Additional Options

When creating a payment method, you can pass additional options on the server side to manage the transactions processed against the PayPal Order.
  • Amount: Allows you to update the amount of the shopping cart that was approved by the Buyer. Note the currency can't be updated at this step. It has to match the currency passed at the time of tokenizing the payment.
  • Order ID: Use this field to pass additional information about the PayPal Order. When it comes to the Order itself, the Order ID stays on Braintree. However, in the case of the PayPal Order's captures, Order IDs are received by the PayPal API and are recorded under 'invoice number' on PayPal's side. These invoice numbers can be used for lookup in the PayPal Console for captures. PayPal invoice numbers must be unique in your PayPal business account.
  • Custom field: Use this field to pass information directly to PayPal via the API for your own tracking purposes. Customers do not see this value, but you can see it in reports from your PayPal console.
  • Description: Description of the transaction that is displayed to customers in PayPal email receipts. Max 127 characters.
  • Shipping: Shipping destination address input.

ExamplesAnchorIcon

Create a new customer with a payment methodAnchorIcon

If you do not already have a record for this customer in your Vault, you can create a new customer with a payment method using Customer: Create with the paymentMethodNonce parameter.
  1. PHP
$result = $gateway->customer()->create([
    'firstName' => 'Mike',
    'lastName' => 'Jones',
    'company' => 'Jones Co.',
    'paymentMethodNonce' => nonceFromTheClient,
    'options' => [
        'paypal' => [
            'amount' => '10.00',
            'orderId' => 'PayPal_Invoice_Number',
            'customField' => 'My_Custom_Field',
            'description' => 'My_Description',
            'shipping' => [
                'firstName' => 'Mike',
                'lastName' => 'Jones',
                'locality' => 'San Jose',
                'postalCode' => '95131',
                'streetAddress' => '111 Main St',
                'region' => 'CA',
                'countryCodeAlpha2' => 'US'
            ]
        ]
    ]
]);

if ($result->success) {
    echo($result->customer->id);
    echo($result->customer->paymentMethods[0]->token);
} else {
    foreach($result->errors->deepAll() AS $error) {
        echo($error->code . ": " . $error->message . "\n");
    }
}

Update an existing customer with a payment methodAnchorIcon

If the customer already exists in your Vault, you can add a new payment method to that customer using Customer: Update with the paymentMethodNonce parameter.
  1. PHP
$updateResult = $gateway->customer()->update(
    'a_customer_id', [
        'paymentMethodNonce' => nonceFromTheClient,
        'options' => [
            'paypal' => [
                'amount' => '10.00',
                'orderId' => 'PayPal_Invoice_Number',
                'customField' => 'My_Custom_Field',
                'description' => 'My_Description',
                'shipping' => [
                    'firstName' => 'Mike',
                    'lastName' => 'Jones',
                    'locality' => 'San Jose',
                    'postalCode' => '95131',
                    'streetAddress' => '111 Main St',
                    'region' => 'CA',
                    'countryCodeAlpha2' => 'US'
                ]
            ]
        ]
    );

$updateResult->success true if update was successful
If the customer can't be found, you'll receive a Braintree\Exception\NotFound exception. Alternatively, you can use Payment Method: Create to accomplish the same thing as above.