~singpolyma/jmp-pay

ee1034dfe78b4e9e960f53a4abca5d7f818f7887 — Stephen Paul Weber 27 days ago 1d3ddd6
Add more 3DS details
2 files changed, 23 insertions(+), 5 deletions(-)

M config.ru
M views/esim_adapter.slim
M config.ru => config.ru +2 -2
@@ 495,7 495,7 @@ class JmpPay < Roda
					body[:currency] = params["currency"]
					body[:order_at] = Time.now.strftime("%Y-%m-%d %H:%m:%S")
					body[:order_id] = sale_result.transaction.id
					body[:name] = "Customer"
					body[:name] = "#{params['given-name']} #{params['family-name']}"
					body[:city] = postal_lookup["results"].values.first.first["city"]
					body[:province_code] = postal_lookup["results"].values.first.first["state_code"]
					req.body = body.to_json


@@ 508,7 508,7 @@ class JmpPay < Roda
			end

			r.get do
				view :esim_adapter, locals: { antifraud: atfd }
				view :esim_adapter, locals: { antifraud: atfd, ip: request.ip }
			end
		end


M views/esim_adapter.slim => views/esim_adapter.slim +21 -3
@@ 117,6 117,14 @@ section data-hx-get="/esim-adapter/total" data-hx-trigger="input delay:1s,change
			div Email Address
			input.ts-control type="email" name="email" required=true

		label.half
			div Cardholder Given Name
			input.ts-control type="text" name="given-name" required=true

		label.half
			div Cardholder Surname
			input.ts-control type="text" name="family-name" required=true

		.htmx-indicator
			.lds-ring <div></div><div></div><div></div><div></div></div>
		#total


@@ 138,7 146,7 @@ javascript:
	if(window.localStorage) {
		var atfd = localStorage.getItem("atfd");
		if(!atfd) {
			atfd = "#{antifraud}";
			atfd = #{{antifraud.to_json}};
			localStorage.setItem("atfd", atfd);
		}
		document.querySelector("input[name=atfd]").value = atfd;


@@ 155,11 163,21 @@ javascript:

		braintreeInstance.requestPaymentMethod({
			threeDSecure: {
				amount: document.querySelector("input[name=amount]").value,
				amount: document.querySelector("*[name=amount]").value,
				requireChallenge: true,
				challengeRequested: true,
				collectDeviceData: true,
				email: document.querySelector("input[name=email]").value
				email: document.querySelector("*[name=email]").value,
				billingAddress: {
					givenName: document.querySelector("*[name=given-name]").value,
					surname: document.querySelector("*[name=family-name]").value,
					postalCode: document.querySelector("*[name=postal-code]").value,
					streetAddress: document.querySelector("*[name=street-address]").value,
					countryCodeAlpha2: document.querySelector("*[name=country-name]").value
				},
				additionalInformation: {
					ipAddress: #{{@ip.to_json}}
				}
			}
		}, function(err, payload) {
			if(err) {