Skip to content
Open
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
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.7.4",
"version": "1.7.5",
"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
12 changes: 12 additions & 0 deletions src/dynamic-checkout/clients/apple-pay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,18 @@ module ProcessOut {

DynamicCheckoutEventsUtils.dispatchPaymentErrorEvent(error)
},
undefined,
invoiceId => {
if (this.paymentConfig.showStatusMessage) {
getViewContainer().appendChild(
new DynamicCheckoutPaymentPendingView(this.processOutInstance, this.paymentConfig).element,
)
}

DynamicCheckoutEventsUtils.dispatchPaymentPendingEvent(invoiceId, {
payment_method_name: "apple_pay",
})
},
)
}

Expand Down
12 changes: 12 additions & 0 deletions src/dynamic-checkout/clients/google-pay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,18 @@ module ProcessOut {

DynamicCheckoutEventsUtils.dispatchPaymentErrorEvent(error)
},
undefined,
invoiceId => {
if (this.paymentConfig.showStatusMessage) {
getViewContainer().appendChild(
new DynamicCheckoutPaymentPendingView(this.processOutInstance, this.paymentConfig).element,
)
}

DynamicCheckoutEventsUtils.dispatchPaymentPendingEvent(invoiceId, {
payment_method_name: "google_pay",
})
},
)
},
error => {
Expand Down
2 changes: 1 addition & 1 deletion src/dynamic-checkout/dynamic-checkout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ module ProcessOut {
}

private onGetInvoiceSuccess(data: any) {
if (!data.success) {
if (resolveOutcome(data) === OUTCOME.Failed) {
this.loadView(
new DynamicCheckoutPaymentErrorView(this.processOutInstance, this.paymentConfig).element,
)
Expand Down
1 change: 1 addition & 0 deletions src/dynamic-checkout/locales/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module ProcessOut {
"payment-success-message": "Diese Zahlung wurde abgeschlossen.",
"payment-info-message":
"Wir verarbeiten Ihre Zahlung. Sie können dieses Fenster jetzt schließen.",
"payment-pending-message": "Ihre Zahlung steht noch aus.",
"payment-error-generic-message": "Wir konnten Ihre Zahlung nicht verarbeiten.",
"street1-label": "Adresszeile 1",
"street2-label": "Adresszeile 2",
Expand Down
1 change: 1 addition & 0 deletions src/dynamic-checkout/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module ProcessOut {
"select-payment-method-label": "Select payment method",
"payment-success-message": "This payment is completed.",
"payment-info-message": "We are processing your payment. You can now close this window.",
"payment-pending-message": "Your payment is pending.",
"payment-error-generic-message": "We were unable to process your payment.",
"street1-label": "Address line 1",
"street2-label": "Address line 2",
Expand Down
1 change: 1 addition & 0 deletions src/dynamic-checkout/locales/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module ProcessOut {
"select-payment-method-label": "Seleccionar método de pago",
"payment-success-message": "Este pago se ha completado.",
"payment-info-message": "Estamos procesando su pago. Puede cerrar esta ventana.",
"payment-pending-message": "Su pago está pendiente.",
"payment-error-generic-message": "No pudimos procesar su pago.",
"street1-label": "Dirección, línea 1",
"street2-label": "Dirección, línea 2",
Expand Down
1 change: 1 addition & 0 deletions src/dynamic-checkout/locales/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module ProcessOut {
"payment-success-message": "Ce paiement a été effectué avec succès.",
"payment-info-message":
"Nous travaillons sur votre paiement. Vous pouvez maintenant fermer cette fenêtre.",
"payment-pending-message": "Votre paiement est en attente.",
"payment-error-generic-message": "Nous n'avons pas pu traiter votre paiement.",
"street1-label": "Adresse, ligne 1",
"street2-label": "Adresse, ligne 2",
Expand Down
1 change: 1 addition & 0 deletions src/dynamic-checkout/locales/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module ProcessOut {
"payment-success-message": "Il pagamento è stato completato.",
"payment-info-message":
"Stiamo elaborando il tuo pagamento. Ora puoi chiudere questa finestra.",
"payment-pending-message": "Il tuo pagamento è in sospeso.",
"payment-error-generic-message": "Non è stato possibile elaborare il pagamento.",
"street1-label": "Indirizzo riga 1",
"street2-label": "Indirizzo riga 2",
Expand Down
1 change: 1 addition & 0 deletions src/dynamic-checkout/locales/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module ProcessOut {
"payment-success-message": "お支払いが完了しました。",
"payment-info-message":
"お支払いを処理しています。このウィンドウを閉じていただいて構いません。",
"payment-pending-message": "お支払いは保留中です。",
"payment-error-generic-message": "お支払いを処理できませんでした。",
"street1-label": "住所1",
"street2-label": "住所2",
Expand Down
1 change: 1 addition & 0 deletions src/dynamic-checkout/locales/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module ProcessOut {
"payment-success-message": "결제가 완료되었습니다.",
"payment-info-message":
"결제를 처리하고 있습니다. 이 창을 닫으셔도 됩니다.",
"payment-pending-message": "결제가 대기 중입니다.",
"payment-error-generic-message": "결제를 처리할 수 없습니다.",
"street1-label": "주소 1",
"street2-label": "주소 2",
Expand Down
1 change: 1 addition & 0 deletions src/dynamic-checkout/locales/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module ProcessOut {
"select-payment-method-label": "Wybierz metodę płatności",
"payment-success-message": "Płatność została zakończona pomyślnie.",
"payment-info-message": "Przetwarzamy Twoją płatność. Możesz teraz zamknąć tę okno.",
"payment-pending-message": "Twoja płatność oczekuje na realizację.",
"payment-error-generic-message": "Nie udało nam się przetworzyć Twojej płatności.",
"street1-label": "Adres, linia 1",
"street2-label": "Adres, linia 2",
Expand Down
37 changes: 19 additions & 18 deletions src/dynamic-checkout/locales/pt.ts
Original file line number Diff line number Diff line change
@@ -1,47 +1,48 @@
module ProcessOut {
export const pt = {
"apm-redirect-message": "Você será redirecionado para finalizar o pagamento.",
"save-for-future-label": "Salvar para pagamentos futuros",
"apm-redirect-message": "Será redirecionado para finalizar o pagamento.",
"save-for-future-label": "Guardar para pagamentos futuros",
"continue-with-apm-button": "Continuar com",
"pay-button-text": "Pagar",
"card-details-section-title": "Detalhes do cartão",
"cardholder-name-label": "Nome do titular do cartão",
"billing-address-section-title": "Endereço de cobrança",
"billing-address-section-title": "Morada de faturação",
"country-label": "País",
"select-country-placeholder": "Selecione o país",
"select-state-placeholder": "Selecione o estado",
"select-state-placeholder": "Selecione o distrito",
"card-number-error-message": "O número do cartão é inválido",
"expiry-date-error-message": "A data de validade é inválida",
"cvc-error-message": "O CVC é inválido",
"cardholder-name-error-message": "O nome do titular do cartão é inválido",
"payment-error-message": "Algo deu errado. Por favor, tente novamente.",
"payment-error-message": "Algo correu mal. Por favor, tente novamente.",
"payment-cancelled-message": "O pagamento foi cancelado.",
"express-checkout-header": "Checkout expresso",
"express-checkout-header": "Pagamento expresso",
"other-payment-methods-header": "Outros métodos de pagamento",
"select-payment-method-label": "Selecionar método de pagamento",
"payment-success-message": "Este pagamento foi concluído.",
"payment-info-message":
"Estamos processando seu pagamento. Você pode agora fechar esta janela.",
"payment-error-generic-message": "Não conseguimos processar o seu pagamento.",
"street1-label": "Endereço, linha 1",
"street2-label": "Endereço, linha 2",
"Estamos a processar o seu pagamento. Pode agora fechar esta janela.",
"payment-pending-message": "O seu pagamento está pendente.",
"payment-error-generic-message": "Não foi possível processar o seu pagamento.",
"street1-label": "Morada, linha 1",
"street2-label": "Morada, linha 2",
"city-label": "Cidade",
"postcode-label": "Código postal",
"state-label": "Estado",
"payments-manager-header": "Gerenciar métodos de pagamento salvos",
"state-label": "Distrito",
"payments-manager-header": "Gerir métodos de pagamento guardados",
"payments-manager-close-button": "Fechar",
"no-saved-payment-methods-header": "Nenhum método de pagamento salvo",
"no-saved-payment-methods-header": "Nenhum método de pagamento guardado",
"no-saved-payment-methods-message":
"Depois de guardar uma forma de pagamento, ela aparecerá aqui. ",
"Da próxima vez que guardar um método de pagamento, aparecerá aqui.",
"card-number-label": "Número do cartão",
"expiry-date-label": "Data de validade",
"cvc-label": "CVC",
"card-not-supported-error-message": "Este cartão não é suportado",
"card-label": "Cartão",
"delete-payment-method-label": "Excluir método de pagamento",
"settings-button-label": "Gerenciar métodos de pagamento salvos",
"loading-label": "Carregando",
"processing-payment-label": "Processando pagamento",
"delete-payment-method-label": "Eliminar método de pagamento",
"settings-button-label": "Gerir métodos de pagamento guardados",
"loading-label": "A carregar",
"processing-payment-label": "A processar pagamento",
"card-form-label": "Formulário de pagamento com cartão",
}
}
46 changes: 42 additions & 4 deletions src/dynamic-checkout/payment-methods/apm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ module ProcessOut {
paymentToken => {
this.resetContainerHtml().appendChild(new DynamicCheckoutInvoiceLoadingView(this.paymentConfig.locale).element)

DynamicCheckoutEventsUtils.dispatchPaymentPendingEvent(paymentToken, {
payment_method_name: apm.gateway_name,
})

this.processOutInstance.makeCardPayment(
this.paymentConfig.invoiceId,
paymentToken,
Expand Down Expand Up @@ -131,6 +127,15 @@ module ProcessOut {
DynamicCheckoutEventsUtils.dispatchPaymentErrorEvent(error)
},
requestOptions,
invoiceId => {
this.resetContainerHtml().appendChild(
new DynamicCheckoutPaymentPendingView(this.processOutInstance, this.paymentConfig).element,
)

DynamicCheckoutEventsUtils.dispatchPaymentPendingEvent(invoiceId, {
payment_method_name: apm.gateway_name,
})
},
)
},
error => {
Expand Down Expand Up @@ -174,6 +179,30 @@ module ProcessOut {
`invoices/${this.paymentConfig.invoiceId}/capture`,
options,
data => {
var outcome = resolveOutcome(data)

if (outcome === OUTCOME.Failed) {
this.resetContainerHtml().appendChild(
new DynamicCheckoutPaymentErrorView(this.processOutInstance, this.paymentConfig)
.element,
)

DynamicCheckoutEventsUtils.dispatchPaymentErrorEvent(data)
return
}

if (outcome === OUTCOME.Pending) {
this.resetContainerHtml().appendChild(
new DynamicCheckoutPaymentPendingView(this.processOutInstance, this.paymentConfig).element,
)

DynamicCheckoutEventsUtils.dispatchPaymentPendingEvent(this.paymentConfig.invoiceId, {
payment_method_name: apm.gateway_name,
})

return
}

this.processOutInstance.handleAction(
data.customer_action.value,
paymentToken => {
Expand Down Expand Up @@ -228,6 +257,15 @@ module ProcessOut {
DynamicCheckoutEventsUtils.dispatchPaymentErrorEvent(error)
},
requestOptions,
invoiceId => {
this.resetContainerHtml().appendChild(
new DynamicCheckoutPaymentPendingView(this.processOutInstance, this.paymentConfig).element,
)

DynamicCheckoutEventsUtils.dispatchPaymentPendingEvent(invoiceId, {
payment_method_name: apm.gateway_name,
})
},
)
},
error => {
Expand Down
17 changes: 13 additions & 4 deletions src/dynamic-checkout/payment-methods/card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,6 @@ module ProcessOut {
cardPaymentOptions["save_source"] = saveForFutureCheckbox.checked
}

DynamicCheckoutEventsUtils.dispatchPaymentPendingEvent(cardToken, {
payment_method_name: "card",
})

this.procesoutInstance.makeCardPayment(
this.paymentConfig.invoiceId,
cardToken,
Expand All @@ -135,6 +131,7 @@ module ProcessOut {
{
clientSecret: this.paymentConfig.clientSecret,
},
this.handleCardPaymentPending.bind(this),
)
}

Expand Down Expand Up @@ -166,6 +163,18 @@ module ProcessOut {
})
}

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

DynamicCheckoutEventsUtils.dispatchPaymentPendingEvent(invoiceId, {
payment_method_name: "card",
})
}

private handleCardPaymentError(error) {
if (this.paymentConfig.showStatusMessage) {
this.resetContainerHtml().appendChild(
Expand Down
37 changes: 26 additions & 11 deletions src/dynamic-checkout/payment-methods/saved-apm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,6 @@ module ProcessOut {
return this.processOutInstance.handleAction(
apm_customer_token.redirect_url,
paymentToken => {
DynamicCheckoutEventsUtils.dispatchPaymentPendingEvent(paymentToken, {
payment_method_name: apm.gateway_name,
})

this.processOutInstance.makeCardPayment(
invoiceId,
paymentToken,
Expand Down Expand Up @@ -158,6 +154,17 @@ module ProcessOut {
DynamicCheckoutEventsUtils.dispatchPaymentErrorEvent(error)
},
requestOptions,
invoiceId => {
if (this.paymentConfig.showStatusMessage) {
this.resetContainerHtml().appendChild(
new DynamicCheckoutPaymentPendingView(this.processOutInstance, this.paymentConfig).element,
)
}

DynamicCheckoutEventsUtils.dispatchPaymentPendingEvent(invoiceId, {
payment_method_name: apm.gateway_name,
})
},
)
},
error => {
Expand All @@ -173,20 +180,14 @@ module ProcessOut {
)
}

DynamicCheckoutEventsUtils.dispatchPaymentPendingEvent(
this.paymentMethod.apm_customer_token.customer_token_id,
{
payment_method_name: apm.gateway_name,
},
)

this.processOutInstance.makeCardPayment(
this.paymentConfig.invoiceId,
this.paymentMethod.apm_customer_token.customer_token_id,
cardPaymentOptions,
this.handlePaymentSuccess.bind(this),
this.handlePaymentError.bind(this),
requestOptions,
this.handlePaymentPending.bind(this),
)
}

Expand All @@ -201,6 +202,20 @@ module ProcessOut {
})
}

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

DynamicCheckoutEventsUtils.dispatchPaymentPendingEvent(invoiceId, {
payment_method_name: this.paymentMethod.apm
? this.paymentMethod.apm.gateway_name
: "apm",
})
}

private handlePaymentError(error) {
this.resetContainerHtml().appendChild(
new DynamicCheckoutPaymentErrorView(this.processOutInstance, this.paymentConfig).element,
Expand Down
14 changes: 14 additions & 0 deletions src/dynamic-checkout/payment-methods/saved-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ module ProcessOut {
},
this.handlePaymentSuccess.bind(this),
this.handlePaymentError.bind(this),
undefined,
this.handlePaymentPending.bind(this),
)
}

Expand All @@ -124,6 +126,18 @@ module ProcessOut {
})
}

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

DynamicCheckoutEventsUtils.dispatchPaymentPendingEvent(invoiceId, {
payment_method_name: "card",
})
}

private handlePaymentError(error) {
if (this.paymentConfig.showStatusMessage) {
this.resetContainerHtml().appendChild(
Expand Down
Loading