Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
Merge pull request #42 from jonyw4/Updates
Browse files Browse the repository at this point in the history
feat: add pix as payment method
  • Loading branch information
jonyw4 authored Nov 30, 2020
2 parents 8c405cf + 29a608f commit e797a8c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"dependencies": {
"@types/qs": "6.9.3",
"pagarme": "4.13.0",
"pagarme-js-types": "2.5.1",
"pagarme-js-types": "2.6.0",
"qs": "6.9.4"
},
"devDependencies": {
Expand Down
22 changes: 14 additions & 8 deletions src/payment-method-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import pagarme, {
CreateTransactionCreditCartInput,
CreateTransactionBoletoInput,
CreateTransactionInputBase,
CreateTransactionPixInput,
ItemInput
} from 'pagarme';
import { Optional } from './types/utils';
Expand Down Expand Up @@ -38,6 +39,7 @@ export type PagarmePaymentMethodMetadata = Omit<
CreateTransactionBoletoInput,
'boleto_instructions' | 'boleto_fine' | 'boleto_interest'
>
| CreateTransactionPixInput
) & {
extraInfo?: {
metadata?: any;
Expand Down Expand Up @@ -284,14 +286,18 @@ export const pagarmePaymentMethodHandler = new PaymentMethodHandler({
unit_price: line.unitPrice,
quantity: line.quantity
})),
boleto_fine: {
days: boletoFineDays,
amount: boletoFineAmount
},
boleto_interest: {
days: boletoInterestDays,
amount: boletoInterestAmount
},
...(metadata.payment_method === 'boleto'
? {
boleto_fine: {
days: boletoFineDays,
amount: boletoFineAmount
},
boleto_interest: {
days: boletoInterestDays,
amount: boletoInterestAmount
}
}
: {}),
metadata: JSON.stringify({
id: order.id,
...extraInfo?.metadata
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7863,10 +7863,10 @@ pacote@^9.1.0, pacote@^9.5.12, pacote@^9.5.3:
unique-filename "^1.1.1"
which "^1.3.1"

pagarme-js-types@2.5.1:
version "2.5.1"
resolved "https://registry.yarnpkg.com/pagarme-js-types/-/pagarme-js-types-2.5.1.tgz#7f10c1f891408f3f65878e9e095746a11f23c8d0"
integrity sha512-rLdPyC8DYaAHCcg2smr/7uh4/b1aq8uqi/YEgwnRUL0yCdEwOqlOxbP++/0MpJg7ywzbRJzjGe7uUUXVw/Gg9g==
pagarme-js-types@2.6.0:
version "2.6.0"
resolved "https://registry.yarnpkg.com/pagarme-js-types/-/pagarme-js-types-2.6.0.tgz#3c6ab507f11af336409812fc60ace0d745c1ad8d"
integrity sha512-ff0XFEE83StzyfiMYhOdjjRdtaEiX7dBPMLWpCq9JcshFZxZh8zIU3ph8L5eQH+R9mKNXp9uUzlcqfOhEb9EYw==

[email protected]:
version "4.13.0"
Expand Down

0 comments on commit e797a8c

Please sign in to comment.