Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion examples/dynamic-checkout/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
document.addEventListener("DOMContentLoaded", function () {
// You need to replace these values with your own
const projectId = "test-proj_qEi1u5BwoYcZb6mOMKDWIm4mpqKCq6bN"
const invoiceId = "iv_30JJHCq6bN6TX1rV260OFo1oARdK0eQu"
const invoiceId = "iv_36LHtCq6bNj5JR3yggvgO4cSjR6XGBNB"
const clientSecret = ""

const client = new ProcessOut.ProcessOut(projectId)
Expand All @@ -21,6 +21,7 @@
clientSecret,
capturePayments: false,
allowFallbackToSale: false,
showStatusMessage: false,
locale: "en",
})

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "processout.js",
"version": "1.6.3",
"version": "1.6.4",
"description": "ProcessOut.js is a JavaScript library for ProcessOut's payment processing API.",
"scripts": {
"build:processout": "tsc -p src/processout && uglifyjs --compress --keep-fnames --ie8 dist/processout.js -o dist/processout.js",
Expand Down
20 changes: 12 additions & 8 deletions src/dynamic-checkout/clients/apple-pay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,21 +129,25 @@ module ProcessOut {
allow_fallback_to_sale: this.paymentConfig.allowFallbackToSale,
},
invoiceId => {
getViewContainer().appendChild(
new DynamicCheckoutPaymentSuccessView(this.processOutInstance, this.paymentConfig)
.element,
)
if (this.paymentConfig.showStatusMessage) {
getViewContainer().appendChild(
new DynamicCheckoutPaymentSuccessView(this.processOutInstance, this.paymentConfig)
.element,
)
}

DynamicCheckoutEventsUtils.dispatchPaymentSuccessEvent({
invoiceId,
returnUrl: this.paymentConfig.invoiceDetails.return_url,
})
},
error => {
getViewContainer().appendChild(
new DynamicCheckoutPaymentErrorView(this.processOutInstance, this.paymentConfig)
.element,
)
if (this.paymentConfig.showStatusMessage) {
getViewContainer().appendChild(
new DynamicCheckoutPaymentErrorView(this.processOutInstance, this.paymentConfig)
.element,
)
}

DynamicCheckoutEventsUtils.dispatchPaymentErrorEvent(error)
},
Expand Down
26 changes: 16 additions & 10 deletions src/dynamic-checkout/clients/google-pay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,23 +129,29 @@ module ProcessOut {
allow_fallback_to_sale: this.paymentConfig.allowFallbackToSale,
},
invoiceId => {
getViewContainer().appendChild(
new DynamicCheckoutPaymentSuccessView(
this.processOutInstance,
this.paymentConfig,
).element,
)
if (this.paymentConfig.showStatusMessage) {
getViewContainer().appendChild(
new DynamicCheckoutPaymentSuccessView(
this.processOutInstance,
this.paymentConfig,
).element,
)
}

DynamicCheckoutEventsUtils.dispatchPaymentSuccessEvent({
invoiceId,
returnUrl: this.paymentConfig.invoiceDetails.return_url,
})
},
error => {
getViewContainer().appendChild(
new DynamicCheckoutPaymentErrorView(this.processOutInstance, this.paymentConfig)
.element,
)
if (this.paymentConfig.showStatusMessage) {
getViewContainer().appendChild(
new DynamicCheckoutPaymentErrorView(
this.processOutInstance,
this.paymentConfig,
).element,
)
}

DynamicCheckoutEventsUtils.dispatchPaymentErrorEvent(error)
},
Expand Down
10 changes: 10 additions & 0 deletions src/dynamic-checkout/config/payment-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module ProcessOut {
clientSecret?: string
capturePayments?: boolean
allowFallbackToSale?: boolean
showStatusMessage?: boolean
}

export type DynamicCheckoutInternalConfigType = {
Expand All @@ -24,10 +25,12 @@ module ProcessOut {
locale: DynamicCheckoutPublicConfigType["locale"] = "en"
capturePayments: DynamicCheckoutPublicConfigType["capturePayments"] = false
allowFallbackToSale: DynamicCheckoutPublicConfigType["allowFallbackToSale"] = false
showStatusMessage: DynamicCheckoutPublicConfigType["showStatusMessage"] = true
invoiceDetails: DynamicCheckoutInternalConfigType["invoiceDetails"]

constructor(config: DynamicCheckoutPublicConfigType) {
this.setInitialConfig(config)
console.log(this.showStatusMessage)
}

public getConfig(): DynamicCheckoutPublicConfigType & DynamicCheckoutInternalConfigType {
Expand All @@ -38,6 +41,7 @@ module ProcessOut {
invoiceDetails: this.invoiceDetails,
capturePayments: this.capturePayments,
allowFallbackToSale: this.allowFallbackToSale,
showStatusMessage: this.showStatusMessage,
}
}

Expand All @@ -58,6 +62,12 @@ module ProcessOut {
this.locale = config.locale || "en"
this.capturePayments = config.capturePayments || false
this.allowFallbackToSale = config.allowFallbackToSale || false

if (config.showStatusMessage !== undefined && config.showStatusMessage !== null) {
this.showStatusMessage = config.showStatusMessage
} else {
this.showStatusMessage = true
}
}

private isValidConfig(config: DynamicCheckoutPublicConfigType) {
Expand Down
56 changes: 34 additions & 22 deletions src/dynamic-checkout/payment-methods/apm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,12 @@ module ProcessOut {
paymentToken,
cardPaymentOptions,
invoiceId => {
this.resetContainerHtml().appendChild(
new DynamicCheckoutPaymentSuccessView(this.processOutInstance, this.paymentConfig)
.element,
)
if (this.paymentConfig.showStatusMessage) {
this.resetContainerHtml().appendChild(
new DynamicCheckoutPaymentSuccessView(this.processOutInstance, this.paymentConfig)
.element,
)
}

DynamicCheckoutEventsUtils.dispatchPaymentSuccessEvent(invoiceId)
},
Expand Down Expand Up @@ -174,31 +176,39 @@ module ProcessOut {
paymentToken,
options,
invoiceId => {
this.resetContainerHtml().appendChild(
new DynamicCheckoutPaymentSuccessView(
this.processOutInstance,
this.paymentConfig,
).element,
)
if (this.paymentConfig.showStatusMessage) {
this.resetContainerHtml().appendChild(
new DynamicCheckoutPaymentSuccessView(
this.processOutInstance,
this.paymentConfig,
).element,
)
}

DynamicCheckoutEventsUtils.dispatchPaymentSuccessEvent(invoiceId)
},
error => {
this.resetContainerHtml().appendChild(
new DynamicCheckoutPaymentErrorView(this.processOutInstance, this.paymentConfig)
.element,
)
if (this.paymentConfig.showStatusMessage) {
this.resetContainerHtml().appendChild(
new DynamicCheckoutPaymentErrorView(
this.processOutInstance,
this.paymentConfig,
).element,
)
}

DynamicCheckoutEventsUtils.dispatchPaymentErrorEvent(error)
},
requestOptions,
)
},
error => {
this.resetContainerHtml().appendChild(
new DynamicCheckoutPaymentErrorView(this.processOutInstance, this.paymentConfig)
.element,
)
if (this.paymentConfig.showStatusMessage) {
this.resetContainerHtml().appendChild(
new DynamicCheckoutPaymentErrorView(this.processOutInstance, this.paymentConfig)
.element,
)
}

DynamicCheckoutEventsUtils.dispatchPaymentErrorEvent(error)
},
Expand All @@ -207,10 +217,12 @@ module ProcessOut {
)
},
error => {
this.resetContainerHtml().appendChild(
new DynamicCheckoutPaymentErrorView(this.processOutInstance, this.paymentConfig)
.element,
)
if (this.paymentConfig.showStatusMessage) {
this.resetContainerHtml().appendChild(
new DynamicCheckoutPaymentErrorView(this.processOutInstance, this.paymentConfig)
.element,
)
}

DynamicCheckoutEventsUtils.dispatchPaymentErrorEvent(error)
},
Expand Down
16 changes: 10 additions & 6 deletions src/dynamic-checkout/payment-methods/card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,11 @@ module ProcessOut {
}

private handleCardPaymentSuccess(invoiceId: string) {
this.resetContainerHtml().appendChild(
new DynamicCheckoutPaymentSuccessView(this.procesoutInstance, this.paymentConfig).element,
)
if (this.paymentConfig.showStatusMessage) {
this.resetContainerHtml().appendChild(
new DynamicCheckoutPaymentSuccessView(this.procesoutInstance, this.paymentConfig).element,
)
}

DynamicCheckoutEventsUtils.dispatchPaymentSuccessEvent({
invoiceId,
Expand All @@ -153,9 +155,11 @@ module ProcessOut {
}

private handleCardPaymentError(error) {
this.resetContainerHtml().appendChild(
new DynamicCheckoutPaymentErrorView(this.procesoutInstance, this.paymentConfig).element,
)
if (this.paymentConfig.showStatusMessage) {
this.resetContainerHtml().appendChild(
new DynamicCheckoutPaymentErrorView(this.procesoutInstance, this.paymentConfig).element,
)
}

DynamicCheckoutEventsUtils.dispatchPaymentErrorEvent(error)
}
Expand Down
19 changes: 12 additions & 7 deletions src/dynamic-checkout/payment-methods/native-apm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ module ProcessOut {
})

window.addEventListener(NATIVE_APM_EVENTS.PAYMENT_SUCCESS, () => {
this.resetContainerHtml().appendChild(
new DynamicCheckoutPaymentSuccessView(this.processOutInstance, this.paymentConfig)
.element,
)
if (this.paymentConfig.showStatusMessage) {
this.resetContainerHtml().appendChild(
new DynamicCheckoutPaymentSuccessView(this.processOutInstance, this.paymentConfig)
.element,
)
}

DynamicCheckoutEventsUtils.dispatchPaymentSuccessEvent({
invoiceId: this.paymentConfig.invoiceId,
Expand All @@ -75,9 +77,12 @@ module ProcessOut {
})

window.addEventListener(NATIVE_APM_EVENTS.PAYMENT_ERROR, e => {
this.resetContainerHtml().appendChild(
new DynamicCheckoutPaymentErrorView(this.processOutInstance, this.paymentConfig).element,
)
if (this.paymentConfig.showStatusMessage) {
this.resetContainerHtml().appendChild(
new DynamicCheckoutPaymentErrorView(this.processOutInstance, this.paymentConfig)
.element,
)
}

DynamicCheckoutEventsUtils.dispatchPaymentErrorEvent(e)
})
Expand Down
22 changes: 14 additions & 8 deletions src/dynamic-checkout/payment-methods/saved-apm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,24 @@ module ProcessOut {
paymentToken,
cardPaymentOptions,
invoiceId => {
this.resetContainerHtml().appendChild(
new DynamicCheckoutPaymentSuccessView(this.processOutInstance, this.paymentConfig)
.element,
)
if (this.paymentConfig.showStatusMessage) {
this.resetContainerHtml().appendChild(
new DynamicCheckoutPaymentSuccessView(
this.processOutInstance,
this.paymentConfig,
).element,
)
}

DynamicCheckoutEventsUtils.dispatchPaymentSuccessEvent(invoiceId)
},
error => {
this.resetContainerHtml().appendChild(
new DynamicCheckoutPaymentErrorView(this.processOutInstance, this.paymentConfig)
.element,
)
if (this.paymentConfig.showStatusMessage) {
this.resetContainerHtml().appendChild(
new DynamicCheckoutPaymentErrorView(this.processOutInstance, this.paymentConfig)
.element,
)
}

DynamicCheckoutEventsUtils.dispatchPaymentErrorEvent(error)
},
Expand Down
17 changes: 11 additions & 6 deletions src/dynamic-checkout/payment-methods/saved-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,12 @@ module ProcessOut {
}

private handlePaymentSuccess(invoiceId: string) {
this.resetContainerHtml().appendChild(
new DynamicCheckoutPaymentSuccessView(this.processOutInstance, this.paymentConfig).element,
)
if (this.paymentConfig.showStatusMessage) {
this.resetContainerHtml().appendChild(
new DynamicCheckoutPaymentSuccessView(this.processOutInstance, this.paymentConfig)
.element,
)
}

DynamicCheckoutEventsUtils.dispatchPaymentSuccessEvent({
invoiceId,
Expand All @@ -115,9 +118,11 @@ module ProcessOut {
}

private handlePaymentError(error) {
this.resetContainerHtml().appendChild(
new DynamicCheckoutPaymentErrorView(this.processOutInstance, this.paymentConfig).element,
)
if (this.paymentConfig.showStatusMessage) {
this.resetContainerHtml().appendChild(
new DynamicCheckoutPaymentErrorView(this.processOutInstance, this.paymentConfig).element,
)
}

DynamicCheckoutEventsUtils.dispatchPaymentErrorEvent(error)
}
Expand Down