paymob_accept 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +6 -2
- data/lib/paymob_accept/api/base.rb +5 -6
- data/lib/paymob_accept/api/pay.rb +6 -6
- data/lib/paymob_accept/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f07b80f4fe23b6ca6da25649d650917ebf48802ce93903ca44dde300acf0f89
|
4
|
+
data.tar.gz: 4238ee5fa6e5267b27deac4b3f45701759515420ae4cfc255621691ef8f9b616
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f29651bddc3f492f908304e0aa1f552b597ba9e8feeaff5f67f1bb045b2b8791f5bf66cf72a16291ae43b7036da4277dc5276dd75550351a4fe476396e7af127
|
7
|
+
data.tar.gz: f761e0b4eb1faafd6688beafdf195416ec2db6160265d9227b3e94c332bddf5c4f493965d2a3ce2767c0f9622ad36b90a5e699e21b7d1307f7c85c1ebe499d91
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -112,11 +112,15 @@ The `:method` key in the `charge` method could be one of the following:
|
|
112
112
|
|
113
113
|
Please refer to the official Paymob documentation for in-depth explanation about each payment method.
|
114
114
|
|
115
|
-
The return value of the `charge` method in general is the response of Paymob's server which varies according to the payment method except in `:online`. In an `:online` payment if an `iframe_id` is provided, the return value is an iFrame URL with an embedded payment token. If the `iframe_id` is not provided, only the payment token is returned
|
115
|
+
The return value of the `charge` method in general is the response of Paymob's server which varies according to the payment method except in `:online`. In an `:online` payment if an `iframe_id` is provided, the return value is an iFrame URL with an embedded payment token. If the `iframe_id` is not provided, only the payment token and order_id is returned
|
116
116
|
|
117
117
|
### Paying with a saved card token
|
118
118
|
|
119
|
-
|
119
|
+
```ruby
|
120
|
+
def pay_moto(customer:, address:, cc_token:, amount_cents:, amount_currency:)
|
121
|
+
```
|
122
|
+
|
123
|
+
- To pre-fill an iFrame with a customer card data or process a MOTO charge, make sure to pass the `cc_token` key in addition to the fields mentioned above.
|
120
124
|
|
121
125
|
## Dealing with charges
|
122
126
|
|
@@ -28,20 +28,20 @@ module PaymobAccept
|
|
28
28
|
end
|
29
29
|
|
30
30
|
# 3. Payment Key Request
|
31
|
-
def generate_payment_intent(customer:, address:, integration_id:, amount_cents:, amount_currency:, iframe_id: nil, order_id: nil, auth_token: get_auth_token)
|
31
|
+
def generate_payment_intent(customer:, address:, integration_id:, amount_cents:, amount_currency:, cc_token: nil, iframe_id: nil, order_id: nil, auth_token: get_auth_token)
|
32
32
|
if order_id.nil?
|
33
33
|
order = create_order(amount_cents: amount_cents, amount_currency: amount_currency)
|
34
34
|
order_id = order['id']
|
35
35
|
end
|
36
36
|
payment_token = generate_payment_key(auth_token: auth_token, customer: customer, address: address, order_id: order_id, amount_cents: amount_cents, amount_currency: amount_currency,
|
37
|
-
integration_id: integration_id)
|
37
|
+
integration_id: integration_id, cc_token: cc_token)
|
38
38
|
|
39
|
-
format_bill_reference(payment_token, iframe_id)
|
39
|
+
{ token: format_bill_reference(payment_token, iframe_id), order_id: order_id }
|
40
40
|
end
|
41
41
|
|
42
42
|
private
|
43
43
|
|
44
|
-
def generate_payment_key(customer:, address:, amount_cents:, amount_currency:, integration_id:, order_id: nil, auth_token: get_auth_token)
|
44
|
+
def generate_payment_key(customer:, address:, amount_cents:, amount_currency:, integration_id:, cc_token: nil, order_id: nil, auth_token: get_auth_token)
|
45
45
|
body = {
|
46
46
|
"auth_token": auth_token,
|
47
47
|
"amount_cents": amount_cents.to_i,
|
@@ -65,7 +65,7 @@ module PaymobAccept
|
|
65
65
|
},
|
66
66
|
"integration_id": integration_id
|
67
67
|
}
|
68
|
-
body['token'] =
|
68
|
+
body['token'] = cc_token unless cc_token.nil?
|
69
69
|
|
70
70
|
response = @client.request('/acceptance/payment_keys', body)
|
71
71
|
|
@@ -98,7 +98,6 @@ module PaymobAccept
|
|
98
98
|
"last_name": { "type": 'string' },
|
99
99
|
"email": { "type": 'string' },
|
100
100
|
"phone_number": { "type": 'string' },
|
101
|
-
"cc_token": { "type": 'string' },
|
102
101
|
"wallet_mobile_number": { "type": 'string' }
|
103
102
|
},
|
104
103
|
"required": %w[email phone_number]
|
@@ -36,15 +36,15 @@ module PaymobAccept
|
|
36
36
|
end
|
37
37
|
|
38
38
|
# Return an iFrame URL if an iframe_id is provided. Otherwise, returns a payment token
|
39
|
-
# The iFrame will be prepoulated with the credit card info if
|
40
|
-
def pay_online(customer:, address:, amount_cents:, amount_currency:, iframe_id: nil)
|
39
|
+
# The iFrame will be prepoulated with the credit card info if cc_token is present and is valid stored credit card token on Paymob's server
|
40
|
+
def pay_online(customer:, address:, amount_cents:, amount_currency:, cc_token: nil, iframe_id: nil)
|
41
41
|
generate_payment_intent(customer: customer, address: address, amount_cents: amount_cents, amount_currency: amount_currency,
|
42
|
-
integration_id: online_integration_id, iframe_id: iframe_id)
|
42
|
+
integration_id: online_integration_id, iframe_id: iframe_id, cc_token: cc_token)
|
43
43
|
end
|
44
44
|
|
45
45
|
# Paying MOTO (ie. with a saved card token)
|
46
|
-
def pay_moto(customer:, address:, amount_cents:, amount_currency:)
|
47
|
-
if
|
46
|
+
def pay_moto(customer:, address:, cc_token:, amount_cents:, amount_currency:)
|
47
|
+
if cc_token.nil?
|
48
48
|
raise ArgumentError,
|
49
49
|
'You need to provide a credit card token for MOTO payments'
|
50
50
|
end
|
@@ -52,7 +52,7 @@ module PaymobAccept
|
|
52
52
|
bill_reference = generate_payment_intent(customer: customer, address: address, amount_cents: amount_cents, amount_currency: amount_currency,
|
53
53
|
integration_id: auth_integration_id)
|
54
54
|
body = {
|
55
|
-
"source": { "subtype": 'TOKEN', "identifier":
|
55
|
+
"source": { "subtype": 'TOKEN', "identifier": cc_token },
|
56
56
|
"payment_token": bill_reference
|
57
57
|
}
|
58
58
|
@client.request('/acceptance/payments/pay', body)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paymob_accept
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OneOrder
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|