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 all 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
72 changes: 2 additions & 70 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 @@ -83,35 +44,6 @@ Each feature module has its own onboarding guide:

To accept a certain payment method in your app, you only need to include that payment-specific submodule.

## Sample Code

```swift
// STEP 0: Fetch an ACCESS_TOKEN and ORDER_ID from your server.

// STEP 1: Create a PaymentConfiguration object
paymentConfig = PaymentConfig(token: ACCESS_TOKEN)

// STEP 2: Create payment method client objects
cardClient = CardClient(config: paymentConfig)

// STEP 3: Collect relevant payment method details
card = Card(number: 4111111111111111, cvv: 123, ...)

// STEP 4: Call checkout method
cardClient?.checkoutWithCard(orderID: ORDER_ID, card: card) { result in
switch result {
case .success(let orderId):
// Send orderID to your server to process the payment
case .error(let error):
// handle checkout error
}
}

// STEP 5: Send orderID to your server to capture/authorize

```


## Testing

This project uses the `XCTest` framework provided by Xcode. Every code path should be unit tested. Unit tests should make up most of the test coverage, with integration, and then UI tests following.
Expand Down
6 changes: 3 additions & 3 deletions docs/CardPayments/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Follow these steps to add Card payments:
## Setup a PayPal Developer Account

You will need to set up authorization to use the PayPal Payments SDK.
Follow the steps in [Get Started](https://developer.paypal.com/api/rest/#link-getstarted) to create a client ID and generate an access token.
Follow the steps in [Get Started](https://developer.paypal.com/api/rest/#link-getstarted) to create a client ID.

You will need a server integration to create an order and capture the funds using [PayPal Orders v2 API](https://developer.paypal.com/docs/api/orders/v2).

Expand All @@ -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