Transaction - max-power/paymill-ruby GitHub Wiki
A transaction is the charging of a credit card or a direct debit. In this case you need a new transaction object with either a valid token, payment, client + payment or preauthorization. Every transaction has a unique identifier which will be generated by Paymill to identify every transaction. You can issue/create, list and display transactions in detail. Refunds can be done in an extra entity.
You have to create at least either a token or a payment object before you can execute a transaction. You get back a response object indicating whether a transaction was successful or not.
Note: The transaction will not be charged at the bank if the test keys are implemented in your code. Please use only the test credit cards mentioned in the documentation. Also important to know is that only transactions under a amount of 10,000.00 € will be processed.
with_token = {
amount: 4200,
currency: "EUR",
token: "098f6bcd4621d373cade4e832627b4f6",
description: "Test Transaction"
}
Paymill::Transaction.create(with_token)
with_payment = {
amount: 4200,
currency: "EUR",
payment: "pay_2f82a672574647cd911d",
description: "Test Transaction"
}
Paymill::Transaction.create(with_payment)
with_client_and_payment = {
amount: 4200,
currency: "EUR",
client: "client_c781b1d2f7f0f664b4d9",
payment: "pay_a818b847db6ce5ff636f",
description: "Test Transaction"
}
Paymill::Transaction.create(with_client_and_payment)
with_preauthorization = {
amount: 4200,
currency: "EUR",
preauthorization: "preauth_ec54f67e52e92051bd65",
description: "Test Transaction"
}
Paymill::Transaction.create(with_preauthorization)
To receive the details of an existing transaction, call the unique transaction ID. You can find the ID in the response of the previous request. The return is a transaction object with the information of the used payment, client and transaction attributes.
Paymill::Transaction.find('tran_023d3b5769321c649435')
This function returns a JSON object with a list of transactions.
Paymill::Transactions.limit(10).offset(5).all
transaction = Paymill::Transactions.find('tran_023d3b5769321c649435')
transaction.refund!
When calling refund! without any argument the whole amount of the transaction is refunded.
You can pass the amount to refund and a description. Both are optional.
transaction.refund!(4200, 'Refund 42 EUR')