@nftlabsupplies/ngx-paperxyz-sdk
v1.0.2
Published
<p align="center"> <br /> <a href="https://paper.xyz"><img src="./src/assets/paper-logo.svg" width="100" alt=""/></a> <br /> </p> <h1 align="center">(Unofficial) Paper Angular SDK</h1> <p align="center"> <!-- TODO: Update --> <!-- <a href
Downloads
7
Maintainers
Readme
Paper is a developer-first NFT checkout solution that easily onboards users without wallets or cryptocurrencies.
Documentation
Installation
Install ngx-paperxyz-sdk with npm:
npm i @nftlabsupplies/ngx-paperxyz-sdk
Usage/Examples
Import SDK module in app:
import { NgxPaperXYZSdk } from '@nftlabsupplies/ngx-paperxyz-sdkk';
imports: [..., NgxPaperXYZSdk.forRoot({ chainName: "Rinkeby", checkoutId: 'your-checkout-id' })],
Implement in html:
<div style="margin-bottom: 1rem; padding: 0.5rem 0">
<label>Email:</label>
<input type="text" [formControl]="control" />
</div>
<paper-create-wallet
[emailAddress]="control.value!"
[disabled]="!control.valid"
(success)="onCreateWalletSuccess($event.walletAddress, $event.emailAddress)"
(error)="onCreateWalletError($event.code, $event.error)"
(emailVerificationPending)="onCreateWalletVerificationPending()"
>
Verify email
</paper-create-wallet>
<br />
<br />
<paper-pay-with-card
*ngIf="email"
[recipientWalletAddress]="wallet"
[emailAddress]="email"
[quantity]="1"
(paymentSuccess)="onCheckoutPaymentSuccess($event.id)"
(transferSuccess)="onCheckoutTransferSuccess($event.id)"
(review)="onCheckoutReview($event.id)"
(cancel)="onCheckoutCancel()"
(error)="onCheckoutError($event.code, $event.error)"
></paper-pay-with-card>
Implement in component:
control = new FormControl('', [Validators.required, Validators.email]);
email = '';
wallet = '';
onCreateWalletSuccess(walletAddress: string, emailAddress: string): void {
console.log('App: Create wallet handler: Success.', walletAddress, emailAddress);
this.email = emailAddress;
this.wallet = walletAddress;
}
onCreateWalletError(code: PaperSDKErrorCode, error: Error): void {
console.log('App: Create wallet handler: Error.', code, error);
}
onCreateWalletVerificationPending(): void {
console.log('App: Create wallet handler: Pending email verification.');
}
onCheckoutPaymentSuccess(id: string): void {
console.log('App: Checkout payment success.', id);
}
onCheckoutTransferSuccess(id: string): void {
console.log('App: Checkout transfer success.', id);
}
onCheckoutReview(id: string): void {
console.log('App: Checkout review.', id);
}
onCheckoutCancel(): void {
console.log('App: Checkout cancel.');
}
onCheckoutError(code: PaperSDKErrorCode, error: Error): void {
console.log('App: Checkout error.', code, error);
}