Skip to content

Commit

Permalink
fix: update payment validation and streamline payment profile retrieval
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Poyigi <[email protected]>
  • Loading branch information
sampoyigi committed Sep 22, 2024
1 parent 916a3aa commit 4ba4459
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
1 change: 0 additions & 1 deletion resources/js/process.square.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
}

ProcessSquare.prototype.init = function () {
console.log(this.$checkoutForm.checkout('selectedPaymentInput').val())
if (this.$checkoutForm.checkout('selectedPaymentInput').val() !== 'square') return

if (!$(this.options.cardSelector).length || $(this.options.cardSelector+' iframe').length)
Expand Down
2 changes: 1 addition & 1 deletion resources/js/process.stripe.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
this.$checkoutForm
.on('submitCheckoutForm', $.proxy(this.submitFormHandler, this))
.on('submit', function () {
if (self.$checkoutForm.find('input[name="form.payment"]:checked').val() !== 'stripe')
if (self.$checkoutForm.find('input[name="fields.payment"]:checked').val() !== 'stripe')
return

self.paymentElement?.update({disabled: true});
Expand Down
5 changes: 4 additions & 1 deletion resources/views/_partials/stripe/payment_form.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
@php($paymentProfile = $paymentMethod->paymentProfileExists($order->customer) ? $paymentMethod->findPaymentProfile($order->customer) : null)
@php($paymentProfile = $order->customer && $paymentMethod->paymentProfileExists($order->customer)
? $paymentMethod->findPaymentProfile($order->customer)
: null
)
<div
id="stripePaymentForm"
class="payment-form ms-2 mt-3"
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Controllers/Payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function index()
public function index_onSetDefault($context = null)
{
$data = $this->validate(post(), [
'default' => 'required|integer|exists:'.Payment::class.',payment_id',
'default' => 'required|alpha_dash|exists:'.Payment::class.',code',
]);

if (Payment::updateDefault($data['default'])) {
Expand Down

0 comments on commit 4ba4459

Please sign in to comment.