Skip to content

Commit 1573079

Browse files
committed
feat: add support for initPaymentSession
1 parent dfaaa15 commit 1573079

11 files changed

Lines changed: 617 additions & 1 deletion

dist/bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.d.ts

Lines changed: 571 additions & 0 deletions
Large diffs are not rendered by default.

src/Context.bs.js

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Context.res

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,14 @@ type rec paymentMethodsManagementElementsType = {
7272

7373
type elementsContextType = {options: Dict.t<JSON.t>}
7474
type confirmPaymentParams = {return_url: string}
75+
7576
type switchContextType = {
7677
clientSecret: string,
7778
confirmPayment: JSON.t => Promise.t<JSON.t>,
7879
confirmCardPayment: (string, option<JSON.t>, option<JSON.t>) => Promise.t<JSON.t>,
7980
retrievePaymentIntent: string => Promise.t<JSON.t>,
8081
paymentRequest: JSON.t => JSON.t,
82+
initPaymentSession: JSON.t => OrcaJs.initPaymentSession,
8183
completeUpdateIntent: string => promise<JSON.t>,
8284
initiateUpdateIntent: unit => promise<JSON.t>,
8385
confirmTokenization: JSON.t => Promise.t<JSON.t>,
@@ -107,12 +109,21 @@ let paymentRequest = options => {
107109
options
108110
}
109111

112+
let defaultGetCustomerSavedPaymentMethods = () => {
113+
Promise.resolve(JSON.Encode.null)
114+
}
115+
116+
let defaultInitPaymentSession: OrcaJs.initPaymentSession = {
117+
getCustomerSavedPaymentMethods: defaultGetCustomerSavedPaymentMethods,
118+
}
119+
110120
let defaultSwitchContext = {
111121
clientSecret: "",
112122
confirmPayment: confirmPaymentFn,
113123
confirmCardPayment: confirmCardPaymentFn,
114124
retrievePaymentIntent: retrievePaymentIntentFn,
115125
paymentRequest,
126+
initPaymentSession: _ => defaultInitPaymentSession,
116127
completeUpdateIntent: _ => Promise.resolve(Dict.make()->JSON.Encode.object),
117128
initiateUpdateIntent: _ => Promise.resolve(Dict.make()->JSON.Encode.object),
118129
confirmTokenization: _ => Promise.resolve(Dict.make()->JSON.Encode.object),

src/OrcaJs.res

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,22 @@ type confirmPaymentParams = {
5656
confirmParams: Nullable.t<confirmParams>,
5757
}
5858

59+
type getCustomerSavedPaymentMethods = {
60+
getCustomerDefaultSavedPaymentMethodData: unit => JSON.t,
61+
getCustomerLastUsedPaymentMethodData: unit => JSON.t,
62+
confirmWithCustomerDefaultPaymentMethod: JSON.t => Promise.t<JSON.t>,
63+
confirmWithLastUsedPaymentMethod: JSON.t => Promise.t<JSON.t>,
64+
}
65+
66+
type initPaymentSession = {getCustomerSavedPaymentMethods: unit => Promise.t<JSON.t>}
67+
5968
type switchInstance = {
6069
confirmPayment: JSON.t => Promise.t<JSON.t>,
6170
elements: JSON.t => element,
6271
confirmCardPayment: (string, option<JSON.t>, option<JSON.t>) => Promise.t<JSON.t>,
6372
retrievePaymentIntent: string => Promise.t<JSON.t>,
6473
paymentRequest: JSON.t => JSON.t,
74+
initPaymentSession: JSON.t => initPaymentSession,
6575
paymentMethodsManagementElements: JSON.t => element,
6676
completeUpdateIntent: string => promise<JSON.t>,
6777
initiateUpdateIntent: unit => promise<JSON.t>,

src/components/Elements.bs.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/Elements.res

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ let make = (~children, ~stripe: Promise.t<OrcaJs.switchInstance>, ~options: JSON
2121
retrievePaymentIntent: switchInstance.retrievePaymentIntent,
2222
clientSecret: elementOptions.clientSecret,
2323
paymentRequest: switchInstance.paymentRequest,
24+
initPaymentSession: switchInstance.initPaymentSession,
2425
completeUpdateIntent: switchInstance.completeUpdateIntent,
2526
initiateUpdateIntent: switchInstance.initiateUpdateIntent,
2627
confirmTokenization: switchInstance.confirmTokenization,

src/components/HyperElements.bs.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/HyperElements.res

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ let make = (~children, ~hyper: Promise.t<OrcaJs.switchInstance>, ~options: JSON.
2121
retrievePaymentIntent: switchInstance.retrievePaymentIntent,
2222
clientSecret: elementOptions.clientSecret,
2323
paymentRequest: switchInstance.paymentRequest,
24+
initPaymentSession: switchInstance.initPaymentSession,
2425
completeUpdateIntent: switchInstance.completeUpdateIntent,
2526
initiateUpdateIntent: switchInstance.initiateUpdateIntent,
2627
confirmTokenization: switchInstance.confirmTokenization,

src/components/HyperManagementElements.bs.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)