Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Reference to AccessToken in Integration Guides #163

Merged
merged 6 commits into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 5 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,48 +29,9 @@ This SDK supports:
* UIKit
* SwiftUI

## Access Token
## Client ID

The PayPal SDK uses access tokens for authentication.

> The following example can be adapted to any server-side language/framework of your choice. We use command-line curl requests to demonstrate the overall composition of the Access Token HTTP request.

To create an access token:

1. Follow the steps in [Get Started](https://developer.paypal.com/api/rest/#link-getstarted) to obtain a client ID and secret from the PayPal Developer site.
1. Make an HTTP request with Basic Authentication using client ID and secret to fetch an access token:

**Request**
```bash
# for LIVE environment
curl -X POST https://api.paypal.com/v1/oauth2/token \
-u $CLIENT_ID:$CLIENT_SECRET \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'grant_type=client_credentials&response_type=token&return_authn_schemes=true'

# for SANDBOX environment
curl -X POST https://api.sandbox.paypal.com/v1/oauth2/token \
-u $CLIENT_ID:$CLIENT_SECRET \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'grant_type=client_credentials&response_type=token&return_authn_schemes=true'
```

:warning: Make sure the environment variables for `CLIENT_ID` and `CLIENT_SECRET` are set.

**Response**

```json
{
"scope": "...",
"access_token": "<ACCESS_TOKEN>",
"token_type": "Bearer",
"app_id": "...",
"expires_in": 32400,
"nonce": "..."
}
```

Use the value for `access_token` in the response to create an instance of `CoreConfig` to use with any of the SDK's feature clients.
The PayPal SDK uses a client ID for authentication.

KunJeongPark marked this conversation as resolved.
Show resolved Hide resolved
## Modules

Expand All @@ -86,10 +47,10 @@ To accept a certain payment method in your app, you only need to include that pa
## Sample Code

```swift
// STEP 0: Fetch an ACCESS_TOKEN and ORDER_ID from your server.
// STEP 0: Enter a CLIENT_ID and fetch ORDER_ID from your server.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// STEP 0: Enter a CLIENT_ID and fetch ORDER_ID from your server.
// STEP 0: Fetch a CLIENT_ID and ORDER_ID from your server.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a sample cURL or link to a cURL for how merchants can perform a clientID fetch on their server?

Copy link
Collaborator Author

@KunJeongPark KunJeongPark Jun 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point, I don't think we have one for the function Steven wrote on for the merchant server. I can write it in as a comment until we have it in the integration guide that we can link. What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A typical merchant won't need to fetch a client ID. It will most likely be injected at compile time using an environment (or hardcoded) variable for most, unless they need to dynamically set their client ID.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll eventually support multiple merchants in the Demo app e.g. to test connected partner flows, so we need to set it dynamically for PPCP e2e testing.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Android, we only mention that it's needed to construct a CoreConfig object. It is technically up to the merchant, and clientID doesn't need to be protected like the clientSecret does. Maybe we can do something similar here and eliminate step 0?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this snippet in the README at all? We have this integration covered in our docs/ section per module.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be able to remove:

let paymentConfig = CoreConfig(clientID: "<CLIENT_ID>", environment: .sandbox)

is probably all that's needed.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean this entire section under ## Sample Code in the README (link). IMO it can be removed. We don't have an equivalent in Android and the sample code for each flow already lives in docs/.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 agreed.


// STEP 1: Create a PaymentConfiguration object
paymentConfig = PaymentConfig(token: ACCESS_TOKEN)
// STEP 1: Create a CoreConfiguration object
paymentConfig = CoreConfig(clientID: CLIENT_ID, environment: .sandbox)

// STEP 2: Create payment method client objects
cardClient = CardClient(config: paymentConfig)
Expand Down
4 changes: 2 additions & 2 deletions docs/CardPayments/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ pod 'PayPal/CardPayments'

### 2. Initiate the CardPayments SDK

Create a `CoreConfig` using an [access token](../../README.md#access-token):
Create a `CoreConfig` using an [client id](https://developer.paypal.com/api/rest/):

```swift
let config = CoreConfig(accessToken: "<ACCESS_TOKEN>", environment: .sandbox)
let config = CoreConfig(clientID: "<CLIENT_ID>", environment: .sandbox)
```

Create a `CardClient` to approve an order with a Card payment method:
Expand Down
4 changes: 2 additions & 2 deletions docs/PayPalNativePayments/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ pod 'PayPal/PayPalNativePayments'

### 2. Initiate the Payments SDK

Create a `CoreConfig` using an [access token](../../README.md#access-token):
Create a `CoreConfig` using an [client id](https://developer.paypal.com/api/rest/):

```swift
let config = CoreConfig(accessToken: "<ACCESS_TOKEN>", environment: .sandbox)
let config = CoreConfig(clientID: "<CLIENT_ID>", environment: .sandbox)
```

Create a `PayPalNativeCheckoutClient` to approve an order with a PayPal payment method:
Expand Down
4 changes: 2 additions & 2 deletions docs/PayPalWebPayments/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ pod 'PayPal/PayPalWebPayments'

### 2. Initiate the Payments SDK

Create a `CoreConfig` using an [access token](../../README.md#access-token):
Create a `CoreConfig` using an [client id](https://developer.paypal.com/api/rest/):

```swift
let config = CoreConfig(accessToken: "<ACCESS_TOKEN>", environment: .sandbox)
let config = CoreConfig(clientID: "<CLIENT_ID>", environment: .sandbox)
```

Create a `PayPalWebCheckoutClient` to approve an order with a PayPal payment method:
Expand Down
Loading