首页 > 解决方案 > 离子是否可以控制条带卡字段的值

问题描述

我在我的应用程序中使用条带我需要保存用户信用卡信息是否有任何方法可以控制诸如 cardnumber 、 exp date 和 cvc 之类的值?

这是html代码

<div *ngIf="checkoutData.form.payment_method =='stripe'" class="stripe-payment">
  <form action="/charge" method="post" id="payment-form">
    <div class="form-row">

      <div id="card-element">
        <!-- A Stripe Element will be inserted here. -->
      </div>

      <!-- Used to display form errors. -->
      <div id="card-errors" class="card-error" role="alert"></div>
    </div>
  </form>
</div>

这是onclick功能

async onClickStripeSubmit() {
    var ownerInfo = {
        owner: {
            name: this.checkoutData.form.billing_first_name + ' ' + this.checkoutData.form.billing_last_name,
            address: {
                line1: this.checkoutData.form.billing_address_1,
                city: this.checkoutData.form.billing_city,
                postal_code: this.checkoutData.form.billing_postcode,
                country: 'US',
            },
            email: this.checkoutData.form.billing_email
        },
    };
    if (!this.checkoutData.form.shipping) {
            this.checkoutData.form.shipping_first_name = this.checkoutData.form.billing_first_name;
            this.checkoutData.form.shipping_last_name = this.checkoutData.form.billing_last_name;
            this.checkoutData.form.shipping_company = this.checkoutData.form.billing_company;
            this.checkoutData.form.shipping_address_1 = this.checkoutData.form.billing_address_1;
            this.checkoutData.form.shipping_address_2 = this.checkoutData.form.billing_address_2;
            this.checkoutData.form.shipping_city = this.checkoutData.form.billing_city;
            this.checkoutData.form.shipping_country = this.checkoutData.form.billing_country;
            this.checkoutData.form.shipping_state = this.checkoutData.form.billing_state;
            this.checkoutData.form.shipping_postcode = this.checkoutData.form.billing_postcode;
        }
        this.buttonSubmit = true;
        this.PlaceOrder = "Placing Order";
        this.loading = await this.loadingController.create({
            message: 'Loading...',
            translucent: true,
            animated: true,
            backdropDismiss: true
        });
        await this.loading.present();
        console.log(this.cardElement);
        this.stripe.createSource(this.cardElement, ownerInfo).then((result) => {
        console.log(ownerInfo);
        console.log(this.cardElement);
        console.log(result);
            if (result.error) {
                this.loading.dismiss();
                // Inform the user if there was an error
                var errorElement = document.getElementById('card-errors');
                errorElement.textContent = result.error.message;
            } else {
                this.checkoutData.form.stripe_source = result.source.id;
                 console.log(this.checkoutData.form.stripe_source);
                this.stripNewPayment();
            }
        });
}

我需要控制该值,以便我可以保存条带结果响应仅给出卡的最后 4 位数字和日期。我需要破解这个我不知道如何但我需要保存这些输入

标签: angularionic-frameworkstripe-paymentsionic4

解决方案


出于安全原因和PCI 合规性,这不是可以做到的。Elements不允许您访问原始卡详细信息。这是为了满足 PCI 合规性的要求而构建的,访问原始卡详细信息将使您处于更高的范围内。

您永远不需要客户的原始卡详细信息。您可以将卡保存在您的 Stripe 帐户中的客户身上,以便您以后可以再次向他们收费,而无需再次询问他们的卡详细信息。这在此处有更多详细信息:https ://stripe.com/docs/payments/save-during-payment


推荐阅读