lib/active_merchant/billing/gateways/blue_pay.rb in activemerchant-1.121.0 vs lib/active_merchant/billing/gateways/blue_pay.rb in activemerchant-1.123.0
- old
+ new
@@ -82,10 +82,11 @@
add_invoice(post, options)
add_address(post, options)
add_customer_data(post, options)
add_rebill(post, options) if options[:rebill]
add_duplicate_override(post, options)
+ add_stored_credential(post, options)
post[:TRANS_TYPE] = 'AUTH'
commit('AUTH_ONLY', money, post, options)
end
# Perform a purchase, which is essentially an authorization and capture in a single operation.
@@ -105,10 +106,11 @@
add_invoice(post, options)
add_address(post, options)
add_customer_data(post, options)
add_rebill(post, options) if options[:rebill]
add_duplicate_override(post, options)
+ add_stored_credential(post, options)
post[:TRANS_TYPE] = 'SALE'
commit('AUTH_CAPTURE', money, post, options)
end
# Captures the funds from an authorize transaction.
@@ -457,9 +459,36 @@
post[:DO_REBILL] = '1'
post[:REB_AMOUNT] = amount(options[:rebill_amount])
post[:REB_FIRST_DATE] = options[:rebill_start_date]
post[:REB_EXPR] = options[:rebill_expression]
post[:REB_CYCLES] = options[:rebill_cycles]
+ end
+
+ def add_stored_credential(post, options)
+ post[:cof] = initiator(options)
+ post[:cofscheduled] = scheduled(options)
+ end
+
+ def initiator(options)
+ return unless initiator = options.dig(:stored_credential, :initiator)
+
+ case initiator
+ when 'merchant'
+ 'M'
+ when 'cardholder'
+ 'C'
+ end
+ end
+
+ def scheduled(options)
+ return unless reason_type = options.dig(:stored_credential, :reason_type)
+
+ case reason_type
+ when 'recurring' || 'installment'
+ 'Y'
+ when 'unscheduled'
+ 'N'
+ end
end
def post_data(action, parameters = {})
post = {}
post[:version] = '1'