post https://api.easyship.com/2023-01/payment_sources
Create a payment sources.
Easyship won't hold the details of your credit card. We use stripe token
to attach the credit card to your easyship account on Stripe.
Please upload your credit card to stripe via Stripe Token JS.
Example:
<script src="https://js.stripe.com/v3/"></script>
<script>
// Retrieve Easyship stripe publishable api key through `GET /2023-01/account/stripe`
var stripe = Stripe('stripe_publishable_api_key');
// Create an instance of Elements.
// https://stripe.com/docs/js/elements_object/create_element?type=card
var elements = stripe.elements();
// Create a CardElement
var card = elements.create('card')
// Create your token from the CardElement data
// https://stripe.com/docs/js/tokens/create_token?type=cardElement
stripe.createToken(card).then(function (result) {
if (result.error) {
// error handling
} else {
// You would receive the `stripe token` with prefix `tok_`.
// `POST /2023-01/payment_sources` here to attach your card to Easyship
var token = result.token;
}
});
</script>
When the credit card needs 3DS (with response status code 202), proceed with the next step found in POST /2023-01/payment_sources/confirm_3ds
.
Required authorization scope: Payment Source
This API is currently in beta and is available upon request. Get in touch with your account manager or Easyship Support Team to enable it.