#J.K. - checkout
1 messages · Page 1 of 1 (latest)
I will paste you our code, i am not sure which part we need to change
let stripe = StripeCheckout.configure({
key: '<?= $stripe_public_key ?>',
image: 'https://stripe.com/img/documentation/checkout/marketplace.png',
locale: 'auto',
token: function(token) {
// Use the token to create the charge with a server-side script.
// You can access the token ID with token.id
let formData = new FormData();
formData.append('image', that.image);
let data = {
order: {
selected_color: that.selected_color,
measurment: that.measurment,
walls: that.walls,
price: that.price,
username: that.username,
email: that.email,
address: that.address,
phone: that.phone
},
stripe: {
email: token.email,
source: token.id
}
};
formData.append('action', 'handle_stripe');
formData.append('data', JSON.stringify(data));
that.turnSpinnerOn();
axios({
method: 'post',
url: '<?= admin_url('admin-ajax.php') ?>',
data: formData,
config: {headers : {'Content-type': 'multipart/form-data'}}
})
.then(function (response) {
that.turnSpinnerOff();
if(response != 'error'){
that.showPositiveFeedback();
} else {
that.showFailFeedback();
}
})
.catch(function (error) {
that.turnSpinnerOff();
that.showFailFeedback();
});
}
});
stripe.open({
name: 'windproofcurtains',
description: 'wall/s',
amount: this.price,
currency: 'gbp'
});
}
Can you clarify exactly what's the issue? Note that implementing Stripe Checkout requires a developer, just copy-pasting code from the documentation won't work.
we are migration from legacy integration
to your new one
we need to know which part needs to be changed
or this part?
$stripe_secret_key = get_option('stripe_secret_key');
Stripe::setApiKey( $stripe_secret_key );/secret key/
$customer = Customer::create([
'email' => $this->json['stripe']['email'],
'source' => $this->json['stripe']['source']
]);
$charge = Charge::create([
'customer' => $customer->id,
'amount' => $this->json['order']['price'],
'currency' => 'gbp'
]);
The two integrations are quite different, so a lot needs to change.
Legacy Checkout only uses JavaScript on the frontend code, and displays a popup. The new Checkout requires code on your backend, and will redirect to a Stripe hosted page.
So you need to send this URL to a developer to make the changes for you https://stripe.com/docs/payments/checkout/migration
He asked which code needs to be change, could you please mark it, from the one I pasted you?
- The JavaScript code you shared: everything needs to change. This code is creating the Checkout Session on the frontend, but now this has to happen on the backend.
- The PHP code you shared: instead of creating a charge, you need to create a Checkout Session, and redirect your users to the Checkout Session
url
All of this is explained on the migration page I linked earlier.