Skip to content

Commit

Permalink
add mit/cit fields
Browse files Browse the repository at this point in the history
  • Loading branch information
devton committed Oct 29, 2024
1 parent a7826be commit c498ff7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,17 @@ def get_encryption_key_json

def credit_card_attributes
contribution.reload
installments = get_installment
hash = {
payment_method: 'credit_card',
amount: delegator.value_with_installment_tax(get_installment),
amount: delegator.value_with_installment_tax(installments),
postback_url: ipn_pagarme_index_url(
host: CatarsePagarme.configuration.host,
subdomain: CatarsePagarme.configuration.subdomain,
protocol: CatarsePagarme.configuration.protocol
),
soft_descriptor: payment.project.permalink.gsub(/[\W\_]/, ' ')[0, MAX_SOFT_DESCRIPTOR_LENGTH],
installments: get_installment,
installments: installments,
customer: {
id: contribution.user.id,
email: contribution.user.email,
Expand All @@ -69,6 +70,9 @@ def credit_card_attributes
antifraud_metadata: af_metadata
}

# Adding recurrence_model field only if it's an installment payment
hash[:recurrence_model] = 'installment' if installments > 1

if params[:card_hash].present?
hash[:card_hash] = params[:card_hash]
else
Expand Down
10 changes: 9 additions & 1 deletion services/payment-service-api/lib/transaction_data_builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,22 @@ const buildTransactionData = (context) => {
const isCreditCard = payment.data.payment_method === 'credit_card'
const paymentData = isCreditCard ? cardTransactionData(context) : bankSlipTransactionData(context)
const transactionMetadata = buildTransactionMetadata(context)
return {

let transactionData = {
postback_url: process.env.POSTBACK_URL,
async: false,
payment_method: payment.data.payment_method,
amount: payment.data.amount,
...paymentData,
...transactionMetadata
}

// Add recurrence_model only for credit card transactions
if (isCreditCard) {
transactionData.recurrence_model = 'standing_order'
}

return transactionData
}

/*
Expand Down

0 comments on commit c498ff7

Please sign in to comment.