Introduction to Saved Cards
Saved Cards have two seperate use-cases
a) 1-click-payments for returning customers. With Saved Cards you can offer your customers a lot of convenience with QuickPay Saved Cards. With this feature your customesr will only have to authorize their credit card once – after that they can pay without filling in their payment details.
Please note that Saved Cards can not currently be used for “1-click-payments” because of the PSD2 regulations. Read more in the PSD2 section below.
b) Non-scheduled recurring payments. While [subscriptions] are meant for scheduled recurring payments, in some cases you want to accept recurring payments from your customers, that are not scheduled.
PSD2
Saved Cards are currently only available for non-scheduled recurring payments, where the cardholder is not present. Read more on PSD2 and QuickPay
We expect Saved Cards to be available for “1-click-payments” again during 2021.
Create and authorize card
Use the card to complete a payment
Examples
1. Create a new card in QuickPay
First step is to create a new card entity in QuickPay.
Example request:
1 2 3 4 5 |
curl -u ':APIKEY' \ -H 'content-type:application/json' \ -H 'Accept-Version:v10' \ -X POST \ https://api.quickpay.net/cards |
Example response (snippet):
1 2 3 4 5 |
{ "id":2886958, "merchant_id":1234 ... } |
2. Authorize card using a link
Next step is to authorize the card.
The recommended way is to request the QuickPay API for a payment link, where your customer can fill in their card information.
Selected parameters. See more in the API documentation.
Parameter | Description | Parameter type | Data type | Required? |
---|---|---|---|---|
id | Transaction id | path | integer | true |
Example request:
1 2 3 4 5 |
curl -u ':APIKEY' \ -H 'content-type:application/json' \ -H 'Accept-Version:v10' \ -X PUT \ https://api.quickpay.net/cards/2886958/link |
Example response:
1 2 3 |
{ "url":"https://payment.quickpay.net/cards/b4674ca58c6c8a2afeea105fb1b5ca22293a1dc17fa852afa0495010999c2d00" } |
When your customer has filled in the card information using the link, the saved card is now authorized.
No funds are withdrawn from your customer yet.
3. Create token
As of now the customers card is authorized, but no funds have been withdrawed from their account.
Each time the card should be used, your system request the QuickPay API for a token from the Saved Card.
This token can be used once to authorize a payment, subscription or payout.
Example request:
1 2 3 4 5 |
curl -u ':APIKEY' \ -H 'content-type:application/json' \ -H 'Accept-Version:v10' \ -X POST \ https://api.quickpay.net/cards/2886958/tokens |
Example response (snippet):
1 2 3 4 5 6 |
{ "token":"b1467a5e-9927-4574-a065-e704144faae6", "is_used":false, "created_at":"2017-10-25T13:16:24Z" ... } |
The token can now be used to complete a payment, subscription or payout.
1. Create a new payment
Next step is to create a payment entity in QuickPay
Selected parameters. See more in the API documentation.
Parameter | Description | Parameter type | Data type | Required? |
---|---|---|---|---|
order_id | Unique order number | form | string | true |
currency | Currency | form | string | true |
Example request:
1 2 3 4 5 6 |
curl -u ':APIKEY \ -H 'content-type:application/json' \ -H 'Accept-Version:v10' \ -X POST \ -d '{"order_id":"test1ab","currency":"dkk"}' \ https://api.quickpay.net/cards |
Example response (snippet):
1 2 3 4 5 6 7 8 9 10 |
{ "id":98648340, "merchant_id":1234, "order_id":"test1ab", "accepted":false, "type":"Payment", "currency":"DKK", "state":"initial" ... } |
2. Authorize payment using the token
Final step is to authorize the payment using the card token created in step 3.
Selected parameters. See more in the API documentation.
Parameter | Description | Parameter type | Data type | Reqired? |
---|---|---|---|---|
id | Transaction id | path | integer | true |
card[token] | Card token | form | string | false |
Example request:
1 2 3 4 5 6 7 |
curl -u ':APIKEY' \ -H 'content-type:application/json' \ -H 'Accept-Version:v10' \ -X POST \ -d '{"card":{"token":"b1467a5e-9927-4574-a065-e704144faae6"}, "amount":1000}' https://api.quickpay.net/payment/98648340/authorize |
Example response (snippet):
1 2 3 4 5 6 7 8 |
{ "id":98648340, "merchant_id":1234, "order_id":"test1ab", "accepted":false, "state":"pending" ... } |
In the response the payments state is pending, as the authorize is not yet approved or rejected by your acquirer.
Use GET /payments/98648340
to check the payment status, by looking at the accepted
parameter.
Implementation Example
Authorizing the credit card
1 2 3 4 5 6 7 8 |
# Use the official quickpay-ruby-client gem require "quickpay/api/client" client = QuickPay::API::Client.new(password: ENV["QUICKPAY_API_KEY"]) card = client.post("/cards") link = client.put("/cards/#{card["id"]}/link") puts link["url"] # Redirect your customer to this URL |
Accepting payments using the saved card
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# Use the official quickpay-ruby-client gem require "quickpay/api/client" client = QuickPay::API::Client.new(password: ENV["QUICKPAY_API_KEY"]) tokens = client.post("/cards/#{card['id']}/tokens") payment = client.post( "/payments", headers: { "Content-Type" => "application/json" }, body: { order_id: "0001", currency: "DKK" }.to_json ) authorize = client.post( "/payments/#{payment['id']}/authorize", headers: { "Content-Type" => "application/json" }, query: { "synchronized" => "" }, body: { amount: 100, card: { token: tokens['token'] } }.to_json ) |