Wallet

Instructions to help you to create a user wallet, with multiple credit card.

If you are looking for instructions about how to implement our wallet feature, here is where you will find it.

User Wallet

1. Adding credit card to user wallet

First things first! To a nice start for a successful wallet implementation, you need to register a credit card into a user id (also a.k.a wallet). It's quite simple if you follow the request below:

curl -X POST \
  'http://api.ingresse.com/wallet/creditcard?publickey={{PUBLICKEY}}&usertoken={{USERTOKEN}}' \
  -H 'Content-Type: application/json' \
  -H 'cache-control: no-cache' \
  -d '{
	"number": "54970992207322124",
	"expiration": "01/26",
	"holder": "Joe Doe",
	"document": "42111111111111111",
	"cvv": "660"
}'

To see more details about the parameters listed above, please check this Create a Credit Card Token API.

If you succeed in this mission, you will receive a 200 code as return.

📘

Saving a credit card at the same time that placing an order

If you prefer, you can save the credit card information directly with the Pay Transaction API using the property creditCard.save as true.

2. Check the registered credit card in the user wallet

For a double-check to guarantee the credit card information is registered, you can implement the following request:

curl -X GET \
  'http://api.ingresse.com/wallet?publickey={{PUBLICKEY}}&usertoken={{USERTOKEN}}' \
  -H 'Content-Type: application/json' \
  -H 'cache-control: no-cache'

This implementation is quite simple, but if you have the curiosity to check it a little bit more you can go to Get User Wallet API reference.

If you did a good job, you will receive a 200 code as a reward.

3. How to set a credit card as default

In case the user registered more than one credit card, it is possible to help him/her to choose which one will be used as default.

curl -X PUT \
  'http://api.ingresse.com/wallet/creditcard/ec048aaa-0268-4b1b-bda5-7ce3d76ff4c9?publickey={{PUBLICKEY}}&usertoken={{USERTOKEN}}' \
  -H 'Content-Type: application/json' \
  -H 'cache-control: no-cache' \
  -d '{
	"default": 1
}'

For further information about this request look into Set a Credit Card as Default.

200 = Great Job!

🚧

New credit cards as default

In case you add a new credit card during the purchase flow, this new credit card will be set as the default automatically.

Placing Orders With Credit Card Token

4. Now you need to start a transaction

As we are done due selecting one credit card as default, it is necessary to implement the start transaction request in order to make the wallet happen.

curl -X POST \
  'http://api.ingresse.com/shop?apikey={{PUBLICKEY}}' \
  -H 'Content-Type: application/json' \
  -H 'cache-control: no-cache' \
  -d '{
  "extras": [
    {
      "externalId": "999",
      "name": "Coke (355ml)",
      "quantity": 1,
      "unitPrice": 100
    }  
  ]
}'

Some people like to deep dive into the details, if you are one of them you are welcome to look into the Start Transaction section in here Whitelabel Payments.

5. Authorising an amount in the default credit card

Now that all the required elements to implement the wallet are finally set, you can proceed to authorise an amount in the user default credit card.

curl -X POST \
  'http://api.ingresse.com/shop/3DBD2E994320B5ED06A437021B37F396E5218BC5/payment?publickey={{PUBLICKEY}}' \
  -H 'Content-Type: application/json' \
  -H 'cache-control: no-cache' \
  -d '{
    "method": "creditCardToken",
    "document": "35577372844",
    "softDescriptor": "ING",
    "capture": "false",
    "creditCardToken": {
        "token": "a7f2e50f-a62e-4160-8705-e99920eb837b",
        "installments": 1,
        "cvv": "150"
    },
    "customer": {
        "name": "Hugo Campos",
        "externalId": "12345",
        "address": {
            "street": "Rua Joaquim Floriano",
            "number": "820",
            "complement": "20o andar",
            "zipcode": "04534013",
            "city": "São Paulo",
            "state": "SP",
            "country": "Brasil",
            "district": "SP"
        }
    },
    "interest": 100,
    "postbackUrl": "https://test.com"
}'

6. Once it's authorized, now it's possible to be capture

The section title says by itself. But you have to keep in mind that this application is set to only accept capture an amount fewer or equal the authorised one.

curl -X POST \
  'http://api.ingresse.com/shop/{{transactionId}}/capture?publickey={{PUBLICKEY}}&usertoken={{USERTOKEN}}' \
  -H 'Content-Type: application/json' \
  -H 'cache-control: no-cache' \
  -d '{
	"amount": "20.00"
}'

It was built to be simple, but if you need to look over the line codes go for it here Capture a Payment.

7. If the credit card expires, get lost or broken.

It's very important to allow the user to update his/her wallet, and deleting a credit card is a way to do that.

curl -X DELETE \
  'http://api.ingresse.com/wallet/creditcard/420a57fd-b964-468b-b3d7-30b0a497420e?publickey={{PUBLICKEY}}&usertoken={{USERTOKEN}}' \
  -H 'Content-Type: application/json' \
  -H 'cache-control: no-cache'

That's all for now, but you always can go further with more information within our documentation. For this section, check it out in Delete Credit Card Token.


What’s Next

Since you are integrating payments, we think you may be interested in one of the topics below.