Compare commits
2 Commits
ac1d8743b1
...
172544b173
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
172544b173 | ||
|
|
43d9a3c637 |
@@ -201,6 +201,11 @@ class PaymentMethod(StrictModel):
|
|||||||
def card_needs_token(self):
|
def card_needs_token(self):
|
||||||
if self.type == 'card' and not (self.token and self.payment_method_id):
|
if self.type == 'card' and not (self.token and self.payment_method_id):
|
||||||
raise ValueError('Card payment requires the provider token and method')
|
raise ValueError('Card payment requires the provider token and method')
|
||||||
|
# The store takes credit cards and PIX only. Mercado Pago's debit
|
||||||
|
# methods are debvisa, debmaster, debelo...; the adapter still knows
|
||||||
|
# how to pay one, should debit be offered again.
|
||||||
|
if self.type == 'card' and self.payment_method_id.startswith('deb'):
|
||||||
|
raise ValueError('Só aceitamos cartão de crédito ou PIX.')
|
||||||
return self
|
return self
|
||||||
|
|
||||||
class PaymentIntent(StrictModel):
|
class PaymentIntent(StrictModel):
|
||||||
|
|||||||
47
app/tiny.py
47
app/tiny.py
@@ -49,6 +49,10 @@ PRODUCT_SETTINGS = {'file': 'TINY_PRODUCT_TEXTIL_FOLHA', 'avulsa': 'TINY_PRODUCT
|
|||||||
# the mode's product id.
|
# the mode's product id.
|
||||||
SKU_SETTINGS = {'file': 'TINY_SKU_TEXTIL_FOLHA', 'avulsa': 'TINY_SKU_TEXTIL_AVULSA',
|
SKU_SETTINGS = {'file': 'TINY_SKU_TEXTIL_FOLHA', 'avulsa': 'TINY_SKU_TEXTIL_AVULSA',
|
||||||
'uvfile': 'TINY_SKU_UV_FOLHA', 'uv': 'TINY_SKU_UV_AVULSA'}
|
'uvfile': 'TINY_SKU_UV_FOLHA', 'uv': 'TINY_SKU_UV_AVULSA'}
|
||||||
|
# Or a single SKU per 10 cm, as the client sells UV ("DTFIMP.UV.010CM"):
|
||||||
|
# 2,30 m is 23 of it.
|
||||||
|
STEP_SETTINGS = {'file': 'TINY_SKU10_TEXTIL_FOLHA', 'avulsa': 'TINY_SKU10_TEXTIL_AVULSA',
|
||||||
|
'uvfile': 'TINY_SKU10_UV_FOLHA', 'uv': 'TINY_SKU10_UV_AVULSA'}
|
||||||
PRODUCTS = {'file': 'DTF Têxtil 57 cm · folha montada',
|
PRODUCTS = {'file': 'DTF Têxtil 57 cm · folha montada',
|
||||||
'avulsa': 'DTF Têxtil 57 cm · artes avulsas',
|
'avulsa': 'DTF Têxtil 57 cm · artes avulsas',
|
||||||
'uvfile': 'DTF UV 28,5 cm · folha montada',
|
'uvfile': 'DTF UV 28,5 cm · folha montada',
|
||||||
@@ -101,18 +105,48 @@ def configured():
|
|||||||
def required_settings():
|
def required_settings():
|
||||||
"""The OAuth application, and a product id for each mode not sold by SKU."""
|
"""The OAuth application, and a product id for each mode not sold by SKU."""
|
||||||
return ['TINY_CLIENT_ID', 'TINY_CLIENT_SECRET', 'TINY_REDIRECT_URI'] + [
|
return ['TINY_CLIENT_ID', 'TINY_CLIENT_SECRET', 'TINY_REDIRECT_URI'] + [
|
||||||
setting for mode, setting in PRODUCT_SETTINGS.items() if not sku_prefix(mode)]
|
setting for mode, setting in PRODUCT_SETTINGS.items() if not (sku_prefix(mode) or step_sku(mode))]
|
||||||
|
|
||||||
|
|
||||||
def sku_prefix(mode):
|
def sku_prefix(mode):
|
||||||
return os.environ.get(SKU_SETTINGS[mode], '').strip()
|
return os.environ.get(SKU_SETTINGS[mode], '').strip()
|
||||||
|
|
||||||
|
|
||||||
|
def step_sku(mode):
|
||||||
|
return os.environ.get(STEP_SETTINGS[mode], '').strip()
|
||||||
|
|
||||||
|
|
||||||
|
def mode_codes(mode):
|
||||||
|
"""Every SKU code a mode sold by SKU uses, or [] for a mode sold by product id."""
|
||||||
|
if step_sku(mode):
|
||||||
|
return [step_sku(mode)]
|
||||||
|
return sku_codes(sku_prefix(mode)) if sku_prefix(mode) else []
|
||||||
|
|
||||||
|
|
||||||
def sku_codes(prefix):
|
def sku_codes(prefix):
|
||||||
"""The metre SKU and the nine of 10 to 90 cm, as the client's catalogue names them."""
|
"""The metre SKU and the nine of 10 to 90 cm, as the client's catalogue names them."""
|
||||||
return [f'{prefix}.100CM'] + [f'{prefix}.{cm:04d}CM' for cm in range(10, 100, 10)]
|
return [f'{prefix}.100CM'] + [f'{prefix}.{cm:04d}CM' for cm in range(10, 100, 10)]
|
||||||
|
|
||||||
|
|
||||||
|
def tenths(item):
|
||||||
|
"""The billed length in 10 cm steps; the Site bills in them."""
|
||||||
|
billed = Decimal(item['billed_metres'])
|
||||||
|
steps = billed * 10
|
||||||
|
if steps != steps.to_integral_value():
|
||||||
|
raise TinyError(f'{billed} m is not a whole number of 10 cm steps')
|
||||||
|
return int(steps), int(billed * int(item['unit_cents']))
|
||||||
|
|
||||||
|
|
||||||
|
def step_lines(item, code):
|
||||||
|
"""(code, quantity, cents each) for a single 10 cm SKU, adding up to the
|
||||||
|
item's total; a rest that does not divide goes on one line of its own."""
|
||||||
|
steps, total = tenths(item)
|
||||||
|
each, rest = divmod(total, steps)
|
||||||
|
if not rest:
|
||||||
|
return [(code, steps, each)]
|
||||||
|
return [(code, steps - 1, each), (code, 1, each + rest)] if steps > 1 else [(code, 1, total)]
|
||||||
|
|
||||||
|
|
||||||
def sku_lines(item, prefix):
|
def sku_lines(item, prefix):
|
||||||
"""(code, quantity, cents each) adding up to the item: whole metres as the
|
"""(code, quantity, cents each) adding up to the item: whole metres as the
|
||||||
metre SKU, the rest as one 10 cm SKU. The Site bills in 10 cm steps, so
|
metre SKU, the rest as one 10 cm SKU. The Site bills in 10 cm steps, so
|
||||||
@@ -316,11 +350,12 @@ def order_payload(payload, contact_id, today=None, product_id=None):
|
|||||||
items = []
|
items = []
|
||||||
for item in order['items']:
|
for item in order['items']:
|
||||||
note = PRODUCTS[item['mode']] + f" · nota {item['grade']}"
|
note = PRODUCTS[item['mode']] + f" · nota {item['grade']}"
|
||||||
prefix = sku_prefix(item['mode'])
|
prefix, step = sku_prefix(item['mode']), step_sku(item['mode'])
|
||||||
if prefix:
|
if step or prefix:
|
||||||
if product_id is None:
|
if product_id is None:
|
||||||
raise TinyError(f"{SKU_SETTINGS[item['mode']]} needs the SKUs looked up in Tiny")
|
raise TinyError(f"{SKU_SETTINGS[item['mode']]} needs the SKUs looked up in Tiny")
|
||||||
for index, (code, quantity, cents) in enumerate(sku_lines(item, prefix)):
|
lines = step_lines(item, step) if step else sku_lines(item, prefix)
|
||||||
|
for index, (code, quantity, cents) in enumerate(lines):
|
||||||
line = {'produto': {'id': product_id(code)}, 'quantidade': quantity, 'valorUnitario': money(cents)}
|
line = {'produto': {'id': product_id(code)}, 'quantidade': quantity, 'valorUnitario': money(cents)}
|
||||||
if index == 0:
|
if index == 0:
|
||||||
line['infoAdicional'] = note + f" · {item['billed_metres']} m"
|
line['infoAdicional'] = note + f" · {item['billed_metres']} m"
|
||||||
@@ -372,7 +407,7 @@ def configured_product(orders, mode):
|
|||||||
def configured_skus(orders, mode):
|
def configured_skus(orders, mode):
|
||||||
"""Whether every SKU of a mode sold by SKU is an active product in Tiny."""
|
"""Whether every SKU of a mode sold by SKU is an active product in Tiny."""
|
||||||
missing = []
|
missing = []
|
||||||
for code in sku_codes(sku_prefix(mode)):
|
for code in mode_codes(mode):
|
||||||
try:
|
try:
|
||||||
orders.product_id(code)
|
orders.product_id(code)
|
||||||
except TinyError:
|
except TinyError:
|
||||||
@@ -400,7 +435,7 @@ def check(auth=None, transport=None, orders=None):
|
|||||||
return 'ok'
|
return 'ok'
|
||||||
|
|
||||||
reads = [('pedidos', lambda: listed('/pedidos')), ('contatos', lambda: listed('/contatos'))]
|
reads = [('pedidos', lambda: listed('/pedidos')), ('contatos', lambda: listed('/contatos'))]
|
||||||
reads += [(PRODUCTS[mode], lambda mode=mode: configured_skus(orders, mode) if sku_prefix(mode)
|
reads += [(PRODUCTS[mode], lambda mode=mode: configured_skus(orders, mode) if mode_codes(mode)
|
||||||
else configured_product(orders, mode)[1]) for mode in PRODUCT_SETTINGS]
|
else configured_product(orders, mode)[1]) for mode in PRODUCT_SETTINGS]
|
||||||
reads.append(('forma de envio de retirada', lambda: configured_pickup(orders)[1]))
|
reads.append(('forma de envio de retirada', lambda: configured_pickup(orders)[1]))
|
||||||
results = {}
|
results = {}
|
||||||
|
|||||||
@@ -67,7 +67,12 @@ def formas_envio(orders, termo, out):
|
|||||||
def conferir(orders, out):
|
def conferir(orders, out):
|
||||||
ok = True
|
ok = True
|
||||||
for mode, setting in tiny.PRODUCT_SETTINGS.items():
|
for mode, setting in tiny.PRODUCT_SETTINGS.items():
|
||||||
prefix = tiny.sku_prefix(mode)
|
prefix, step = tiny.sku_prefix(mode), tiny.step_sku(mode)
|
||||||
|
if step:
|
||||||
|
result = tiny.configured_skus(orders, mode)
|
||||||
|
ok &= result == 'ok'
|
||||||
|
out(f'{tiny.STEP_SETTINGS[mode]} ({tiny.PRODUCTS[mode]}): {result} ({step} a cada 10 cm)')
|
||||||
|
continue
|
||||||
if prefix:
|
if prefix:
|
||||||
result = tiny.configured_skus(orders, mode)
|
result = tiny.configured_skus(orders, mode)
|
||||||
ok &= result == 'ok'
|
ok &= result == 'ok'
|
||||||
|
|||||||
@@ -62,6 +62,10 @@ x-app: &app
|
|||||||
TINY_SKU_TEXTIL_AVULSA: ${TINY_SKU_TEXTIL_AVULSA:-}
|
TINY_SKU_TEXTIL_AVULSA: ${TINY_SKU_TEXTIL_AVULSA:-}
|
||||||
TINY_SKU_UV_FOLHA: ${TINY_SKU_UV_FOLHA:-}
|
TINY_SKU_UV_FOLHA: ${TINY_SKU_UV_FOLHA:-}
|
||||||
TINY_SKU_UV_AVULSA: ${TINY_SKU_UV_AVULSA:-}
|
TINY_SKU_UV_AVULSA: ${TINY_SKU_UV_AVULSA:-}
|
||||||
|
TINY_SKU10_TEXTIL_FOLHA: ${TINY_SKU10_TEXTIL_FOLHA:-}
|
||||||
|
TINY_SKU10_TEXTIL_AVULSA: ${TINY_SKU10_TEXTIL_AVULSA:-}
|
||||||
|
TINY_SKU10_UV_FOLHA: ${TINY_SKU10_UV_FOLHA:-}
|
||||||
|
TINY_SKU10_UV_AVULSA: ${TINY_SKU10_UV_AVULSA:-}
|
||||||
TINY_ECOMMERCE_ID: ${TINY_ECOMMERCE_ID:-}
|
TINY_ECOMMERCE_ID: ${TINY_ECOMMERCE_ID:-}
|
||||||
WHATSAPP_ADAPTER: fake
|
WHATSAPP_ADAPTER: fake
|
||||||
STORAGE_ADAPTER: s3-local
|
STORAGE_ADAPTER: s3-local
|
||||||
|
|||||||
@@ -76,6 +76,10 @@ x-app-environment: &app-environment
|
|||||||
TINY_SKU_TEXTIL_AVULSA: ${TINY_SKU_TEXTIL_AVULSA:-}
|
TINY_SKU_TEXTIL_AVULSA: ${TINY_SKU_TEXTIL_AVULSA:-}
|
||||||
TINY_SKU_UV_FOLHA: ${TINY_SKU_UV_FOLHA:-}
|
TINY_SKU_UV_FOLHA: ${TINY_SKU_UV_FOLHA:-}
|
||||||
TINY_SKU_UV_AVULSA: ${TINY_SKU_UV_AVULSA:-}
|
TINY_SKU_UV_AVULSA: ${TINY_SKU_UV_AVULSA:-}
|
||||||
|
TINY_SKU10_TEXTIL_FOLHA: ${TINY_SKU10_TEXTIL_FOLHA:-}
|
||||||
|
TINY_SKU10_TEXTIL_AVULSA: ${TINY_SKU10_TEXTIL_AVULSA:-}
|
||||||
|
TINY_SKU10_UV_FOLHA: ${TINY_SKU10_UV_FOLHA:-}
|
||||||
|
TINY_SKU10_UV_AVULSA: ${TINY_SKU10_UV_AVULSA:-}
|
||||||
# The client's "retirar pessoalmente" forma de envio id, on pickup orders.
|
# The client's "retirar pessoalmente" forma de envio id, on pickup orders.
|
||||||
TINY_FORMA_ENVIO_RETIRADA: ${TINY_FORMA_ENVIO_RETIRADA:-}
|
TINY_FORMA_ENVIO_RETIRADA: ${TINY_FORMA_ENVIO_RETIRADA:-}
|
||||||
# Sets "Aprovada" on paid orders and "Pronto para envio" on finished pickup
|
# Sets "Aprovada" on paid orders and "Pronto para envio" on finished pickup
|
||||||
|
|||||||
@@ -314,6 +314,8 @@ TINY_SKU_TEXTIL_FOLHA=DTFIMP.TX # optional, instead of the product id:
|
|||||||
TINY_SKU_TEXTIL_AVULSA= # same, for the other modes, once their SKUs are confirmed
|
TINY_SKU_TEXTIL_AVULSA= # same, for the other modes, once their SKUs are confirmed
|
||||||
TINY_SKU_UV_FOLHA=
|
TINY_SKU_UV_FOLHA=
|
||||||
TINY_SKU_UV_AVULSA=
|
TINY_SKU_UV_AVULSA=
|
||||||
|
TINY_SKU10_UV_FOLHA=DTFIMP.UV.010CM # or one SKU per 10 cm: 2,30 m = 23 of it (the client's UV)
|
||||||
|
TINY_SKU10_UV_AVULSA=DTFIMP.UV.010CM
|
||||||
```
|
```
|
||||||
|
|
||||||
With the client ID and secret set, the Kanban header shows **Conectar Tiny**.
|
With the client ID and secret set, the Kanban header shows **Conectar Tiny**.
|
||||||
|
|||||||
@@ -365,6 +365,9 @@ From the report already sent. These are dated promises, not backlog.
|
|||||||
`DTFIMP.UV.010CM` seen) and artes avulsas stay on a product id per metre
|
`DTFIMP.UV.010CM` seen) and artes avulsas stay on a product id per metre
|
||||||
until their SKUs are confirmed. Fake transport only; whether v3's `/produtos`
|
until their SKUs are confirmed. Fake transport only; whether v3's `/produtos`
|
||||||
filters by `codigo` is checked by `conferir` on the account.
|
filters by `codigo` is checked by `conferir` on the account.
|
||||||
|
**UV (2026-10-05):** the client sells UV only as `DTFIMP.UV.010CM`, per 10 cm.
|
||||||
|
`TINY_SKU10_<MODE>` names such a SKU: 2,30 m goes as 23 of it, at the price
|
||||||
|
paid (a rest that does not divide gets a line of its own).
|
||||||
**Customer notices through Tiny (2026-09-25, Week 3 head start):** the client
|
**Customer notices through Tiny (2026-09-25, Week 3 head start):** the client
|
||||||
already sends WhatsApp notices from Tiny's order situação (Tiny webhook ->
|
already sends WhatsApp notices from Tiny's order situação (Tiny webhook ->
|
||||||
the `api-tiny-n8n` middleware, which reads the order through API v2 -> n8n
|
the `api-tiny-n8n` middleware, which reads the order through API v2 -> n8n
|
||||||
|
|||||||
@@ -58,6 +58,10 @@ def run():
|
|||||||
assert not customer.call('/quotes/' + quote_id)['order'], 'unsigned delivery created an order'
|
assert not customer.call('/quotes/' + quote_id)['order'], 'unsigned delivery created an order'
|
||||||
print('PASS: unsigned and tampered deliveries are refused and create nothing')
|
print('PASS: unsigned and tampered deliveries are refused and create nothing')
|
||||||
|
|
||||||
|
# Debit cards are not taken, even sent around the payment page.
|
||||||
|
customer.call('/payments/intent', {'quote_id': quote_id, 'method': {
|
||||||
|
'type': 'card', 'token': 'tok', 'payment_method_id': 'debvisa'}}, expected=422)
|
||||||
|
|
||||||
# Starting a PIX twice returns the same one. A card in review blocks every
|
# Starting a PIX twice returns the same one. A card in review blocks every
|
||||||
# further attempt, so one quote can never be charged twice.
|
# further attempt, so one quote can never be charged twice.
|
||||||
pix = customer.call('/payments/intent', {'quote_id': quote_id, 'method': {'type': 'pix'}})
|
pix = customer.call('/payments/intent', {'quote_id': quote_id, 'method': {'type': 'pix'}})
|
||||||
|
|||||||
@@ -304,6 +304,38 @@ class TinySkuTests(FakeTinyCase):
|
|||||||
self.assertEqual(self.orders, [])
|
self.assertEqual(self.orders, [])
|
||||||
|
|
||||||
|
|
||||||
|
UV = {**PAID, 'order': {**PAID['order'], 'items': [
|
||||||
|
{'mode': 'uvfile', 'grade': 100, 'billed_metres': '2.3', 'unit_cents': 6990, 'total_cents': 16077}]}}
|
||||||
|
|
||||||
|
|
||||||
|
@mock.patch.dict(os.environ, {**PRODUCTS, 'TINY_SKU10_UV_FOLHA': 'DTFIMP.UV.010CM'})
|
||||||
|
class TinyStepSkuTests(FakeTinyCase):
|
||||||
|
"""UV sold as one SKU per 10 cm, the only UV SKU the client has."""
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super().setUp()
|
||||||
|
self.products['300'] = {'id': 300, 'sku': 'DTFIMP.UV.010CM', 'descricao': 'UV 10 cm', 'situacao': 'A'}
|
||||||
|
|
||||||
|
def test_the_length_in_ten_centimetre_steps_at_the_price_paid(self):
|
||||||
|
self.tiny.deliver('k1', UV)
|
||||||
|
lines = [(i['produto']['id'], i['quantidade'], i['valorUnitario']) for i in self.orders[0]['itens']]
|
||||||
|
self.assertEqual(lines, [(300, 23, 6.99)]) # 2,30 m at R$ 69,90 = R$ 160,77
|
||||||
|
|
||||||
|
def test_a_rest_that_does_not_divide_gets_its_own_line(self):
|
||||||
|
from app.tiny import step_lines
|
||||||
|
lines = step_lines({'billed_metres': '1.3', 'unit_cents': 1495}, 'C')
|
||||||
|
self.assertEqual(lines, [('C', 12, 149), ('C', 1, 155)])
|
||||||
|
self.assertEqual(sum(q * c for _, q, c in lines), 1943)
|
||||||
|
|
||||||
|
def test_settings_and_check_know_the_step_sku(self):
|
||||||
|
from app.tiny import check, required_settings
|
||||||
|
self.assertNotIn('TINY_PRODUCT_UV_FOLHA', required_settings())
|
||||||
|
self.assertEqual(check(orders=self.tiny)['DTF UV 28,5 cm · folha montada'], 'ok')
|
||||||
|
del self.products['300']
|
||||||
|
self.tiny.skus.clear()
|
||||||
|
self.assertIn('DTFIMP.UV.010CM', check(orders=self.tiny)['DTF UV 28,5 cm · folha montada'])
|
||||||
|
|
||||||
|
|
||||||
@mock.patch.dict(os.environ, PRODUCTS)
|
@mock.patch.dict(os.environ, PRODUCTS)
|
||||||
class TinyProbeTests(FakeTinyCase):
|
class TinyProbeTests(FakeTinyCase):
|
||||||
"""The supervised console tool run against the fake Tiny."""
|
"""The supervised console tool run against the fake Tiny."""
|
||||||
|
|||||||
@@ -439,7 +439,8 @@
|
|||||||
// Paying: card (the default, paid on this page) or PIX (paid on its own page).
|
// Paying: card (the default, paid on this page) or PIX (paid on its own page).
|
||||||
async function escolhaPagamento(quote, version) {
|
async function escolhaPagamento(quote, version) {
|
||||||
const session=await ready;
|
const session=await ready;
|
||||||
const opcoes=[...(session.payment_public_key?[['credito','Cartão de crédito'],['debito','Cartão de débito']]:[]),['pix','PIX']];
|
// Credit card and PIX: the store does not take debit cards.
|
||||||
|
const opcoes=[...(session.payment_public_key?[['credito','Cartão de crédito']]:[]),['pix','PIX']];
|
||||||
let escolhido=opcoes[0][0];
|
let escolhido=opcoes[0][0];
|
||||||
const grupo=node('div',null,'metodos');
|
const grupo=node('div',null,'metodos');
|
||||||
grupo.setAttribute('role','radiogroup'); grupo.setAttribute('aria-label','Forma de pagamento');
|
grupo.setAttribute('role','radiogroup'); grupo.setAttribute('aria-label','Forma de pagamento');
|
||||||
@@ -454,7 +455,7 @@
|
|||||||
async function pinta() {
|
async function pinta() {
|
||||||
radios.forEach(el=>el.setAttribute('aria-checked',String(el.dataset.metodo===escolhido)));
|
radios.forEach(el=>el.setAttribute('aria-checked',String(el.dataset.metodo===escolhido)));
|
||||||
unmountCard(); area.replaceChildren(); message('');
|
unmountCard(); area.replaceChildren(); message('');
|
||||||
if (escolhido!=='pix') { await showCard(quote.approved, area, version, escolhido); return; }
|
if (escolhido!=='pix') { await showCard(quote.approved, area, version); return; }
|
||||||
area.append(node('p','Clique em Pagar para gerar o QR code do PIX.','pagNota'));
|
area.append(node('p','Clique em Pagar para gerar o QR code do PIX.','pagNota'));
|
||||||
button('Pagar',async event=>{
|
button('Pagar',async event=>{
|
||||||
if (!cartOk()) { await refresh(); return; }
|
if (!cartOk()) { await refresh(); return; }
|
||||||
@@ -550,7 +551,7 @@
|
|||||||
function unmountCard() {
|
function unmountCard() {
|
||||||
if (cardBrick) { try { cardBrick.unmount(); } catch(_) {} cardBrick=null; }
|
if (cardBrick) { try { cardBrick.unmount(); } catch(_) {} cardBrick=null; }
|
||||||
}
|
}
|
||||||
async function showCard(approved, into, version, tipo) {
|
async function showCard(approved, into, version) {
|
||||||
const holder=node('div');
|
const holder=node('div');
|
||||||
holder.id='cardPaymentBrick';
|
holder.id='cardPaymentBrick';
|
||||||
const espera=node('div',null,'skel skelBloco');
|
const espera=node('div',null,'skel skelBloco');
|
||||||
@@ -564,10 +565,8 @@
|
|||||||
const mp=new window.MercadoPago(session.payment_public_key,{locale:'pt-BR'});
|
const mp=new window.MercadoPago(session.payment_public_key,{locale:'pt-BR'});
|
||||||
cardBrick=await mp.bricks().create('cardPayment','cardPaymentBrick',{
|
cardBrick=await mp.bricks().create('cardPayment','cardPaymentBrick',{
|
||||||
initialization:{amount:approved.total_cents/100, payer:{email:approved.customer.mail}},
|
initialization:{amount:approved.total_cents/100, payer:{email:approved.customer.mail}},
|
||||||
// Each option takes only its kind of card; debit is paid at once.
|
// Credit cards only: the store does not take debit.
|
||||||
customization:{paymentMethods:tipo==='debito'
|
customization:{paymentMethods:{maxInstallments:12,types:{excluded:['debit_card']}},
|
||||||
? {maxInstallments:1,types:{excluded:['credit_card']}}
|
|
||||||
: {maxInstallments:12,types:{excluded:['debit_card']}},
|
|
||||||
// The option above already names the card; the form's own title
|
// The option above already names the card; the form's own title
|
||||||
// ("crédito ou débito") would contradict it.
|
// ("crédito ou débito") would contradict it.
|
||||||
visual:{hideFormTitle:true,
|
visual:{hideFormTitle:true,
|
||||||
|
|||||||
Reference in New Issue
Block a user