Payment Method

In order to setup a payment method for future use, you need to first vault the card and have a token("tok-xxxx") ready. Please refer to Vaulting to tokenize the card.

Then use the payment method API to accept the token and convert it to a payment method that can be used in the future.

Credit cards

Setup payment method using API - To create the payment method, simply pass the token and external_customer_id to the create payment method endpoint.

curl --location --request POST 'https://api.elements-sandbox.io/api/v1/payment_methods/' \
--header 'Authorization: Bearer mck_test_7PZxGNf-xXQ8A7lDXTJZWGDHPBwJ-p5PNJRQhY-kNft6IEulu0ACCqbsUkkPLUMINZk9SOIvhR6OJW9ZHup-JQ' \
--header 'Content-Type: application/json' \
--data-raw '{
    "token": "TOK-2ejkCm5odmzCqR2qA7MUkZLSGrHw9vsW8",
    "show_psp_references": true,
    "external_customer_id": "ext_cus_id_xxx"
}'
Elements::PaymentMethod.create({
   token: 'TOK-2ejkCm5odmzCqR2qA7MUkZLSGrHw9vsW8', 
   external_customer_id: 'ext_cus_id_xxx'
})
elements.PaymentMethod.create(
   token: "TOK-2ejkCm5odmzCqR2qA7MUkZLSGrHw9vsW8", 
   external_customer_id: "ext_cus_id_xxx"
)

Redirection type payment methods(PayPal, Kakao pay, Vipps etc)

For payment methods requires verification from the payment method side (e.g PayPal, KaKao pay, Vipps etc). Use Elements Mobile SDK to set it up. The SDK guides customers to complete the entire redirection flow with minimum effort.

  1. Whenever a customer tries to add a payment method on your client app - initialize the add payment method request using Elements SDK, the SDK will talk to its server and return an action that It should redirect to(Can be native url or app deeplink action)

  2. Redirect customers to the payment method app/web finish authorization. (e.g Paypal usually takes customer to their web to authenticate, other apps like Kakao pay requires in-app authorization)

  3. Once user authorized store payment method on the client app end, Elements SDK redirect user back to your client app, passed the information to server to store the payment method.

  4. Client app sends the payment method token to client server to store for future payment