From 0043f095656e1fdb4023a10d2a2f1b76ea76331b Mon Sep 17 00:00:00 2001 From: Yann IRBAH Date: Fri, 27 Feb 2015 20:00:35 +0100 Subject: [PATCH] Adds code samples for API Reference --- samples/authentication/authentication.rb | 1 + samples/clients/create_new_client.rb | 4 ++++ samples/clients/export_clients_list.rb | 1 + samples/clients/get_client_details.rb | 1 + samples/clients/list_clients.rb | 1 + samples/clients/remove_client.rb | 2 ++ samples/clients/update_client.rb | 4 ++++ samples/offers/create_new_offer.rb | 7 +++++++ samples/offers/export_offers_list.rb | 1 + samples/offers/get_offer_details.rb | 1 + samples/offers/list_offers.rb | 1 + samples/offers/remove_offer.rb | 7 +++++++ samples/offers/update_offer.rb | 8 ++++++++ ...eate_new_credit_card_payment_with_token.rb | 1 + ...edit_card_payment_with_token_and_client.rb | 4 ++++ .../create_new_debit_payment_with_token.rb | 1 + ...new_debit_payment_with_token_and_client.rb | 4 ++++ samples/payments/export_payments_list.rb | 1 + samples/payments/get_payment_details.rb | 1 + samples/payments/list_payments.rb | 1 + samples/payments/remove_payment.rb | 2 ++ ...reate_new_preauthorization_with_payment.rb | 8 ++++++++ .../create_new_preauthorization_with_token.rb | 6 ++++++ .../export_preauthorizations_list.rb | 1 + .../get_preauthorization_details.rb | 1 + .../list_preauthozizations.rb | 1 + .../remove_preauthorization.rb | 2 ++ samples/refunds/create_new_refund.rb | 11 +++++++++++ samples/refunds/export_refunds_list.rb | 1 + samples/refunds/get_refund_details.rb | 1 + samples/refunds/list_refunds.rb | 1 + samples/subscriptions/cancel_subscription.rb | 2 ++ .../create_new_subscription_with_an_offer.rb | 15 +++++++++++++++ ...tion_with_an_offer_and_different_values.rb | 19 +++++++++++++++++++ ...reate_new_subscription_without_an_offer.rb | 13 +++++++++++++ samples/subscriptions/delete_subscription.rb | 2 ++ .../export_subscriptions_list.rb | 1 + .../subscriptions/get_subscription_details.rb | 1 + samples/subscriptions/list_subscriptions.rb | 1 + samples/subscriptions/pause_subscription.rb | 7 +++++++ samples/subscriptions/update_subscription.rb | 12 ++++++++++++ .../update_subscription_amount.rb | 7 +++++++ .../update_subscription_offer.rb | 14 ++++++++++++++ .../create_new_transaction_with_app_fee.rb | 8 ++++++++ ...new_transaction_with_client_and_payment.rb | 12 ++++++++++++ .../create_new_transaction_with_payment.rb | 7 +++++++ ...e_new_transaction_with_preauthorization.rb | 10 ++++++++++ .../create_new_transaction_with_token.rb | 6 ++++++ .../transactions/export_transactions_list.rb | 1 + .../get_transaction_details_by_id.rb | 1 + .../get_transaction_details_by_slv.rb | 1 + samples/transactions/list_transactions.rb | 1 + samples/transactions/upate_transaction.rb | 3 +++ samples/webhooks/create_new_email_webhook.rb | 5 +++++ samples/webhooks/create_new_url_webhook.rb | 4 ++++ samples/webhooks/export_webhooks_list.rb | 1 + samples/webhooks/get_webhook_details.rb | 1 + samples/webhooks/remove_webhook.rb | 2 ++ samples/webhooks/update_webhook.rb | 3 +++ 59 files changed, 247 insertions(+) create mode 100644 samples/authentication/authentication.rb create mode 100644 samples/clients/create_new_client.rb create mode 100644 samples/clients/export_clients_list.rb create mode 100644 samples/clients/get_client_details.rb create mode 100644 samples/clients/list_clients.rb create mode 100644 samples/clients/remove_client.rb create mode 100644 samples/clients/update_client.rb create mode 100644 samples/offers/create_new_offer.rb create mode 100644 samples/offers/export_offers_list.rb create mode 100644 samples/offers/get_offer_details.rb create mode 100644 samples/offers/list_offers.rb create mode 100644 samples/offers/remove_offer.rb create mode 100644 samples/offers/update_offer.rb create mode 100644 samples/payments/create_new_credit_card_payment_with_token.rb create mode 100644 samples/payments/create_new_credit_card_payment_with_token_and_client.rb create mode 100644 samples/payments/create_new_debit_payment_with_token.rb create mode 100644 samples/payments/create_new_debit_payment_with_token_and_client.rb create mode 100644 samples/payments/export_payments_list.rb create mode 100644 samples/payments/get_payment_details.rb create mode 100644 samples/payments/list_payments.rb create mode 100644 samples/payments/remove_payment.rb create mode 100644 samples/preauthorizations/create_new_preauthorization_with_payment.rb create mode 100644 samples/preauthorizations/create_new_preauthorization_with_token.rb create mode 100644 samples/preauthorizations/export_preauthorizations_list.rb create mode 100644 samples/preauthorizations/get_preauthorization_details.rb create mode 100644 samples/preauthorizations/list_preauthozizations.rb create mode 100644 samples/preauthorizations/remove_preauthorization.rb create mode 100644 samples/refunds/create_new_refund.rb create mode 100644 samples/refunds/export_refunds_list.rb create mode 100644 samples/refunds/get_refund_details.rb create mode 100644 samples/refunds/list_refunds.rb create mode 100644 samples/subscriptions/cancel_subscription.rb create mode 100644 samples/subscriptions/create_new_subscription_with_an_offer.rb create mode 100644 samples/subscriptions/create_new_subscription_with_an_offer_and_different_values.rb create mode 100644 samples/subscriptions/create_new_subscription_without_an_offer.rb create mode 100644 samples/subscriptions/delete_subscription.rb create mode 100644 samples/subscriptions/export_subscriptions_list.rb create mode 100644 samples/subscriptions/get_subscription_details.rb create mode 100644 samples/subscriptions/list_subscriptions.rb create mode 100644 samples/subscriptions/pause_subscription.rb create mode 100644 samples/subscriptions/update_subscription.rb create mode 100644 samples/subscriptions/update_subscription_amount.rb create mode 100644 samples/subscriptions/update_subscription_offer.rb create mode 100644 samples/transactions/create_new_transaction_with_app_fee.rb create mode 100644 samples/transactions/create_new_transaction_with_client_and_payment.rb create mode 100644 samples/transactions/create_new_transaction_with_payment.rb create mode 100644 samples/transactions/create_new_transaction_with_preauthorization.rb create mode 100644 samples/transactions/create_new_transaction_with_token.rb create mode 100644 samples/transactions/export_transactions_list.rb create mode 100644 samples/transactions/get_transaction_details_by_id.rb create mode 100644 samples/transactions/get_transaction_details_by_slv.rb create mode 100644 samples/transactions/list_transactions.rb create mode 100644 samples/transactions/upate_transaction.rb create mode 100644 samples/webhooks/create_new_email_webhook.rb create mode 100644 samples/webhooks/create_new_url_webhook.rb create mode 100644 samples/webhooks/export_webhooks_list.rb create mode 100644 samples/webhooks/get_webhook_details.rb create mode 100644 samples/webhooks/remove_webhook.rb create mode 100644 samples/webhooks/update_webhook.rb diff --git a/samples/authentication/authentication.rb b/samples/authentication/authentication.rb new file mode 100644 index 0000000..38242b0 --- /dev/null +++ b/samples/authentication/authentication.rb @@ -0,0 +1 @@ +Paymill.api_key = "" diff --git a/samples/clients/create_new_client.rb b/samples/clients/create_new_client.rb new file mode 100644 index 0000000..9f4d35e --- /dev/null +++ b/samples/clients/create_new_client.rb @@ -0,0 +1,4 @@ +Paymill::Client.create( + email: 'lovely-client@example.com', + description: 'Lovely Client' +) diff --git a/samples/clients/export_clients_list.rb b/samples/clients/export_clients_list.rb new file mode 100644 index 0000000..a9d9f29 --- /dev/null +++ b/samples/clients/export_clients_list.rb @@ -0,0 +1 @@ +# Not implemented yet diff --git a/samples/clients/get_client_details.rb b/samples/clients/get_client_details.rb new file mode 100644 index 0000000..05c36a5 --- /dev/null +++ b/samples/clients/get_client_details.rb @@ -0,0 +1 @@ +Paymill::Client.find('client_88a388d9dd48f86c3136') diff --git a/samples/clients/list_clients.rb b/samples/clients/list_clients.rb new file mode 100644 index 0000000..0811574 --- /dev/null +++ b/samples/clients/list_clients.rb @@ -0,0 +1 @@ +Paymill::Client.all diff --git a/samples/clients/remove_client.rb b/samples/clients/remove_client.rb new file mode 100644 index 0000000..886d3ed --- /dev/null +++ b/samples/clients/remove_client.rb @@ -0,0 +1,2 @@ +client = Paymill::Client.find('client_88a388d9dd48f86c3136') +client.delete diff --git a/samples/clients/update_client.rb b/samples/clients/update_client.rb new file mode 100644 index 0000000..bc7e699 --- /dev/null +++ b/samples/clients/update_client.rb @@ -0,0 +1,4 @@ +client = Paymill::Client.find('client_88a388d9dd48f86c3136') +client.email = 'lovely-client@example.com' +client.description = 'My Lovely Client' +client.update diff --git a/samples/offers/create_new_offer.rb b/samples/offers/create_new_offer.rb new file mode 100644 index 0000000..87593ff --- /dev/null +++ b/samples/offers/create_new_offer.rb @@ -0,0 +1,7 @@ +Paymill::Offer.create( + amount: 4200, + currency: 'EUR', + interval: '1 MONTH', + name: 'Nerd Special', + trial_period_days: 0 +) diff --git a/samples/offers/export_offers_list.rb b/samples/offers/export_offers_list.rb new file mode 100644 index 0000000..a9d9f29 --- /dev/null +++ b/samples/offers/export_offers_list.rb @@ -0,0 +1 @@ +# Not implemented yet diff --git a/samples/offers/get_offer_details.rb b/samples/offers/get_offer_details.rb new file mode 100644 index 0000000..42bdc4a --- /dev/null +++ b/samples/offers/get_offer_details.rb @@ -0,0 +1 @@ +Paymill::Offer.find('offer_40237e20a7d5a231d99b') diff --git a/samples/offers/list_offers.rb b/samples/offers/list_offers.rb new file mode 100644 index 0000000..8c1c595 --- /dev/null +++ b/samples/offers/list_offers.rb @@ -0,0 +1 @@ +Paymill::Offer.all() diff --git a/samples/offers/remove_offer.rb b/samples/offers/remove_offer.rb new file mode 100644 index 0000000..9406a2d --- /dev/null +++ b/samples/offers/remove_offer.rb @@ -0,0 +1,7 @@ +# with subscriptions: +offer = Paymill::Offer.find('offer_40237e20a7d5a231d99b') +offer.delete_with_subscriptions() + +# without subscriptions: +offer = Paymill::Offer.find('offer_40237e20a7d5a231d99b') +offer.delete_without_subscriptions() diff --git a/samples/offers/update_offer.rb b/samples/offers/update_offer.rb new file mode 100644 index 0000000..d376bb6 --- /dev/null +++ b/samples/offers/update_offer.rb @@ -0,0 +1,8 @@ +offer = Paymill::Offer.find('offer_40237e20a7d5a231d99b') + +offer.name = 'Extended Special' +offer.interval = '1 MONTH' +offer.currency = 'USD' +offer.amount = '3333' + +offer.update( update_subscriptions: true ) diff --git a/samples/payments/create_new_credit_card_payment_with_token.rb b/samples/payments/create_new_credit_card_payment_with_token.rb new file mode 100644 index 0000000..b7781db --- /dev/null +++ b/samples/payments/create_new_credit_card_payment_with_token.rb @@ -0,0 +1 @@ +Paymill::Payment.create( token: '098f6bcd4621d373cade4e832627b4f6' ) diff --git a/samples/payments/create_new_credit_card_payment_with_token_and_client.rb b/samples/payments/create_new_credit_card_payment_with_token_and_client.rb new file mode 100644 index 0000000..5d7abeb --- /dev/null +++ b/samples/payments/create_new_credit_card_payment_with_token_and_client.rb @@ -0,0 +1,4 @@ +Paymill::Payment.create( + token: '098f6bcd4621d373cade4e832627b4f6', + client: 'client_88a388d9dd48f86c3136' +) diff --git a/samples/payments/create_new_debit_payment_with_token.rb b/samples/payments/create_new_debit_payment_with_token.rb new file mode 100644 index 0000000..6fd7ebf --- /dev/null +++ b/samples/payments/create_new_debit_payment_with_token.rb @@ -0,0 +1 @@ +Paymill::Payment.create( token: '12a46bcd462sd3r3care4e8336ssb4f5' ) diff --git a/samples/payments/create_new_debit_payment_with_token_and_client.rb b/samples/payments/create_new_debit_payment_with_token_and_client.rb new file mode 100644 index 0000000..f37c310 --- /dev/null +++ b/samples/payments/create_new_debit_payment_with_token_and_client.rb @@ -0,0 +1,4 @@ +Paymill::Payment.create( + token: '12a46bcd462sd3r3care4e8336ssb4f5', + client: 'client_88a388d9dd48f86c3136' +) diff --git a/samples/payments/export_payments_list.rb b/samples/payments/export_payments_list.rb new file mode 100644 index 0000000..d1069c3 --- /dev/null +++ b/samples/payments/export_payments_list.rb @@ -0,0 +1 @@ +# Not yet implemented diff --git a/samples/payments/get_payment_details.rb b/samples/payments/get_payment_details.rb new file mode 100644 index 0000000..82decbc --- /dev/null +++ b/samples/payments/get_payment_details.rb @@ -0,0 +1 @@ +Paymill::Payment.find( 'pay_3af44644dd6d25c820a8' ) diff --git a/samples/payments/list_payments.rb b/samples/payments/list_payments.rb new file mode 100644 index 0000000..c97a7a7 --- /dev/null +++ b/samples/payments/list_payments.rb @@ -0,0 +1 @@ +Paymill::Payment.all diff --git a/samples/payments/remove_payment.rb b/samples/payments/remove_payment.rb new file mode 100644 index 0000000..6907a54 --- /dev/null +++ b/samples/payments/remove_payment.rb @@ -0,0 +1,2 @@ +payment = Paymill::Payment.find( 'pay_ea98515b29437b046207ea45' ) +payment.delete diff --git a/samples/preauthorizations/create_new_preauthorization_with_payment.rb b/samples/preauthorizations/create_new_preauthorization_with_payment.rb new file mode 100644 index 0000000..01a7c79 --- /dev/null +++ b/samples/preauthorizations/create_new_preauthorization_with_payment.rb @@ -0,0 +1,8 @@ +payment = Paymill::Payment.create(token: '098f6bcd4621d373cade4e832627b4f6') + +Paymill::Preauthorization.create( + payment: payment.id, + amount: 4200, + currency: 'EUR', + description: 'description example' +) diff --git a/samples/preauthorizations/create_new_preauthorization_with_token.rb b/samples/preauthorizations/create_new_preauthorization_with_token.rb new file mode 100644 index 0000000..0e8ea48 --- /dev/null +++ b/samples/preauthorizations/create_new_preauthorization_with_token.rb @@ -0,0 +1,6 @@ +Paymill::Preauthorization.create( + token: '098f6bcd4621d373cade4e832627b4f6', + amount: 4200, + currency: 'EUR', + description: 'description example' +) diff --git a/samples/preauthorizations/export_preauthorizations_list.rb b/samples/preauthorizations/export_preauthorizations_list.rb new file mode 100644 index 0000000..a9d9f29 --- /dev/null +++ b/samples/preauthorizations/export_preauthorizations_list.rb @@ -0,0 +1 @@ +# Not implemented yet diff --git a/samples/preauthorizations/get_preauthorization_details.rb b/samples/preauthorizations/get_preauthorization_details.rb new file mode 100644 index 0000000..2b35e9c --- /dev/null +++ b/samples/preauthorizations/get_preauthorization_details.rb @@ -0,0 +1 @@ +Paymill::Preauthorization.find('preauth_31eb90495837447f76b7') diff --git a/samples/preauthorizations/list_preauthozizations.rb b/samples/preauthorizations/list_preauthozizations.rb new file mode 100644 index 0000000..f91e297 --- /dev/null +++ b/samples/preauthorizations/list_preauthozizations.rb @@ -0,0 +1 @@ +Paymill::Preauthorization.all() diff --git a/samples/preauthorizations/remove_preauthorization.rb b/samples/preauthorizations/remove_preauthorization.rb new file mode 100644 index 0000000..7e5f231 --- /dev/null +++ b/samples/preauthorizations/remove_preauthorization.rb @@ -0,0 +1,2 @@ +preauthorization = Paymill::Preauthorization.find('preauth_31eb90495837447f76b7') +preauthorization.delete diff --git a/samples/refunds/create_new_refund.rb b/samples/refunds/create_new_refund.rb new file mode 100644 index 0000000..9aa4921 --- /dev/null +++ b/samples/refunds/create_new_refund.rb @@ -0,0 +1,11 @@ +transaction = Paymill::Transaction.create( + token: '098f6bcd4621d373cade4e832627b4f6', + amount: 4200, + currency: 'USD' +) + +Paymill::Refund.create( + transaction, + amount: 4200, + description: 'Sample Description' +) diff --git a/samples/refunds/export_refunds_list.rb b/samples/refunds/export_refunds_list.rb new file mode 100644 index 0000000..a9d9f29 --- /dev/null +++ b/samples/refunds/export_refunds_list.rb @@ -0,0 +1 @@ +# Not implemented yet diff --git a/samples/refunds/get_refund_details.rb b/samples/refunds/get_refund_details.rb new file mode 100644 index 0000000..6a0ed38 --- /dev/null +++ b/samples/refunds/get_refund_details.rb @@ -0,0 +1 @@ +Paymill::Refund.find('refund_87bc404a95d5ce616049') diff --git a/samples/refunds/list_refunds.rb b/samples/refunds/list_refunds.rb new file mode 100644 index 0000000..8cddf70 --- /dev/null +++ b/samples/refunds/list_refunds.rb @@ -0,0 +1 @@ +Paymill::Refund.all() diff --git a/samples/subscriptions/cancel_subscription.rb b/samples/subscriptions/cancel_subscription.rb new file mode 100644 index 0000000..646ab91 --- /dev/null +++ b/samples/subscriptions/cancel_subscription.rb @@ -0,0 +1,2 @@ +subscription = Paymill::Subscription.find('sub_dea86e5c65b2087202e3') +subscription.cancel() diff --git a/samples/subscriptions/create_new_subscription_with_an_offer.rb b/samples/subscriptions/create_new_subscription_with_an_offer.rb new file mode 100644 index 0000000..4c194e5 --- /dev/null +++ b/samples/subscriptions/create_new_subscription_with_an_offer.rb @@ -0,0 +1,15 @@ +payment = Paymill::Payment.create(token: '098f6bcd4621d373cade4e832627b4f6') +offer = Paymill::Offer.create( + amount: 3333, + currency: 'EUR', + interval: '1 WEEK', + name: 'Nerd Special', + trial_period_days: 30 + ) + +Paymill::Subscription.create( + payment: payment, + offer: offer, + period_of_validity: '2 YEAR', + start_at: 2.days.from_now +) diff --git a/samples/subscriptions/create_new_subscription_with_an_offer_and_different_values.rb b/samples/subscriptions/create_new_subscription_with_an_offer_and_different_values.rb new file mode 100644 index 0000000..4d69ae1 --- /dev/null +++ b/samples/subscriptions/create_new_subscription_with_an_offer_and_different_values.rb @@ -0,0 +1,19 @@ +payment = Paymill::Payment.create(token: '098f6bcd4621d373cade4e832627b4f6') +offer = Paymill::Offer.create( + amount: 4200, + currency: 'EUR', + interval: '1 MONTH', + name: 'Nerd Special', + trial_period_days: 30 +) + +Paymill::Subscription.create( + payment: payment, + offer: offer, + amount: 3000, + currency: 'EUR', + interval: '1 week, monday', + name: 'Example Subscription', + period_of_validity: '2 YEAR', + start_at: 2.days.from_now +) diff --git a/samples/subscriptions/create_new_subscription_without_an_offer.rb b/samples/subscriptions/create_new_subscription_without_an_offer.rb new file mode 100644 index 0000000..4ca1bdb --- /dev/null +++ b/samples/subscriptions/create_new_subscription_without_an_offer.rb @@ -0,0 +1,13 @@ +client = Paymill::Client.create(email: 'client@example.com') +payment = Paymill::Payment.create(token: '098f6bcd4621d373cade4e832627b4f6', client: client) + +Paymill::Subscription.create( + payment: payment, + client: client, + name: 'Example Subscription', + amount: 3000, + currency: 'EUR', + interval: '1 week,monday', + period_of_validity: '2 YEAR', + start_at: 2.days.from_now +) diff --git a/samples/subscriptions/delete_subscription.rb b/samples/subscriptions/delete_subscription.rb new file mode 100644 index 0000000..0d34fc5 --- /dev/null +++ b/samples/subscriptions/delete_subscription.rb @@ -0,0 +1,2 @@ +subscription = Paymill::Subscription.find('sub_dea86e5c65b2087202e3') +subscription.remove() diff --git a/samples/subscriptions/export_subscriptions_list.rb b/samples/subscriptions/export_subscriptions_list.rb new file mode 100644 index 0000000..a9d9f29 --- /dev/null +++ b/samples/subscriptions/export_subscriptions_list.rb @@ -0,0 +1 @@ +# Not implemented yet diff --git a/samples/subscriptions/get_subscription_details.rb b/samples/subscriptions/get_subscription_details.rb new file mode 100644 index 0000000..cfe862d --- /dev/null +++ b/samples/subscriptions/get_subscription_details.rb @@ -0,0 +1 @@ +Paymill::Subscription.find("sub_dc180b755d10da324864") diff --git a/samples/subscriptions/list_subscriptions.rb b/samples/subscriptions/list_subscriptions.rb new file mode 100644 index 0000000..81ea38f --- /dev/null +++ b/samples/subscriptions/list_subscriptions.rb @@ -0,0 +1 @@ +Paymill::Subscription.all() diff --git a/samples/subscriptions/pause_subscription.rb b/samples/subscriptions/pause_subscription.rb new file mode 100644 index 0000000..c1a4e6c --- /dev/null +++ b/samples/subscriptions/pause_subscription.rb @@ -0,0 +1,7 @@ +#pause: +subscription = Paymill::Subscription.find('sub_dea86e5c65b2087202e3') +subscription.pause + +#play: +subscription = Paymill::Subscription.find('sub_dea86e5c65b2087202e3') +subscription.play diff --git a/samples/subscriptions/update_subscription.rb b/samples/subscriptions/update_subscription.rb new file mode 100644 index 0000000..8d6ce0f --- /dev/null +++ b/samples/subscriptions/update_subscription.rb @@ -0,0 +1,12 @@ +subscription = Paymill::Subscription.find('sub_dea86e5c65b2087202e3') +subscription.payment = 'pay_95ba26ba2c613ebb0ca8' +subscription.currency = 'USD' +subscription.interval = '1 month,friday' +subscription.name = 'Changed Subscription' +subscription.trial_end = false +subscription.update + +# for limit / unlimit use +subscription = Paymill::Subscription.find('sub_dea86e5c65b2087202e3') +subscription.unlimit +subscription.limit('12 MONTH') diff --git a/samples/subscriptions/update_subscription_amount.rb b/samples/subscriptions/update_subscription_amount.rb new file mode 100644 index 0000000..3b7a39e --- /dev/null +++ b/samples/subscriptions/update_subscription_amount.rb @@ -0,0 +1,7 @@ +#amount temporary: +subscription = Paymill::Subscription.find('sub_dea86e5c65b2087202e3') +subscription.update_amount_once(1234) + +#amount permanently: +subscription = Paymill::Subscription.find('sub_dea86e5c65b2087202e3') +subscription.update_amount_permanently(1234) diff --git a/samples/subscriptions/update_subscription_offer.rb b/samples/subscriptions/update_subscription_offer.rb new file mode 100644 index 0000000..15077b8 --- /dev/null +++ b/samples/subscriptions/update_subscription_offer.rb @@ -0,0 +1,14 @@ +#offer with no refund and unchanged capture date: +subscription = Paymill::Subscription.find('sub_dea86e5c65b2087202e3') +offer = Offer.create(name: 'Foo', amount: 4990, currency: 'EUR', interval: '2 WEEK') +subscription.update_offer_without_changes(offer) + +#offer with refund and unchanged capture date: +subscription = Paymill::Subscription.find('sub_dea86e5c65b2087202e3') +offer = Offer.create(name: 'Foo', amount: 4990, currency: 'EUR', interval: '2 WEEK') +subscription.update_offer_with_refund(offer) + +#offer with refund and capture date: +subscription = Paymill::Subscription.find('sub_dea86e5c65b2087202e3') +offer = Offer.create(name: 'Foo', amount: 4990, currency: 'EUR', interval: '2 WEEK') +subscription.update_offer_with_refund_and_capture_date(offer) diff --git a/samples/transactions/create_new_transaction_with_app_fee.rb b/samples/transactions/create_new_transaction_with_app_fee.rb new file mode 100644 index 0000000..a6acd25 --- /dev/null +++ b/samples/transactions/create_new_transaction_with_app_fee.rb @@ -0,0 +1,8 @@ +Paymill::Transaction.create( + token: '098f6bcd4621d373cade4e832627b4f6', + amount: 4200, currency: 'EUR', + description: 'Test Transaction', + fee_amount: 4200, + fee_payment: 'pay_a818b847db6ce5ff636f', + fee_currency: 'EUR' +) diff --git a/samples/transactions/create_new_transaction_with_client_and_payment.rb b/samples/transactions/create_new_transaction_with_client_and_payment.rb new file mode 100644 index 0000000..3d91555 --- /dev/null +++ b/samples/transactions/create_new_transaction_with_client_and_payment.rb @@ -0,0 +1,12 @@ +client = Paymill::Client.create(email: 'mail@example.com') +payment = Paymill::Payment.create( + token: '098f6bcd4621d373cade4e832627b4f6', + client: client +) + +Paymill::Transaction.create( + payment: payment, + client: client, + amount: 4200, + currency: 'EUR' +) diff --git a/samples/transactions/create_new_transaction_with_payment.rb b/samples/transactions/create_new_transaction_with_payment.rb new file mode 100644 index 0000000..7dec3a0 --- /dev/null +++ b/samples/transactions/create_new_transaction_with_payment.rb @@ -0,0 +1,7 @@ +payment = Paymill::Payment.create(token: '098f6bcd4621d373cade4e832627b4f6') +transaction = Paymill::Transaction.create( + payment: payment, + amount: 4200, + currency: 'EUR', + description: 'Test Transaction' +) diff --git a/samples/transactions/create_new_transaction_with_preauthorization.rb b/samples/transactions/create_new_transaction_with_preauthorization.rb new file mode 100644 index 0000000..a2606cc --- /dev/null +++ b/samples/transactions/create_new_transaction_with_preauthorization.rb @@ -0,0 +1,10 @@ +preauthorization = Paymill::Preauthorization.create( + token: '098f6bcd4621d373cade4e832627b4f6', + amount: 4200, + currency: 'EUR' +) +transaction = Transaction.create( + preauthorization: preauthorization, + amount: 4200, + currency: 'EUR' +) diff --git a/samples/transactions/create_new_transaction_with_token.rb b/samples/transactions/create_new_transaction_with_token.rb new file mode 100644 index 0000000..5d224f5 --- /dev/null +++ b/samples/transactions/create_new_transaction_with_token.rb @@ -0,0 +1,6 @@ +Paymill::Transaction.create( + token: '098f6bcd4621d373cade4e832627b4f6', + amount: 4200, + currency: 'EUR', + description: 'Test Transaction' +) diff --git a/samples/transactions/export_transactions_list.rb b/samples/transactions/export_transactions_list.rb new file mode 100644 index 0000000..a9d9f29 --- /dev/null +++ b/samples/transactions/export_transactions_list.rb @@ -0,0 +1 @@ +# Not implemented yet diff --git a/samples/transactions/get_transaction_details_by_id.rb b/samples/transactions/get_transaction_details_by_id.rb new file mode 100644 index 0000000..840b070 --- /dev/null +++ b/samples/transactions/get_transaction_details_by_id.rb @@ -0,0 +1 @@ +Paymill::Transaction.find('tran_023d3b5769321c649435') diff --git a/samples/transactions/get_transaction_details_by_slv.rb b/samples/transactions/get_transaction_details_by_slv.rb new file mode 100644 index 0000000..840b070 --- /dev/null +++ b/samples/transactions/get_transaction_details_by_slv.rb @@ -0,0 +1 @@ +Paymill::Transaction.find('tran_023d3b5769321c649435') diff --git a/samples/transactions/list_transactions.rb b/samples/transactions/list_transactions.rb new file mode 100644 index 0000000..f49ada5 --- /dev/null +++ b/samples/transactions/list_transactions.rb @@ -0,0 +1 @@ +Paymill::Transaction.all() diff --git a/samples/transactions/upate_transaction.rb b/samples/transactions/upate_transaction.rb new file mode 100644 index 0000000..872512d --- /dev/null +++ b/samples/transactions/upate_transaction.rb @@ -0,0 +1,3 @@ +transaction = Paymill::Transaction.find('tran_023d3b5769321c649435') +transaction.description = 'My updated transaction description' +transaction.update diff --git a/samples/webhooks/create_new_email_webhook.rb b/samples/webhooks/create_new_email_webhook.rb new file mode 100644 index 0000000..293029a --- /dev/null +++ b/samples/webhooks/create_new_email_webhook.rb @@ -0,0 +1,5 @@ +Paymill::Webhook.create( + email: 'webhook@example.com', + event_types: ['transaction.succeeded', 'transaction.failed'], + active: false +) diff --git a/samples/webhooks/create_new_url_webhook.rb b/samples/webhooks/create_new_url_webhook.rb new file mode 100644 index 0000000..8b517e1 --- /dev/null +++ b/samples/webhooks/create_new_url_webhook.rb @@ -0,0 +1,4 @@ +Paymill::Webhook.create( + url: 'http://example.com', + event_types: ['transaction.succeeded', 'transaction.failed'] +) diff --git a/samples/webhooks/export_webhooks_list.rb b/samples/webhooks/export_webhooks_list.rb new file mode 100644 index 0000000..a9d9f29 --- /dev/null +++ b/samples/webhooks/export_webhooks_list.rb @@ -0,0 +1 @@ +# Not implemented yet diff --git a/samples/webhooks/get_webhook_details.rb b/samples/webhooks/get_webhook_details.rb new file mode 100644 index 0000000..3b0358f --- /dev/null +++ b/samples/webhooks/get_webhook_details.rb @@ -0,0 +1 @@ +Paymill::Webhook.find('hook_40237e20a7d5a231d99b') diff --git a/samples/webhooks/remove_webhook.rb b/samples/webhooks/remove_webhook.rb new file mode 100644 index 0000000..532a85c --- /dev/null +++ b/samples/webhooks/remove_webhook.rb @@ -0,0 +1,2 @@ +webhook = Paymill::Webhook.find(active_webhook_id) +webhook.delete() diff --git a/samples/webhooks/update_webhook.rb b/samples/webhooks/update_webhook.rb new file mode 100644 index 0000000..bc10590 --- /dev/null +++ b/samples/webhooks/update_webhook.rb @@ -0,0 +1,3 @@ +webhook = Paymill::Webhook.find(active_webhook_id) +webhook.email = 'mail@example.com' +webhook.update()