Skip to content

Commit

Permalink
Merge pull request #440 from VAlmea/issue/395
Browse files Browse the repository at this point in the history
Issue/395
  • Loading branch information
WillStrohl authored Jan 10, 2023
2 parents 30a5c75 + f851720 commit 7379729
Show file tree
Hide file tree
Showing 312 changed files with 3,531 additions and 13,461 deletions.
1 change: 1 addition & 0 deletions .build/ModulePackage.targets
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
<Copy SourceFiles="$(MSBuildDnnBinPath)\log4net.dll" DestinationFolder="$(ModulesBuildFolder)\bin" />
<Copy SourceFiles="$(MSBuildDnnBinPath)\paypal_base.dll" DestinationFolder="$(ModulesBuildFolder)\bin" />
<Copy SourceFiles="$(MSBuildDnnBinPath)\Stripe.net.dll" DestinationFolder="$(ModulesBuildFolder)\bin" />
<Copy SourceFiles="$(MSBuildDnnBinPath)\Microsoft.Bcl.AsyncInterfaces.dll" DestinationFolder="$(ModulesBuildFolder)\bin" />
<Copy SourceFiles="$(MSBuildDnnBinPath)\DocumentFormat.OpenXml.dll" DestinationFolder="$(ModulesBuildFolder)\bin" />
<Copy SourceFiles="$(MSBuildDnnBinPath)\DocumentFormat.OpenXml.Extensions.dll" DestinationFolder="$(ModulesBuildFolder)\bin" />
<Copy SourceFiles="$(MSBuildDnnBinPath)\EntityFramework.dll" DestinationFolder="$(ModulesBuildFolder)\bin" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
jQuery(function ($) {
const clientSecret = $("#PaymentIntentClientSecret").val()
const stripePublicKey = $("#StripePublicKey").val();
const stripe = stripePublicKey ? Stripe(stripePublicKey) : null;

// Common ----------------------

Expand Down Expand Up @@ -422,7 +425,11 @@
var showBillingNm = (blRes != null && blRes.NormalizedAddress != null);

if (!showShippingNm && !showBillingNm) {
self.saveForm();
if (clientSecret) {
CreatePaymentMethod(clientSecret)
} else {
self.saveForm();
}
}
else {
if (showShippingNm) {
Expand Down Expand Up @@ -866,6 +873,52 @@
$("table.totaltable").attr("class", "table table-striped table-hover totaltable");
}

async function CreatePaymentMethod(clientSecret) {
var status = await checkPaymentStatus(clientSecret)
if (status === "requires_payment_method") {
var cardNumber = $("#cccardnumber").val();
var cvc = $("#ccsecuritycode").val();
var expMonth = $("#ccexpmonth").val();
var expYear = $("#ccexpyear").val();
var paymentIntent = $("#PaymentIntentId").val();
var pm = "";
if (cardNumber && cvc && expMonth && expYear) {
var reqUrl = hcc.getServiceUrl("checkout/AttachPaymentMethod");
$.post(reqUrl, { "CardNumber": cardNumber, "Cvc": cvc, "ExpMonth": expMonth, "ExpYear": expYear, "PaymentIntentId": paymentIntent }, null, "json")
.done((data) => {
stripe
.retrievePaymentIntent(clientSecret)
.then(async (result) => {
if (result.paymentIntent) {
if (result.paymentIntent.status == "requires_action") {
var result = await stripe.confirmCardPayment(clientSecret);
Addresses.saveForm()
} else {
Addresses.saveForm()
}
} else {
Addresses.saveForm()
}
});
})
.fail(function (error) {
console.log("error: " + error);
});
} else {
Addresses.saveForm()
}
} else {
Addresses.saveForm()
}
};


async function checkPaymentStatus(clientSecret) {

const { paymentIntent } = await stripe.retrievePaymentIntent(clientSecret);
return paymentIntent.status;
}

// Initialization --------------------------

OrderSummary.init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
<div class="hc-creditcard-form clearfix">
<input type="hidden" id="aesInitVector" name="aesInitVector" value="@Model.AESEncryptInitVector" />
<input type="hidden" id="aesKey" name="aesKey" value="@Model.AESEncryptKey" />
@if (HccApp.CurrentStore.Settings.PaymentCreditCardGateway.Equals(PaymentGatewayType.Stripe))
{
<input type="hidden" id="PaymentIntentId" name="PaymentIntentId" value="@Model.PaymentIntentId" />
<input type="hidden" id="PaymentIntentClientSecret" name="PaymentIntentClientSecret" value="@Model.PaymentIntentClientSecret" />
<input type="hidden" id="StripePublicKey" value="@Model.StripePublicKey" />
}
<div class="form-group row">
<label class="col-sm-3 offset-sm-1 col-form-label">&nbsp;</label>
<div class="col-sm-6 offset-sm-0">
Expand Down Expand Up @@ -66,11 +72,11 @@
<div class="form-group row">
<label class="col-sm-3 offset-sm-1 col-form-label">@Localization.GetString("ExpDate"):</label>
<div class="col-sm-6 offset-sm-0 form-inline">
<select name="ccexpmonth" class="form-control small hc-cc-expmonth">
<select id="ccexpmonth" name="ccexpmonth" class="form-control small hc-cc-expmonth">
<option value="0">--</option>
@Months()
</select>
<select name="ccexpyear" class="form-control medium hc-cc-expyear">
<select id="ccexpyear" name="ccexpyear" class="form-control medium hc-cc-expyear">
<option value="0">----</option>
@Years()
</select>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
jQuery(function ($) {
const clientSecret = $("#PaymentIntentClientSecret").val()
const stripePublicKey = $("#StripePublicKey").val();
const stripe = stripePublicKey ? Stripe(stripePublicKey) : null;

// Common ----------------------

Expand Down Expand Up @@ -416,7 +419,11 @@
var showBillingNm = (blRes != null && blRes.NormalizedAddress != null);

if (!showShippingNm && !showBillingNm) {
self.saveForm();
if (clientSecret) {
CreatePaymentMethod(clientSecret)
} else {
self.saveForm();
}
}
else {
if (showShippingNm) {
Expand Down Expand Up @@ -858,6 +865,52 @@
}
};

async function CreatePaymentMethod(clientSecret) {
var status = await checkPaymentStatus(clientSecret)
if (status === "requires_payment_method") {
var cardNumber = $("#cccardnumber").val();
var cvc = $("#ccsecuritycode").val();
var expMonth = $("#ccexpmonth").val();
var expYear = $("#ccexpyear").val();
var paymentIntent = $("#PaymentIntentId").val();
var pm = "";
if (cardNumber && cvc && expMonth && expYear) {
var reqUrl = hcc.getServiceUrl("checkout/AttachPaymentMethod");
$.post(reqUrl, { "CardNumber": cardNumber, "Cvc": cvc, "ExpMonth": expMonth, "ExpYear": expYear, "PaymentIntentId": paymentIntent }, null, "json")
.done((data) => {
stripe
.retrievePaymentIntent(clientSecret)
.then(async (result) => {
if (result.paymentIntent) {
if (result.paymentIntent.status == "requires_action") {
var result = await stripe.confirmCardPayment(clientSecret);
Addresses.saveForm()
} else {
Addresses.saveForm()
}
} else {
Addresses.saveForm()
}
});
})
.fail(function (error) {
console.log("error: " + error);
});
} else {
Addresses.saveForm()
}
} else {
Addresses.saveForm()
}
};


async function checkPaymentStatus(clientSecret) {

const { paymentIntent } = await stripe.retrievePaymentIntent(clientSecret);
return paymentIntent.status;
}

// Initialization --------------------------

OrderSummary.init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
<div class="hc-creditcard-form">
<input type="hidden" id="aesInitVector" name="aesInitVector" value="@Model.AESEncryptInitVector" />
<input type="hidden" id="aesKey" name="aesKey" value="@Model.AESEncryptKey" />
@if (HccApp.CurrentStore.Settings.PaymentCreditCardGateway.Equals(PaymentGatewayType.Stripe))
{
<input type="hidden" id="PaymentIntentId" name="PaymentIntentId" value="@Model.PaymentIntentId" />
<input type="hidden" id="PaymentIntentClientSecret" name="PaymentIntentClientSecret" value="@Model.PaymentIntentClientSecret" />
<input type="hidden" id="StripePublicKey" value="@Model.StripePublicKey" />
}
<div class="dnnFormItem">
<label class="dnnLabel">&nbsp;</label>
<span class="hc-card-icons">
Expand Down Expand Up @@ -64,12 +70,12 @@
<div class="dnnFormItem">
<label class="dnnLabel">@Localization.GetString("ExpDate")</label>

<select name="ccexpmonth" class="hc-cc-expmonth" tabindex="502">
<select id="ccexpmonth" name="ccexpmonth" class="hc-cc-expmonth" tabindex="502">
<option value="0">--</option>
@Months()
</select>

<select name="ccexpyear" class="hc-cc-expyear" tabindex="503">
<select id="ccexpyear" name="ccexpyear" class="hc-cc-expyear" tabindex="503">
<option value="0">----</option>
@Years()
</select>
Expand All @@ -78,7 +84,7 @@
<div class="dnnFormItem">
<label class="dnnLabel">@Localization.GetString("SecurityCode")</label>

<input type="text" name="ccsecuritycode" size="5" tabindex="504"
<input type="text" id="ccsecuritycode" name="ccsecuritycode" size="5" tabindex="504"
maxlength="4" class="hc-cc-seccode @Model.IsErr("ccsecuritycode")" autocomplete="off" />

</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
jQuery(function ($) {
const clientSecret = $("#PaymentIntentClientSecret").val()
const stripePublicKey = $("#StripePublicKey").val();
const stripe = stripePublicKey ? Stripe(stripePublicKey) : null;

// Common ----------------------

Expand Down Expand Up @@ -422,7 +425,11 @@
var showBillingNm = (blRes != null && blRes.NormalizedAddress != null);

if (!showShippingNm && !showBillingNm) {
self.saveForm();
if (clientSecret) {
CreatePaymentMethod(clientSecret)
} else {
self.saveForm();
}
}
else {
if (showShippingNm) {
Expand Down Expand Up @@ -866,6 +873,52 @@
$("table.totaltable").attr("class", "table table-striped table-hover totaltable");
}

async function CreatePaymentMethod(clientSecret) {
var status = await checkPaymentStatus(clientSecret)
if (status === "requires_payment_method") {
var cardNumber = $("#cccardnumber").val();
var cvc = $("#ccsecuritycode").val();
var expMonth = $("#ccexpmonth").val();
var expYear = $("#ccexpyear").val();
var paymentIntent = $("#PaymentIntentId").val();
var pm = "";
if (cardNumber && cvc && expMonth && expYear) {
var reqUrl = hcc.getServiceUrl("checkout/AttachPaymentMethod");
$.post(reqUrl, { "CardNumber": cardNumber, "Cvc": cvc, "ExpMonth": expMonth, "ExpYear": expYear, "PaymentIntentId": paymentIntent }, null, "json")
.done((data) => {
stripe
.retrievePaymentIntent(clientSecret)
.then(async (result) => {
if (result.paymentIntent) {
if (result.paymentIntent.status == "requires_action") {
var result = await stripe.confirmCardPayment(clientSecret);
Addresses.saveForm()
} else {
Addresses.saveForm()
}
} else {
Addresses.saveForm()
}
});
})
.fail(function (error) {
console.log("error: " + error);
});
} else {
Addresses.saveForm()
}
} else {
Addresses.saveForm()
}
};


async function checkPaymentStatus(clientSecret) {

const { paymentIntent } = await stripe.retrievePaymentIntent(clientSecret);
return paymentIntent.status;
}

// Initialization --------------------------

OrderSummary.init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
<div class="hc-creditcard-form clearfix">
<input type="hidden" id="aesInitVector" name="aesInitVector" value="@Model.AESEncryptInitVector" />
<input type="hidden" id="aesKey" name="aesKey" value="@Model.AESEncryptKey" />
@if (HccApp.CurrentStore.Settings.PaymentCreditCardGateway.Equals(PaymentGatewayType.Stripe))
{
<input type="hidden" id="PaymentIntentId" name="PaymentIntentId" value="@Model.PaymentIntentId" />
<input type="hidden" id="PaymentIntentClientSecret" name="PaymentIntentClientSecret" value="@Model.PaymentIntentClientSecret" />
<input type="hidden" id="StripePublicKey" value="@Model.StripePublicKey" />
}
<div class="form-group">
<label class="col-sm-4 control-label">&nbsp;</label>
<div class="col-sm-offset-0 col-sm-6">
Expand Down Expand Up @@ -70,7 +76,7 @@
<option value="0">--</option>
@Months()
</select>
<select name="ccexpyear" class="form-control medium hc-cc-expyear">
<select id="ccexpyear" name="ccexpyear" class="form-control medium hc-cc-expyear">
<option value="0">----</option>
@Years()
</select>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
jQuery(function ($) {
const clientSecret = $("#PaymentIntentClientSecret").val()
const stripePublicKey = $("#StripePublicKey").val();
const stripe = stripePublicKey ? Stripe(stripePublicKey) : null;

// Common ----------------------

Expand Down Expand Up @@ -422,7 +425,11 @@
var showBillingNm = (blRes != null && blRes.NormalizedAddress != null);

if (!showShippingNm && !showBillingNm) {
self.saveForm();
if (clientSecret) {
CreatePaymentMethod(clientSecret)
} else {
self.saveForm();
}
}
else {
if (showShippingNm) {
Expand Down Expand Up @@ -866,6 +873,52 @@
$("table.totaltable").attr("class", "table table-striped table-hover totaltable");
}

async function CreatePaymentMethod(clientSecret) {
var status = await checkPaymentStatus(clientSecret)
if (status === "requires_payment_method") {
var cardNumber = $("#cccardnumber").val();
var cvc = $("#ccsecuritycode").val();
var expMonth = $("#ccexpmonth").val();
var expYear = $("#ccexpyear").val();
var paymentIntent = $("#PaymentIntentId").val();
var pm = "";
if (cardNumber && cvc && expMonth && expYear) {
var reqUrl = hcc.getServiceUrl("checkout/AttachPaymentMethod");
$.post(reqUrl, { "CardNumber": cardNumber, "Cvc": cvc, "ExpMonth": expMonth, "ExpYear": expYear, "PaymentIntentId": paymentIntent }, null, "json")
.done((data) => {
stripe
.retrievePaymentIntent(clientSecret)
.then(async (result) => {
if (result.paymentIntent) {
if (result.paymentIntent.status == "requires_action") {
var result = await stripe.confirmCardPayment(clientSecret);
Addresses.saveForm()
} else {
Addresses.saveForm()
}
} else {
Addresses.saveForm()
}
});
})
.fail(function (error) {
console.log("error: " + error);
});
} else {
Addresses.saveForm()
}
} else {
Addresses.saveForm()
}
};


async function checkPaymentStatus(clientSecret) {

const { paymentIntent } = await stripe.retrievePaymentIntent(clientSecret);
return paymentIntent.status;
}

// Initialization --------------------------

OrderSummary.init();
Expand Down
Loading

0 comments on commit 7379729

Please sign in to comment.