fawry 0.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +57 -0
- data/.github/workflows/ruby.yml +35 -0
- data/.rubocop.yml +6 -3
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +64 -44
- data/README-ar.md +181 -0
- data/README.md +105 -18
- data/Rakefile +18 -1
- data/fawry.gemspec +8 -6
- data/lib/fawry.rb +130 -9
- data/lib/fawry/config.rb +17 -0
- data/lib/fawry/connection.rb +22 -6
- data/lib/fawry/contracts/charge_request_contract.rb +16 -2
- data/lib/fawry/contracts/create_card_token_request_contract.rb +33 -0
- data/lib/fawry/contracts/delete_token_request_contract.rb +30 -0
- data/lib/fawry/contracts/list_tokens_request_contract.rb +29 -0
- data/lib/fawry/contracts/payment_status_request_contract.rb +16 -2
- data/lib/fawry/contracts/refund_request_contract.rb +16 -2
- data/lib/fawry/errors.rb +3 -1
- data/lib/fawry/fawry_callback.rb +56 -0
- data/lib/fawry/fawry_request.rb +14 -0
- data/lib/fawry/fawry_response.rb +3 -7
- data/lib/fawry/requests/charge_request.rb +13 -7
- data/lib/fawry/requests/create_card_token_request.rb +57 -0
- data/lib/fawry/requests/delete_token_request.rb +62 -0
- data/lib/fawry/requests/list_tokens_request.rb +57 -0
- data/lib/fawry/requests/payment_status_request.rb +13 -5
- data/lib/fawry/requests/refund_request.rb +13 -5
- data/lib/fawry/utils.rb +31 -0
- data/lib/fawry/version.rb +1 -1
- metadata +54 -26
- data/.travis.yml +0 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5015952a24c3ab03377aae7d4d17abccbb7800c00c5ed6a02b4becabe5aa42a6
|
|
4
|
+
data.tar.gz: 337289fe3666ac8fd7f7ff9886d5a6d5e33ebc542000c624771f338278160634
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 53a9057c10dda83db87042cce4dae0d7d76155c3bcffaeb5369403517d33613b10fb3d7a057db7cd39f368a2f4b3988ca06277db9de1e6ac9ab5c7d636ae026c
|
|
7
|
+
data.tar.gz: 8fb2747e2050270ea3514b6c7967e60d41268f2469bf6060188c532d4a2688387edcbaea741d567321b107ebb876adac7f7c79ec3375eeca91c9c007e6c6127a
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
jobs:
|
|
3
|
+
build:
|
|
4
|
+
docker:
|
|
5
|
+
- image: circleci/ruby:2.6.0
|
|
6
|
+
|
|
7
|
+
working_directory: ~/repo
|
|
8
|
+
|
|
9
|
+
steps:
|
|
10
|
+
- checkout
|
|
11
|
+
|
|
12
|
+
# Download and cache dependencies
|
|
13
|
+
- restore_cache:
|
|
14
|
+
keys:
|
|
15
|
+
- v1-dependencies-{{ checksum "Gemfile.lock" }}
|
|
16
|
+
# fallback to using the latest cache if no exact match is found
|
|
17
|
+
- v1-dependencies-
|
|
18
|
+
|
|
19
|
+
- run:
|
|
20
|
+
name: install bundler
|
|
21
|
+
command: gem install bundler
|
|
22
|
+
|
|
23
|
+
- run:
|
|
24
|
+
name: install dependencies
|
|
25
|
+
command: |
|
|
26
|
+
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
|
27
|
+
|
|
28
|
+
- save_cache:
|
|
29
|
+
paths:
|
|
30
|
+
- ./vendor/bundle
|
|
31
|
+
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
|
|
32
|
+
|
|
33
|
+
# run tests!
|
|
34
|
+
- run:
|
|
35
|
+
name: run tests
|
|
36
|
+
command: |
|
|
37
|
+
mkdir /tmp/test-results
|
|
38
|
+
TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | \
|
|
39
|
+
circleci tests split --split-by=timings)"
|
|
40
|
+
|
|
41
|
+
bundle exec rspec \
|
|
42
|
+
--format progress \
|
|
43
|
+
--format RspecJunitFormatter \
|
|
44
|
+
--out /tmp/test-results/rspec.xml \
|
|
45
|
+
--format progress \
|
|
46
|
+
$TEST_FILES
|
|
47
|
+
|
|
48
|
+
- run:
|
|
49
|
+
name: run rubocop
|
|
50
|
+
command: bundle exec rubocop
|
|
51
|
+
|
|
52
|
+
# collect reports
|
|
53
|
+
- store_test_results:
|
|
54
|
+
path: /tmp/test-results
|
|
55
|
+
- store_artifacts:
|
|
56
|
+
path: /tmp/test-results
|
|
57
|
+
destination: test-results
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
|
2
|
+
# They are provided by a third-party and are governed by
|
|
3
|
+
# separate terms of service, privacy policy, and support
|
|
4
|
+
# documentation.
|
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
|
7
|
+
|
|
8
|
+
name: Ruby
|
|
9
|
+
|
|
10
|
+
on:
|
|
11
|
+
push:
|
|
12
|
+
branches: [ master ]
|
|
13
|
+
pull_request:
|
|
14
|
+
branches: [ master ]
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
test:
|
|
18
|
+
|
|
19
|
+
runs-on: ubuntu-latest
|
|
20
|
+
strategy:
|
|
21
|
+
matrix:
|
|
22
|
+
ruby-version: ['2.6', '2.7', '3.0']
|
|
23
|
+
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@v2
|
|
26
|
+
- name: Set up Ruby
|
|
27
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
|
28
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
|
29
|
+
# uses: ruby/setup-ruby@v1
|
|
30
|
+
uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
|
|
31
|
+
with:
|
|
32
|
+
ruby-version: ${{ matrix.ruby-version }}
|
|
33
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
|
34
|
+
- name: Run tests
|
|
35
|
+
run: bundle exec rake
|
data/.rubocop.yml
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
AllCops:
|
|
2
|
+
NewCops: enable
|
|
3
|
+
TargetRubyVersion: 2.6
|
|
4
|
+
Layout/LineLength:
|
|
2
5
|
Max: 120
|
|
3
6
|
Metrics/BlockLength:
|
|
4
|
-
|
|
7
|
+
IgnoredMethods: ['describe', 'context']
|
|
5
8
|
Style/Documentation:
|
|
6
|
-
Enabled: false
|
|
9
|
+
Enabled: false
|
data/CHANGELOG.md
ADDED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
fawry (
|
|
4
|
+
fawry (1.3.0)
|
|
5
5
|
dry-validation (~> 1.3, >= 1.3.1)
|
|
6
6
|
faraday (~> 0.17.0)
|
|
7
7
|
|
|
@@ -10,69 +10,87 @@ GEM
|
|
|
10
10
|
specs:
|
|
11
11
|
addressable (2.7.0)
|
|
12
12
|
public_suffix (>= 2.0.2, < 5.0)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
ast (2.4.2)
|
|
14
|
+
byebug (11.1.3)
|
|
15
|
+
concurrent-ruby (1.1.8)
|
|
16
|
+
crack (0.4.5)
|
|
17
|
+
rexml
|
|
18
|
+
diff-lcs (1.4.4)
|
|
19
|
+
dry-configurable (0.12.1)
|
|
19
20
|
concurrent-ruby (~> 1.0)
|
|
20
|
-
dry-core (~> 0.
|
|
21
|
+
dry-core (~> 0.5, >= 0.5.0)
|
|
21
22
|
dry-container (0.7.2)
|
|
22
23
|
concurrent-ruby (~> 1.0)
|
|
23
24
|
dry-configurable (~> 0.1, >= 0.1.3)
|
|
24
|
-
dry-core (0.
|
|
25
|
+
dry-core (0.5.0)
|
|
25
26
|
concurrent-ruby (~> 1.0)
|
|
26
|
-
dry-equalizer (0.
|
|
27
|
+
dry-equalizer (0.3.0)
|
|
27
28
|
dry-inflector (0.2.0)
|
|
28
|
-
dry-initializer (3.0.
|
|
29
|
-
dry-logic (1.0
|
|
29
|
+
dry-initializer (3.0.4)
|
|
30
|
+
dry-logic (1.2.0)
|
|
30
31
|
concurrent-ruby (~> 1.0)
|
|
31
|
-
dry-core (~> 0.
|
|
32
|
-
|
|
33
|
-
dry-schema (1.4.1)
|
|
32
|
+
dry-core (~> 0.5, >= 0.5)
|
|
33
|
+
dry-schema (1.6.2)
|
|
34
34
|
concurrent-ruby (~> 1.0)
|
|
35
35
|
dry-configurable (~> 0.8, >= 0.8.3)
|
|
36
|
-
dry-core (~> 0.
|
|
37
|
-
dry-equalizer (~> 0.2)
|
|
36
|
+
dry-core (~> 0.5, >= 0.5)
|
|
38
37
|
dry-initializer (~> 3.0)
|
|
39
38
|
dry-logic (~> 1.0)
|
|
40
|
-
dry-types (~> 1.
|
|
41
|
-
dry-types (1.
|
|
39
|
+
dry-types (~> 1.5)
|
|
40
|
+
dry-types (1.5.1)
|
|
42
41
|
concurrent-ruby (~> 1.0)
|
|
43
42
|
dry-container (~> 0.3)
|
|
44
|
-
dry-core (~> 0.
|
|
45
|
-
dry-equalizer (~> 0.2, >= 0.2.2)
|
|
43
|
+
dry-core (~> 0.5, >= 0.5)
|
|
46
44
|
dry-inflector (~> 0.1, >= 0.1.2)
|
|
47
45
|
dry-logic (~> 1.0, >= 1.0.2)
|
|
48
|
-
dry-validation (1.
|
|
46
|
+
dry-validation (1.6.0)
|
|
49
47
|
concurrent-ruby (~> 1.0)
|
|
50
48
|
dry-container (~> 0.7, >= 0.7.1)
|
|
51
49
|
dry-core (~> 0.4)
|
|
52
50
|
dry-equalizer (~> 0.2)
|
|
53
51
|
dry-initializer (~> 3.0)
|
|
54
|
-
dry-schema (~> 1.
|
|
55
|
-
faraday (0.17.
|
|
52
|
+
dry-schema (~> 1.5, >= 1.5.2)
|
|
53
|
+
faraday (0.17.4)
|
|
56
54
|
multipart-post (>= 1.2, < 3)
|
|
57
|
-
hashdiff (1.0.
|
|
55
|
+
hashdiff (1.0.1)
|
|
58
56
|
multipart-post (2.1.1)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
rspec
|
|
57
|
+
parallel (1.20.1)
|
|
58
|
+
parser (3.0.1.1)
|
|
59
|
+
ast (~> 2.4.1)
|
|
60
|
+
public_suffix (4.0.6)
|
|
61
|
+
rainbow (3.0.0)
|
|
62
|
+
rake (13.0.3)
|
|
63
|
+
regexp_parser (2.1.1)
|
|
64
|
+
rexml (3.2.5)
|
|
65
|
+
rspec (3.10.0)
|
|
66
|
+
rspec-core (~> 3.10.0)
|
|
67
|
+
rspec-expectations (~> 3.10.0)
|
|
68
|
+
rspec-mocks (~> 3.10.0)
|
|
69
|
+
rspec-core (3.10.1)
|
|
70
|
+
rspec-support (~> 3.10.0)
|
|
71
|
+
rspec-expectations (3.10.1)
|
|
68
72
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
69
|
-
rspec-support (~> 3.
|
|
70
|
-
rspec-mocks (3.
|
|
73
|
+
rspec-support (~> 3.10.0)
|
|
74
|
+
rspec-mocks (3.10.2)
|
|
71
75
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
72
|
-
rspec-support (~> 3.
|
|
73
|
-
rspec-support (3.
|
|
74
|
-
|
|
75
|
-
|
|
76
|
+
rspec-support (~> 3.10.0)
|
|
77
|
+
rspec-support (3.10.2)
|
|
78
|
+
rspec_junit_formatter (0.4.1)
|
|
79
|
+
rspec-core (>= 2, < 4, != 2.12.0)
|
|
80
|
+
rubocop (1.13.0)
|
|
81
|
+
parallel (~> 1.10)
|
|
82
|
+
parser (>= 3.0.0.0)
|
|
83
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
84
|
+
regexp_parser (>= 1.8, < 3.0)
|
|
85
|
+
rexml
|
|
86
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
|
87
|
+
ruby-progressbar (~> 1.7)
|
|
88
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
|
89
|
+
rubocop-ast (1.5.0)
|
|
90
|
+
parser (>= 3.0.1.1)
|
|
91
|
+
ruby-progressbar (1.11.0)
|
|
92
|
+
unicode-display_width (2.0.0)
|
|
93
|
+
webmock (3.12.2)
|
|
76
94
|
addressable (>= 2.3.6)
|
|
77
95
|
crack (>= 0.3.2)
|
|
78
96
|
hashdiff (>= 0.4.0, < 2.0.0)
|
|
@@ -82,11 +100,13 @@ PLATFORMS
|
|
|
82
100
|
|
|
83
101
|
DEPENDENCIES
|
|
84
102
|
bundler (~> 2.0)
|
|
85
|
-
byebug (~> 11.0
|
|
103
|
+
byebug (~> 11.0)
|
|
86
104
|
fawry!
|
|
87
|
-
rake (~>
|
|
105
|
+
rake (~> 13.0)
|
|
88
106
|
rspec (~> 3.0)
|
|
89
|
-
|
|
107
|
+
rspec_junit_formatter
|
|
108
|
+
rubocop (~> 1.11)
|
|
109
|
+
webmock (~> 3.12)
|
|
90
110
|
|
|
91
111
|
BUNDLED WITH
|
|
92
|
-
2.
|
|
112
|
+
2.2.3
|
data/README-ar.md
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
[](https://circleci.com/gh/fawry-api/fawry)
|
|
2
|
+
|
|
3
|
+
# Fawry
|
|
4
|
+
|
|
5
|
+
**تنويه:** نحن لسنا تابعين رسميًا لشركة فوري.
|
|
6
|
+
|
|
7
|
+
مكتبة لتسهيل التعامل مع خدمات الدفع الخاصة بشبكة الدفع الإلكتروني فوري:
|
|
8
|
+
|
|
9
|
+
_المكتبة تدعم النظام التجريبي لفوري ايضا_
|
|
10
|
+
|
|
11
|
+
## لإضافة وتشغيل المكتبة
|
|
12
|
+
|
|
13
|
+
أضف هذا السطر إلى ملف Gemfile الخاص بتطبيقك:
|
|
14
|
+
|
|
15
|
+
```ruby
|
|
16
|
+
gem 'fawry'
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
ثم نفذ:
|
|
20
|
+
|
|
21
|
+
$ bundle
|
|
22
|
+
|
|
23
|
+
أو قم بتثبيته بنفسك على النحو التالي:
|
|
24
|
+
|
|
25
|
+
$ gem install fawry
|
|
26
|
+
|
|
27
|
+
## تهيئة فوري للاستخدام
|
|
28
|
+
|
|
29
|
+
لبرنامجك لتهيئة المكتبة `fawry.rb` أضف مهيئ
|
|
30
|
+
```ruby
|
|
31
|
+
Fawry.configure do |config|
|
|
32
|
+
config.sandbox = Rails.env.staging? ? true : false
|
|
33
|
+
config.fawry_secure_key = 'fawry_secure_key'
|
|
34
|
+
config.fawry_merchant_code = 'fawry_merchant_code'
|
|
35
|
+
end
|
|
36
|
+
```
|
|
37
|
+
`FAWRY_SANDBOX`, `FAWRY_SECURE_KEY`, `FAWRY_MERCHANT_CODE` _(environment variables)_ او يمكنك بدلا من ذلك، استخدام المتغيرات البيئية
|
|
38
|
+
|
|
39
|
+
## طريقة الإستعمال
|
|
40
|
+
|
|
41
|
+
### لإجراء عملية دفع
|
|
42
|
+
|
|
43
|
+
```ruby
|
|
44
|
+
params = { "merchant_code": 'merchant_code',
|
|
45
|
+
"merchant_ref_num": 'io5jxf3jp27kfh8m719arcqgw7izo7db',
|
|
46
|
+
"customer_profile_id": 'ocvsydvbu2gcp528wvl64i9z5srdalg5',
|
|
47
|
+
"customer_mobile": '012345678901',
|
|
48
|
+
"payment_method": 'PAYATFAWRY',
|
|
49
|
+
"currency_code": 'EGP',
|
|
50
|
+
"amount": 20,
|
|
51
|
+
"fawry_secure_key": 'fawry_secure_key',
|
|
52
|
+
"description": 'the charge request description',
|
|
53
|
+
"charge_items": [{ "item_id": 'fk3fn9flk8et9a5t9w3c5h3oc684ivho',
|
|
54
|
+
"description": 'desc', "price": 20, "quantity": 1 }] }
|
|
55
|
+
|
|
56
|
+
res = Fawry.charge(params)
|
|
57
|
+
# => #<Fawry::FawryResponse:0x0000564257d0ea90 @type="ChargeResponse", @reference_number="931600239",
|
|
58
|
+
# @merchant_ref_number="io5jxf3jp27kfh8m719arcqgw7izo7db",
|
|
59
|
+
# @expiration_time=1573153206979, @status_code=200,
|
|
60
|
+
# @status_description="Operation done successfully">
|
|
61
|
+
|
|
62
|
+
res.success? # => true
|
|
63
|
+
res.reference_number # => 931600239
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### لإجراء عملية استرداد
|
|
67
|
+
|
|
68
|
+
```ruby
|
|
69
|
+
params = { "merchant_code": 'merchant_code',
|
|
70
|
+
"reference_number": '931337410',
|
|
71
|
+
"refund_amount": 20,
|
|
72
|
+
"fawry_secure_key": 'fawry_secure_key' }
|
|
73
|
+
|
|
74
|
+
res = Fawry.refund(params)
|
|
75
|
+
# => #<Fawry::FawryResponse:0x0000564257d0ea90 @type="ResponseDataModel", @status_code=200,
|
|
76
|
+
# @status_description="Operation done successfully">
|
|
77
|
+
|
|
78
|
+
res.success? # => true
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### حالة الدفع
|
|
82
|
+
|
|
83
|
+
```ruby
|
|
84
|
+
params = { "merchant_code": 'merchant_code',
|
|
85
|
+
"merchant_ref_number": 'ssshxb98phmyvm434es62kage3nsm2cj',
|
|
86
|
+
"fawry_secure_key": 'fawry_secure_key' }
|
|
87
|
+
|
|
88
|
+
res = Fawry.payment_status(params)
|
|
89
|
+
# => #<Fawry::FawryResponse:0x0000559974056898 @type="PaymentStatusResponse", @reference_number="931922417",
|
|
90
|
+
# @merchant_ref_number="ssshxb98phmyvm434es62kage3nsm2cj",
|
|
91
|
+
# @expiration_time=1573297736167, @status_code=200,
|
|
92
|
+
# @status_description="Operation done successfully", @payment_amount=20,
|
|
93
|
+
# @payment_method="PAYATFAWRY", @payment_status="UNPAID">
|
|
94
|
+
|
|
95
|
+
res.success? # => true
|
|
96
|
+
res.payment_status # => UNPAID
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### عرض رموز الكروت
|
|
100
|
+
|
|
101
|
+
```ruby
|
|
102
|
+
params = { "merchant_code": 'merchant_code',
|
|
103
|
+
"customer_profile_id": 'customer_profile_id',
|
|
104
|
+
"fawry_secure_key": 'fawry_secure_key' }
|
|
105
|
+
|
|
106
|
+
res = Fawry.list_tokens(params)
|
|
107
|
+
|
|
108
|
+
#<Fawry::FawryResponse:0x0000556cb3a31798 @fawry_api_response={"type"=>"CustomerTokensResponse", "cards"=>[{"token"=>"b5sshhdsl98df96200f254c19b2718bfc825a0678888216c28962b3e66a393084ee9aed6", "creationDate"=>1599487402318, "lastFourDigits"=>"4242", "brand"=>"Visa Card"}, {"token"=>"fb98dslsksmkdds7857ed7042ce30a2a5b777e1f1ac6ac58da1c8c0199f61df7a8bc098e96", "creationDate"=>1599489158457, "lastFourDigits"=>"0001", "brand"=>"Visa Card"}, {"token"=>"cc03fwqaacbd94e468a1b756ac1cbb285a41a2428df9f1a727457b41f9447d0058c7c", "creationDate"=>1599584834346, "lastFourDigits"=>"2346", "brand"=>"MasterCard"}, {"token"=>"f04a8bc9c973f900515f4b58e52c9ff03070baf3f534bdfdad0e97679534f60ddkjk13", "creationDate"=>1600260415739, "lastFourDigits"=>"8769", "brand"=>"Visa Card"}], "statusCode"=>200, "statusDescription"=>"Operation done successfully"}, @type="CustomerTokensResponse", @cards=[{"token"=>"b5sshhdsl98df96200f254c19b2718bfc825a0678888216c28962b3e66a393084ee9aed6", "creationDate"=>1599487402318, "lastFourDigits"=>"4242", "brand"=>"Visa Card"}, {"token"=>"fb98dslsksmkdds7857ed7042ce30a2a5b777e1f1ac6ac58da1c8c0199f61df7a8bc098e96", "creationDate"=>1599489158457, "lastFourDigits"=>"0001", "brand"=>"Visa Card"}, {"token"=>"cc03fwqaacbd94e468a1b756ac1cbb285a41a2428df9f1a727457b41f9447d0058c7c", "creationDate"=>1599584834346, "lastFourDigits"=>"2346", "brand"=>"MasterCard"}, {"token"=>"f04a8bc9c973f900515f4b58e52c9ff03070baf3f534bdfdad0e97679534f60ddkjk13", "creationDate"=>1600260415739, "lastFourDigits"=>"8769", "brand"=>"Visa Card"}], @status_code=200, @status_description="Operation done successfully">
|
|
109
|
+
|
|
110
|
+
res.success? # => true
|
|
111
|
+
res.cards # => cards
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### إضافة رمز كارت
|
|
115
|
+
|
|
116
|
+
```ruby
|
|
117
|
+
params = { "merchant_code" : "merchant_code",
|
|
118
|
+
"customer_profile_id" : "customer_profile_id",
|
|
119
|
+
"customer_mobile" : "customer_mobile",
|
|
120
|
+
"customer_email" : "customer_email",
|
|
121
|
+
"card_number" : "card_number",
|
|
122
|
+
"expiry_year" : "expiry_year",
|
|
123
|
+
"expiry_month" : "expiry_month",
|
|
124
|
+
"cvv" : "cvv" }
|
|
125
|
+
|
|
126
|
+
res = Fawry.create_card_token(params)
|
|
127
|
+
#<Fawry::FawryResponse:0x0000556cb3eb0080 @fawry_api_response={"type"=>"CardTokenResponse", "card"=>{"token"=>"b598f96200f254c19b2718bfc825a063278888216c28962b3e66a393084ee9aed6", "creationDate"=>1607011562353, "lastFourDigits"=>"4242"}, "statusCode"=>200, "statusDescription"=>"Operation done successfully"}, @type="CardTokenResponse", @status_code=200, @status_description="Operation done successfully", @card={"token"=>"b598f96200f254c19b2718bfc825a063278888216c28962b3e66a393084ee9aed6", "creationDate"=>1607011562353, "lastFourDigits"=>"4242"}>
|
|
128
|
+
|
|
129
|
+
res.success?
|
|
130
|
+
res.card
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### حذف رمز كارت
|
|
134
|
+
|
|
135
|
+
```ruby
|
|
136
|
+
params = { "merchant_code": 'merchant_code',
|
|
137
|
+
"customer_profile_id": 'customer_profile_id',
|
|
138
|
+
"card_token": 'card_token' }
|
|
139
|
+
|
|
140
|
+
res = Fawry.delete_token(params)
|
|
141
|
+
#<Fawry::FawryResponse:0x0000556cb57c2460 @fawry_api_response={"type"=>"CardTokenResponse", "statusCode"=>200, "statusDescription"=>"Operation done successfully"}, @type="CardTokenResponse", @status_code=200, @status_description="Operation done successfully">
|
|
142
|
+
res.success?
|
|
143
|
+
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### رد اتصال خدمة تحليل فوري v2
|
|
147
|
+
|
|
148
|
+
```ruby
|
|
149
|
+
# تم إرسال المعلمات من خادم فوري
|
|
150
|
+
callback_params = { "requestId": 'c72827d084ea4b88949d91dd2db4996e', "fawryRefNumber": '970177',
|
|
151
|
+
"merchantRefNumber": '9708f1cea8b5426cb57922df51b7f790',
|
|
152
|
+
"customerMobile": '01004545545', "customerMail": 'fawry@fawry.com',
|
|
153
|
+
"paymentAmount": 152.00, "orderAmount": 150.00, "fawryFees": 2.00,
|
|
154
|
+
"shippingFees": '', "orderStatus": 'NEW', "paymentMethod": 'PAYATFAWRY',
|
|
155
|
+
"messageSignature": 'b0175565323e464b01dc9407160368af5568196997fb6e379374a4f4fbbcf587',
|
|
156
|
+
"orderExpiryDate": 1_533_554_719_314,
|
|
157
|
+
"orderItems": [{ "itemCode": 'e6aacbd5a498487ab1a10ae71061535d', "price": 150.0, "quantity": 1 }] }
|
|
158
|
+
|
|
159
|
+
fawry_callback = Fawry.parse_callback(callback_params)
|
|
160
|
+
# <Fawry::FawryCallback:0x000056339ac43730 @request_id="c72827d084ea4b88949d91dd2db4996e", @fawry_ref_number="970177",
|
|
161
|
+
# @merchant_ref_number="9708f1cea8b5426cb57922df51b7f790", @customer_mobile="01004545545",
|
|
162
|
+
# @customer_mail="fawry@fawry.com", @order_status="NEW", @order_amount=150.0, @fawry_fees=2.0, ...>
|
|
163
|
+
|
|
164
|
+
fawry_callback.fawry_ref_number # => 970177
|
|
165
|
+
fawry_callback.order_status # => NEW
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## الخطوات القادمة المطلوب تنفيذها:
|
|
169
|
+
|
|
170
|
+
- إضافة خيار لرفع الاستثناء عند فشل الطلب
|
|
171
|
+
|
|
172
|
+
## تطوير المكتبة
|
|
173
|
+
|
|
174
|
+
بعد التحقق من الريبو ، قم بتشغيل `bin/setup` لتثبيت التبعيات.
|
|
175
|
+
ثم نفذ الأمر `rake spec` لإجراء الاختبارات. يمكنك أيضا الجري `bin/console` للمطالبة التفاعلية التي تسمح لك بالتجربة.
|
|
176
|
+
|
|
177
|
+
لتثبيت هذه المكتبة على جهازك ، قم بتشغيل `bundle exec rake install`. لإصدار إصدار جديد ، قم بتحديث رقم الإصدار بتنسيق `version.rb`, ثم نفذ الأمر `bundle exec rake release`, الذي سينشئ علامة git للإصدار ، ويدفع التزامات git والعلامات ، ويدفع ملف `.gem` يا صديق [rubygems.org](https://rubygems.org).
|
|
178
|
+
|
|
179
|
+
## المساهمة
|
|
180
|
+
|
|
181
|
+
يتم الترحيب بتقارير الأخطاء وطلبات السحب على GitHub في https://github.com/amrrbakry/fawry. يهدف هذا المشروع إلى أن يكون مساحة آمنة ومرحبة للتعاون ، ومن المتوقع أن يلتزم المساهمون بـ [Contributor Covenant](http://contributor-covenant.org) القواعد السلوكية.
|