#kun_api

1 messages ยท Page 1 of 1 (latest)

full whaleBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1267886420131840193

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

obtuse bay
#

Hello
pm_1PiIlHLK2TVZwhU0mt93gUx4 was created in test mode on acct_1KVm3XLK2TVZwhU0

#

Are you hard coding the payment method ID in your code anywhere?

chrome mason
#

no

#

can I show you my code implementation?

obtuse bay
#

sure

full whaleBOT
#

๐Ÿง‘โ€๐Ÿ’ป How to format code on Discord

Inline code: wrap in single backticks (`)

This:

The variable `foo` contains the value `bar`.

Will turn into this:

The variable foo contains the value bar.

Code blocks: wrap in three backticks (```)

Also, you can specify the language after the first three backticks to get syntax highlighting.

This:

```javascript
function foo() {
return 'bar';
}
```

Will turn into this:

function foo() {
  return 'bar';
}```

Notes about **code blocks**:
- Specifying the language is optional (e.g., you can omit `javascript` in the example above)
  - If you don't specify the language you won't get syntax highlighting
- When you're inside a code block (after you type \`\`\`) the `Return`/`Enter` key will add a new line instead of sending your message
  - Once you end the code block `Return`/`Enter` works normally again

You can [read more about message formatting on Discord's website.](https://support.discord.com/hc/en-us/articles/210298617)
chrome mason
#

thanks

#

Frontend

onSubmit(): void {
    if (this.cardForm.invalid) return;

    console.log("this.userInfo", this.userInfo);

    if (
      !this.userInfo?.subscriptionDetails?.isFreeTrialEnded &&
      !this.userInfo?.subscriptionDetails?.isFreeTrialActive
    ) {
      console.log(
        "this.this.calculatedAmountPayload",
        this.calculatedAmountPayload
      );
      if (!this.calculatedAmountPayload) {
        this.isSubscriptionDetailsMissing = true;
        return;
      }
    }

    this.isSubscriptionDetailsMissing = false;
    this.isPaymentCardAdding = true;
    console.log(this.cardForm.value, this.card.element);
    const { nameOnCard, billingAddress, city, country, postalCode } =
      this.cardForm.value;

    const paymentPayload = {
      userEmail: this.userInfo?.email,
      billingStreetAddress: billingAddress,
      billingCity: city,
      billingCountry: country?.name,
      billingZipCode: postalCode,
      paymentMethodId: "",
    };

    const ref = this.stripeService
      .createPaymentMethod({
        type: "card",
        card: this.card.element,
        billing_details: {
          name: nameOnCard,
        },
      })
      .subscribe(
        (result: any) => {
          console.log(result);
          if (result.paymentMethod) {
            console.log(result.paymentMethod.id);
            // Send paymentMethod.id to your backend for verification and to attach to a customer
          } else if (result.error) {
            console.error(result.error.message);
          }

          const ref2 = this.paymentService
            .addPaymentCard({
              ...paymentPayload,
              paymentMethodId: result?.paymentMethod?.id || "",
            })
#

Here I am getting the paymentMethodId from ngx stripe and then pass to my nest.js backend

#

let me give you some more information

I used publsh key of live mode here and what I get from stripe createPaymentMethod
is this

obtuse bay
#

So it doesn't look like your frotend code is using the right Live API key

#

livemode: false meaning the object was created in test mode

chrome mason
#

I check either my api is correct or not
I logged the value
and it confirmeted that my publishable key is correct

#

let mse sen you the screen shoot

#
 ngOnInit() {
    this.screenWidth = window.innerWidth;
    console.log('Our Stipe Public Key', environment.stripe.public_key);
    const stripePromise = loadStripe(environment.stripe.public_key, {
      stripeAccount: "acct_1E4JzvFrwl37tCGi",
    });
obtuse bay
#

it is possible that the key is getting set again to test mode somewhere in your code.. You'd want to investigate that..

chrome mason
#

so the error is coming because the publish key is not correct
once the key is correct livemode will be true and then I wont get this paymentMethoidId error

obtuse bay
#

Correct

chrome mason
#

let me double double check it

#

be right back

#

Brother Thank you very much for your support I solved it
Great support