> ## Documentation Index
> Fetch the complete documentation index at: https://docs.slm.m1amdocs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# AutoBill.finalizePayPalAuth

The `finalizePayPalAuth` method completes the authorization of a PayPal payment method validation transaction. This method enables you to report the status of the validation transaction to Subscribe. Use this method only when you are working with an `AutoBill` that is paid for with a PayPal-based payment method.

Subscribe generates the validation transaction when you create the `AutoBill` by calling the `update()` method with the `validateForFuturePayment` flag turned on. The `update()` call returns a PayPal site URL to you; ask your customer to visit that URL so that they may complete the authorization activities necessary to validate the payment method at PayPal’s site. After the customer finishes the authorization at the PayPal Web site, and is redirected to your site, call `finalizePayPalAuth()` from either the success page (`returnUrl` specified in the PayPal payment method) or failure page (`cancelUrl` specified in the payment method) to which the customer was redirected. The `AutoBill` will start billing only after this finalization is completed and authorization of the underlying validation is known to Subscribe.

For more information on applying tax to PayPal transactions, please see the [Transaction.addressAndSalesTaxFromPayPalOrder](Transaction_addressAndSa) method.

## Input

*srd*: sparse response description, a SOAP string (which must be a JSON object), in which you specify the elements you want returned.This parameter enables the calling system to constrain a `method` call to return only components you specify. This gives you greater control over returned content, and improves response time within the Vindicia platform by reducing the processing needed for the call.

Some fields are required, either practically or in the WSDL, and will be returned regardless of the *srd*. A null *srd* returns the complete response.

*payPalTransactionId*: Vindicia’s ID for the PayPal payment method validation `Transaction`, generated when you called `AutoBill.update`. Retrieve this ID from the value associated with the name: `vindicia_vid` in the name–value pairs attached to the redirect URL.

*success*: set by you. Set it to `true` if the customer successfully authorized the validation transaction at PayPal’s site and was redirected to the success page (`returnUrl`) hosted by you. If the customer was redirected to the failure page (`cancelUrl`), set this to `false`.

## Output

*return*: an object of type `Return` that indicates the success or failure of the call.

*authStatus*: a `TransactionStatus` object. Its `payPalStatus` attribute contains return codes received from PayPal while authorizing the transaction.

*autobill*: the `AutoBill` object for which this method finalized the PayPal validation transaction. It contains the updated status of the `AutoBill` after the finalization. For example, if the validation was successful, the `AutoBill` should have an `Active` status.

## Returns

In addition to those listed in [The Return Object](The_Return_Object), this call returns:

| Return Code | Return String |
| - | - |
| `400` | *Internal-error-string.* |

**Note:**

In some cases, after your customer has authorized payment on the PayPal site, PayPal will (invisibly) return a 10417 response code:

`Hard Failure: Account not associated with a usable funding source. Credit card or Billing Agreement is required to complete payment method.`

Upon calling `Transaction.finalizePayPalAuth`, Subscribe will then return the error message:

`Merchant and PayPal consider transaction to be in different states: 0 vs. 1.`

## Example

```

// to finalize a PayPal authorization

$soap_caller = new AutoBill();

// obtain id of the PayPal validation transaction
// from the redirect URL. It is the value associated with name
// 'vindicia_vid'

$payPalTxId = … ;

// if calling from return URL which is reached when the PayPal
// transaction is successfully authorized you should set the
// success input parameter to true

$success = true;
$response = 
   $soap_caller->finalizePayPalAuth($payPalTxId, $success);

if($response['returnCode'] == 200) {
   printLog "PayPal validation transaction successful";
   $updatedAutoBill = $response['data']->autobill;
   printLog " AutoBill id " . 
      $updatedAutoBill->get() . "\n";

   printLog " AutoBill status " 
      . $updatedAutoBill->getStatus() . "\n";
}
```

**Parent topic:**[AutoBill Methods](../topics/AutoBill_Methods)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.