#aruljothi-apple-sub
1 messages · Page 1 of 1 (latest)
hello alex
i need applepay subscrption
paymentRequest.canMakePayment().then(function(result) {
if (result) {
prButton.mount('#payment-request-button');
} else {
document.getElementById('payment-request-button').style.display = 'block';
}
});
paymentRequest.on('paymentmethod', function(ev) {}
first created button using stipe element
Next created the payment intent
After payemnt intent creation called this
stripe.confirmCardPayment(clientSecret,{payment_method: ev.paymentMethod.id},{handleActions: false})
.then(function(confirmResult) {
hi
hello, could you share what is the issue you're facing?
i need applepay subscrption
if i pass customer with payment method attached
then i will create subscription means following error displyed- "The customer does not have a payment method with the ID pm_1JjhsJIX5abeNCfAdGn89ylv. The payment method must be attached to the customer."
@idle shore as the error message mentioned : for a subscription payment, the payment method must be attached to the customer. So you should
- attach the created PaymentMethod to the customer
- create the PaymentIntent
- stripe.confirmCardPayment (clientSecret).then...
if i attach payment method -This PaymentMethod was previously used without being attached to a Customer or was detached from a Customer, and may not be used again.
this error displayed
@idle shore have you tried making a call to your server to attach the card to the customer first? like the below
paymentRequest.on('paymentmethod', function(ev) {
// make a call to your server to attach the card to the customer first
}
okay
i am created customer in this function paymentRequest.on('paymentmethod', function(ev) {
}
@idle shore alright, so are you having any other problems / errors?
paymentRequest.on('paymentmethod', function(ev) {
fetch('https://dhyanfoundation.org.uk/ajax_function.php', {
method: "POST",
headers: {'Content-Type': 'application/json',},
body: JSON.stringify({'customer_name':customer_name,'customer_email':emailaddress,'ajax_call':'create_customer'}),
})
.then(function(customer_result) {
return customer_result.json();
})
.then(function( customer_data ) {
added aattchedment customer in this palce
but this gives the above errors
what error are you receiving now?
This PaymentMethod was previously used without being attached to a Customer or was detached from a Customer, and may not be used again.
can you share the payment method id? it'd look like pm_123
@idle shore this is a live payment method, are you testing in live mode?
it's been used for a charge (and was not previously attached to a customer) before, which is why that particular payment method cannot be reused.
can you test in test mode, and create a new payment method to be attached to a customer
live mode - payment method pm_1JmCVRIX5abeNCfA9L3TJGlI
please check - https://dashboard.stripe.com/logs/req_ZvBbasC45Pvfom
{
"customer": "cus_KR4eGGBLyVeIat",
"default_payment_method": "pm_1JmCVRIX5abeNCfA9L3TJGlI",
"items": {
"0": {
"price": "price_1JmCVSIX5abeNCfAFXIZCLwo"
}
}
}
Response body
{
"error": {
"message": "The customer does not have a payment method with the ID pm_1JmCVRIX5abeNCfA9L3TJGlI. The payment method must be attached to the customer.",
"param": "payment_method",
"type": "invalid_request_error"
}
}
my question here is, are you intentionally doing this in live mode?
most people would prefer to do this in test mode, to avoid charging their credit card
you can test applepay in test mode
you should use your test API keys, Stripe will recognize that you are in test mode and will return a successful test card token for you to use.
okay we will check
i'd suggest shifting to using test mode first before you continue
okay sure we will alter first