-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SCA Updates - PaymentIntents & SetupIntents management (#81)
* Update angular-demo to NS6 * Update demo to NS6 * Update android-sdk to 10.2.1 * Remove dev-typescript * migrate API * restore SDK 8.7.0 * Use androidx * fix namespace * fix app start * remove bundle and uglify * Restore 10.2.1 SDK * Fix merge issue * Update defs * Enable multidex * Bump minSDK version * Update {N} version on travis * Remove useless template * Rename _android var to _widget * fix commas * Implements createPaymentMethod * Add debug run * Add stripe3ds2 typings * Init PaymentConfiguration before CustomerSession * Fix requestPayment on Android * Cleans * Update typings * Update xcode and node versions * Fix frame is undefined * Add webpack configs to demos * confirmPaymentIntent uses StripePaymentIntentParams * Add create intent endpoint * Demo Intent * PaymentConfiguration.init called once * Update paymentIntent conf * Update ios podfile to 16.0.6 * Fix creditcard view * Fix paymentContextDidCreatePaymentResultCompletion * add debug demo.ios * Remove deleted createCardSources attribute * tmp paymentWithAuthent * Changelog * Remove unused import * Fix authentification context * Add status * Factorize StripeIntent * Clean component * cleans * Remove source and use payment method * remove source * Restore keys * Update SDK in README * Fix semicolons * trailing spaces * cleans * refactor stripeIntent for Android * Update README * tslint * Exclude platforms from tslint * Handle automatic and manual payment intent flows * fix tslint * Update README and Changelog * feedbacks * cleans * requiresCapture helper * Bump version * Fix ios contextMethod from modals * fix linter * Remove confirmPaymentIntent from index.d.ts * Fix keyUpdateListener.onKeyUpdateFailure error * Push last PR updates
- Loading branch information
1 parent
9960971
commit fa58a2d
Showing
32 changed files
with
9,462 additions
and
5,141 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
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
This file was deleted.
Oops, something went wrong.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<StackLayout class="page"> | ||
<CreditCardView #card></CreditCardView> | ||
|
||
<Button | ||
text="Save Credit Card - Setup Intent" | ||
(tap)="registerCard(card)" | ||
class="btn btn-primary"></Button> | ||
|
||
<Label [text]="status" textWrap="true" class="text-center"></Label> | ||
|
||
<Button | ||
text="Close modal" | ||
(tap)="closeModal()" | ||
class="btn btn-cancel"></Button> | ||
</StackLayout> |
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,66 @@ | ||
import { Component, ChangeDetectorRef } from "@angular/core"; | ||
import { ModalDialogParams } from "nativescript-angular/modal-dialog"; | ||
import { alert } from "tns-core-modules/ui/dialogs"; | ||
import { CreditCardView, Stripe } from "nativescript-stripe"; | ||
|
||
import { publishableKey, StripeService } from "./stripe.service"; | ||
|
||
@Component({ | ||
moduleId: module.id, | ||
templateUrl: "intent-modal.component.html" | ||
}) | ||
export class ItentModalComponent { | ||
status: string; | ||
private stripe: Stripe; | ||
|
||
constructor( | ||
private stripeService: StripeService, | ||
public changeDetectionRef: ChangeDetectorRef, | ||
private dialogParams: ModalDialogParams | ||
) { | ||
if (-1 !== publishableKey.indexOf("pk_test_yours")) { | ||
throw new Error("publishableKey must be changed from placeholder"); | ||
} | ||
this.stripe = new Stripe(publishableKey); | ||
} | ||
|
||
/* | ||
* Public methods | ||
*/ | ||
|
||
closeModal() { | ||
this.dialogParams.closeCallback(); | ||
} | ||
|
||
registerCard(cardView: CreditCardView) { | ||
this._setStatus("Create Setup Intent..."); | ||
this.stripeService.createSetupIntent().then((intent) => { | ||
|
||
this._setStatus("Create Payment Method..."); | ||
this.stripe.createPaymentMethod(cardView.card, (error, pm) => { | ||
if (error) return this._displayError(error); | ||
this._setStatus("Confirm Setup Intent..."); | ||
this.stripe.confirmSetupIntent(pm.id, intent.secret, (error, setupIntent) => { | ||
if (error) this._displayError(error); | ||
this._setStatus(`Setup Intent Status => ${setupIntent.status}`); | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
/* | ||
* Private | ||
*/ | ||
|
||
private _setStatus(message) { | ||
this.status = message; | ||
this.changeDetectionRef.detectChanges(); | ||
} | ||
|
||
private _displayError(message) { | ||
alert({ | ||
message, | ||
okButtonText: "OK" | ||
}).then(() => this._setStatus(null)); | ||
} | ||
} |
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,27 @@ | ||
<ActionBar title="Intent Demo" class="action-bar"></ActionBar> | ||
|
||
<StackLayout class="page"> | ||
<CreditCardView #card></CreditCardView> | ||
|
||
<Button | ||
text="Save Credit Card - Setup Intent" | ||
(tap)="registerCard(card)" | ||
class="btn btn-primary"></Button> | ||
|
||
<Button | ||
text="Automatic Confirm Intent Payment (12$)" | ||
(tap)="automaticConfirmPayment(card)" | ||
class="btn btn-primary"></Button> | ||
|
||
<Button | ||
text="Manual Confirm Intent Payment (12$)" | ||
(tap)="manualConfirmPayment(card)" | ||
class="btn btn-primary"></Button> | ||
|
||
<Button | ||
text="From Modal" | ||
(tap)="openModal()" | ||
class="btn btn-primary"></Button> | ||
|
||
<Label [text]="status" textWrap="true" class="text-center"></Label> | ||
</StackLayout> |
Oops, something went wrong.