-
Notifications
You must be signed in to change notification settings - Fork 52
/
test_payment.rb
102 lines (93 loc) · 3.02 KB
/
test_payment.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# typed: true
# frozen_string_literal: true
require_relative '../lib/mercadopago'
require 'minitest/autorun'
class TestPayment < Minitest::Test
def test_method_search
sdk = Mercadopago::SDK.new('TEST-6130770563612470-121314-d27bbd7363e64c3853f058251cf8fc6e-537031659')
result = sdk.payment.search(filters: { id: 1_231_872_196 })
assert_equal 200, result[:status]
end
def test_method_get_id
sdk = Mercadopago::SDK.new('TEST-6130770563612470-121314-d27bbd7363e64c3853f058251cf8fc6e-537031659')
result = sdk.payment.get(1_231_872_196)
assert_equal 200, result[:status]
end
def test_method_post
sdk = Mercadopago::SDK.new('APP_USR-558881221729581-091712-44fdc612e60e3e638775d8b4003edd51-471763966')
card_token_object = {
card_number: '5031433215406351',
expiration_year: 2025,
expiration_month: 11,
security_code: '123',
cardholder: {
name: 'APRO'
}
}
result_card_token = sdk.card_token.create(card_token_object)
payment_object = {
token: result_card_token[:response]['id'],
installments: 1,
transaction_amount: 58.80,
description: 'Point Mini a maquininha que dá o dinheiro de suas vendas na hora',
payment_method_id: 'master',
payer: {
email: '[email protected]',
identification: {
number: '19119119100',
type: 'CPF'
}
},
notification_url: 'https://www.suaurl.com/notificacoes/',
binary_mode: false,
external_reference: 'MP0001',
statement_descriptor: 'MercadoPago',
additional_info: {
items: [
{
id: 'PR0001',
title: 'Point Mini',
description: 'Producto Point para cobros con tarjetas mediante bluetooth',
picture_url: 'https://http2.mlstatic.com/resources/frontend/statics/growth-sellers-landings/[email protected]',
category_id: 'electronics',
quantity: 1,
unit_price: 58.80
}
],
payer: {
first_name: 'Nome',
last_name: 'Sobrenome',
address: {
zip_code: '06233-200',
street_name: 'Av das Nacoes Unidas',
street_number: 3003
},
registration_date: '2019-01-01T12:01:01.000-03:00',
phone: {
area_code: '011',
number: '987654321'
}
},
shipments: {
receiver_address: {
street_name: 'Av das Nacoes Unidas',
street_number: 3003,
zip_code: '06233200',
city_name: 'Buzios',
state_name: 'Rio de Janeiro'
}
}
}
}
result = sdk.payment.create(payment_object)
assert_equal 201, result[:status]
end
def test_method_put
sdk = Mercadopago::SDK.new('TEST-6130770563612470-121314-d27bbd7363e64c3853f058251cf8fc6e-537031659')
data = {
status: 'approved'
}
result = sdk.payment.update(1_231_910_402, data)
assert_equal 403, result[:status]
end
end