-
-
Notifications
You must be signed in to change notification settings - Fork 539
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for checking platform pay availability on web
* Partially addresses #1122
- Loading branch information
Showing
14 changed files
with
1,292 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
packages/stripe_js/lib/src/js/payment_requests/payment_item.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import 'package:js/js.dart'; | ||
|
||
@anonymous | ||
@JS() | ||
abstract class PaymentItem { | ||
external factory PaymentItem({ | ||
required num amount, | ||
required String label, | ||
bool pending, | ||
}); | ||
|
||
external String label; | ||
external num amount; | ||
external bool pending; | ||
} |
46 changes: 46 additions & 0 deletions
46
packages/stripe_js/lib/src/js/payment_requests/payment_request.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import 'package:js/js.dart'; | ||
import 'package:stripe_js/stripe_js.dart'; | ||
|
||
extension PaymentRequestExtension on Stripe { | ||
_JS get _js => this as _JS; | ||
|
||
PaymentRequest paymentRequest( | ||
PaymentRequestCreateOptions options, | ||
) { | ||
return PaymentRequest.of(_js.paymentRequest(options)); | ||
} | ||
} | ||
|
||
class PaymentRequest { | ||
final _JSPaymentRequest _js; | ||
|
||
PaymentRequest.of(this._js); | ||
|
||
String get id => _js.id; | ||
|
||
Future<CanMakePaymentResponse?> canMakePayment() => | ||
promiseToFuture(_js.canMakePayment()); | ||
} | ||
|
||
@anonymous | ||
@JS() | ||
abstract class _JS { | ||
external _JSPaymentRequest paymentRequest( | ||
PaymentRequestCreateOptions options, | ||
); | ||
} | ||
|
||
@anonymous | ||
@JS() | ||
abstract class _JSPaymentRequest { | ||
external String get id; | ||
external Promise<CanMakePaymentResponse?> canMakePayment(); | ||
} | ||
|
||
@anonymous | ||
@JS() | ||
abstract class CanMakePaymentResponse { | ||
external bool get applePay; | ||
external bool get googlePay; | ||
external bool get link; | ||
} |
29 changes: 29 additions & 0 deletions
29
packages/stripe_js/lib/src/js/payment_requests/payment_request_creation_options.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import 'package:js/js.dart'; | ||
import 'package:stripe_js/stripe_js.dart'; | ||
|
||
@anonymous | ||
@JS() | ||
abstract class PaymentRequestCreateOptions { | ||
@JS("PaymentRequestCreateOptions") | ||
external factory PaymentRequestCreateOptions({ | ||
required String country, | ||
required String currency, | ||
required PaymentItem total, | ||
bool requestPayerName, | ||
bool requestPayerEmail, | ||
bool requestPayerPhone, | ||
bool requestShipping, | ||
List<ShippingOption> shippingOptions, | ||
List<String> disableWallets, | ||
}); | ||
|
||
external String country; | ||
external String currency; | ||
external PaymentItem total; | ||
external bool requestPayerName; | ||
external bool requestPayerEmail; | ||
external bool requestPayerPhone; | ||
external bool requestShipping; | ||
external ShippingOption shippingOptions; | ||
external List<String> disableWallets; | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/stripe_js/lib/src/js/payment_requests/payment_requests.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export 'payment_item.dart'; | ||
export 'payment_request.dart'; | ||
export 'payment_request_creation_options.dart'; | ||
export 'shipping_option.dart'; |
17 changes: 17 additions & 0 deletions
17
packages/stripe_js/lib/src/js/payment_requests/shipping_option.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import 'package:js/js.dart'; | ||
|
||
@anonymous | ||
@JS() | ||
abstract class ShippingOption { | ||
external factory ShippingOption({ | ||
required String id, | ||
required String label, | ||
required String detail, | ||
required num amount, | ||
}); | ||
|
||
external String id; | ||
external String label; | ||
external String detail; | ||
external num amount; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.