const { result, error } = await unprice.customers.createPaymentMethod({
  customerId: "cus_1234567890",
  paymentProvider: "stripe",
  successUrl: "https://example.com/success",
  cancelUrl: "https://example.com/cancel"
});

if (error) {
  // handle potential network or bad request error
  // a link to our docs will be in the `error.docs` field
  console.error(error.message);
  return;
}

console.log(result);
{
  "success": true,
  "url": "https://checkout.stripe.com/pay/cs_test_1234567890"
}
const { result, error } = await unprice.customers.createPaymentMethod({
  customerId: "cus_1234567890",
  paymentProvider: "stripe",
  successUrl: "https://example.com/success",
  cancelUrl: "https://example.com/cancel"
});

if (error) {
  // handle potential network or bad request error
  // a link to our docs will be in the `error.docs` field
  console.error(error.message);
  return;
}

console.log(result);
{
  "success": true,
  "url": "https://checkout.stripe.com/pay/cs_test_1234567890"
}

Request

customerId
string
required
The ID of the customer to create a payment method for
paymentProvider
string
required
The payment provider to use
successUrl
string
required
The URL to redirect to after successful payment method creation
cancelUrl
string
required
The URL to redirect to if payment method creation is canceled

Response

success
boolean
required
Whether the payment method creation was successful
url
string
required
The URL to redirect the customer to for payment method creation