Skip to content

Commit

Permalink
Better docs
Browse files Browse the repository at this point in the history
  • Loading branch information
smikhalevski committed Mar 13, 2024
1 parent 26b6373 commit a13e842
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,20 @@ class MainActivity : AppCompatActivity() {
}
```

Usual flow to tokenize a card or resume a previously aborted tokenization:
To get the token info from the wallet use:

```ts
import { googlePayManager, GooglePayTokenInfo, GooglePayTokenServiceProvider } from 'racehorse';

async function getTokenInfo(lastFour: string): GooglePayTokenInfo | undefined {
(await googlePayManager.listTokens()).find(tokenInfo =>
(tokenInfo.dpanLastFour === lastFour || tokenInfo.fpanLastFour === lastFour) &&
tokenInfo.tokenServiceProvider === GooglePayTokenServiceProvider.MASTERCARD
);
}
```

To tokenize a card or resume a previously aborted tokenization:

```ts
import {
Expand Down Expand Up @@ -965,17 +978,20 @@ async function tokenizeCard(lastFour: string): GooglePayTokenInfo {
network: GooglePayCardNetwork.MASTERCARD,
tokenServiceProvider: GooglePayTokenServiceProvider.MASTERCARD,
// displayName
})
});
}

return getTokenInfo(lastFour);
}
```

async function getTokenInfo(lastFour: string): GooglePayTokenInfo | undefined {
(await googlePayManager.listTokens()).find(tokenInfo =>
(tokenInfo.dpanLastFour === lastFour || tokenInfo.fpanLastFour === lastFour) &&
tokenInfo.tokenServiceProvider === GooglePayTokenServiceProvider.MASTERCARD
);
To open a wallet app and reveal the tokenized card use:

```ts
async function revealCard(lastFour: string): Promise<boolean> {
const tokenInfo = await getTokenInfo(lastFour);

return tokenInfo ? googlePayManager.viewToken(tokenInfo.issuerTokenId, tokenInfo.tokenServiceProvider) : false;
}
```

Expand Down

0 comments on commit a13e842

Please sign in to comment.