paymob_accept 0.3.0 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 74ac2d808d84a3858e5ea44a1b6db205c28d0f092bc06fac9569766aca7f993a
4
- data.tar.gz: 0104bfacb501475891edebcdf30f7f68e61ac259b45b75a9c556a0cc917009a4
3
+ metadata.gz: a858f0d51d53e165acf7bb759286fd6d3ffba067068342e1356d98edf9523652
4
+ data.tar.gz: 05d5404002d4ff545c32c67f310d1c42cdb0ea6869fa03f46938a1cf9d15638f
5
5
  SHA512:
6
- metadata.gz: 52bc4b9d8af84a9df149edf279aa782391346bcd1de3adfe21ec4416c39f625b2dc5afa7b12b1e74a4fde43ed4575ec07bfbea292818403df5796c5e0a0f9096
7
- data.tar.gz: 959e4ab4f5257eb40d115d2e70edc43e593b52acba626a5eed866df261f0b2171648c48231f191c33bf019c5cf2c48fe4c7c9f170f0d4d616fa55aabbb0e9579
6
+ metadata.gz: 130578e9ccb379fc2b8bd76a22d149502d8177a52026abffca362456f30341055979f2b8478322ef55e1edd1408cf124916c6a885be23aa229d36cc02b4bc0c3
7
+ data.tar.gz: 793edd6500af9628d4746bb40c9b824e035e05bf3ddb819dfc546d41f82d1d6d44f98e7db5407fc0506184fe43f2c598771f14bd4f24b96f879648bf744e324c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- paymob_accept (0.3.0)
4
+ paymob_accept (0.3.2)
5
5
  faraday
6
6
  json-schema
7
7
 
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
- To pre-fill an iFrame with a customer card data or process a MOTO charge, make sure the `customer_data` hash has a `cc_token` key in addition to the fields mentioned above.
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'] = customer[:cc_token] unless customer[:cc_token].nil?
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]
@@ -30,21 +30,21 @@ module PaymobAccept
30
30
 
31
31
  private
32
32
 
33
- def pay_auth(customer:, address:, amount_cents:, amount_currency:)
33
+ def pay_auth(customer:, address:, amount_cents:, amount_currency:, iframe_id: nil, cc_token: nil)
34
34
  generate_payment_intent(customer: customer, address: address, amount_cents: amount_cents, amount_currency: amount_currency,
35
- integration_id: auth_integration_id)
35
+ integration_id: auth_integration_id, iframe_id: iframe_id, cc_token: cc_token)
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 customer[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:, 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 customer[:cc_token].nil?
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": customer[:cc_token] },
55
+ "source": { "subtype": 'TOKEN', "identifier": cc_token },
56
56
  "payment_token": bill_reference
57
57
  }
58
58
  @client.request('/acceptance/payments/pay', body)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PaymobAccept
4
- VERSION = '0.3.0'
4
+ VERSION = '0.3.2'
5
5
  end
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.0
4
+ version: 0.3.2
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-02 00:00:00.000000000 Z
11
+ date: 2022-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday