Server-side Implementation

Create payment methodAnchorIcon

Once the customer has successfully authenticated with PayPal, you can use one of the following calls to create a payment method. You will be using this payment method for processing transactions against the PayPal Order.

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
]);

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
    ]
);

$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.

Process transactionsAnchorIcon

Use the transaction API to process customer payments against the PayPal Order:

Currency supportAnchorIcon

The customer will be charged in the currency associated with the merchantAccountId passed in the Transaction: Sale call. We support all currencies that PayPal REST APIs support. For details on accepting foreign currencies with PayPal, see our PayPal account setup guide.

Seller ProtectionAnchorIcon

By passing a shipping address, you may also be eligible for PayPal Seller Protection. You can check the status of Seller Protection as follows:
  1. PHP
$transaction = $gateway->transaction()->find('the_transaction_id');

$transaction->paypalDetails->sellerProtectionStatus;
# "ELIGIBLE"

Void an orderAnchorIcon

As the PayPal Order is represented by a customer's payment method, to void an order you need to delete the payment method by calling Payment Method: Delete.