Skip to content

Commit 0153bf0

Browse files
Sep release (#52)
* Network tokenization change * changed request target header * sep release
1 parent a7af77d commit 0153bf0

9 files changed

+124
-7
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,16 @@ build-iPhoneSimulator/
3434
/_yardoc/
3535
/doc/
3636
/rdoc/
37+
log
3738

3839
## Environment normalization:
3940
/.bundle/
4041
/vendor/bundle
4142
/lib/bundler/man/
4243

44+
#IDE config folders
45+
.idea
46+
4347
# for a library or gem, you might want to ignore these files since the code is
4448
# intended to run in multiple environments; otherwise, check them in:
4549
# Gemfile.lock

Samples/Authentication/src/StandAloneHttpSignature.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,16 @@ def getHttpSignature(resource, http_method, gmtdatetime)
6363
signatureHeaderValue << ", algorithm=\"HmacSHA256\""
6464

6565
if http_method == "post"
66-
signatureHeader = 'host date (request-target) digest v-c-merchant-id'
66+
signatureHeader = 'host date request-target digest v-c-merchant-id'
6767
elsif http_method == "get"
68-
signatureHeader = 'host date (request-target) v-c-merchant-id'
68+
signatureHeader = 'host date request-target v-c-merchant-id'
6969
end
7070

7171
signatureHeaderValue << ", headers=\"" + signatureHeader + "\""
7272

7373
signatureString = 'host: ' + @@request_host
7474
signatureString << "\ndate: " + gmtdatetime
75-
signatureString << "\n(request-target): "
75+
signatureString << "\nrequest-target: "
7676

7777
targetUrl = http_method + ' ' + resource
7878

Samples/RecurringBillingSubscriptions/Plans/create-plan.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def run()
1111
plan_information.name = "Gold Plan"
1212
plan_information.description = "New Gold Plan"
1313
plan_information.status = plan_information_status
14-
billing_period = CyberSource::InlineResponse200PlanInformationBillingPeriod.new
14+
billing_period = CyberSource::GetAllPlansResponsePlanInformationBillingPeriod.new
1515
billing_period.length = "1"
1616
billing_period.unit = "M"
1717
plan_information.billing_period = billing_period

Samples/RecurringBillingSubscriptions/Plans/update-plan.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def run()
1010
plan_information = CyberSource::Rbsv1plansidPlanInformation.new
1111
plan_information.name = "Gold Plan NA"
1212
plan_information.description = "Updated Gold Plan"
13-
billing_period = CyberSource::InlineResponse200PlanInformationBillingPeriod.new
13+
billing_period = CyberSource::GetAllPlansResponsePlanInformationBillingPeriod.new
1414
billing_period.length = "2"
1515
billing_period.unit = "W"
1616
plan_information.billing_period = billing_period
@@ -25,8 +25,8 @@ def run()
2525
processing_information.subscription_billing_options = subscription_billing_options
2626
request_obj.processing_information = processing_information
2727

28-
order_information = CyberSource::InlineResponse200OrderInformation.new
29-
amount_details = CyberSource::InlineResponse200OrderInformationAmountDetails.new
28+
order_information = CyberSource::GetAllPlansResponseOrderInformation.new
29+
amount_details = CyberSource::GetAllPlansResponseOrderInformationAmountDetails.new
3030
amount_details.currency = "USD"
3131
amount_details.billing_amount = "11"
3232
amount_details.setup_fee = "2"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# frozen_string_literal: true
2+
3+
require 'cybersource_rest_client'
4+
require_relative '../../data/Configuration'
5+
6+
public
7+
class Create_instrument_identifier_card_enroll_for_network_token
8+
def run(profile_id = nil )
9+
if profile_id == nil?
10+
profile_id = '93B32398-AD51-4CC2-A682-EA3E93614EB1'
11+
end
12+
request_obj = CyberSource::PostInstrumentIdentifierRequest.new
13+
request_obj.type = "enrollable card"
14+
card = CyberSource::Tmsv2customersEmbeddedDefaultPaymentInstrumentEmbeddedInstrumentIdentifierCard.new
15+
card.number = "5204245750003216"
16+
card.expiration_month = "12"
17+
card.expiration_year = "2025"
18+
request_obj.card = card
19+
20+
opts = {}
21+
opts[:"profile-id"] = profile_id
22+
23+
config = MerchantConfiguration.new.merchantConfigProp()
24+
api_client = CyberSource::ApiClient.new
25+
api_instance = CyberSource::InstrumentIdentifierApi.new(api_client, config)
26+
data, status_code, headers = api_instance.post_instrument_identifier(request_obj, opts)
27+
puts data, status_code, headers
28+
write_log_audit(status_code)
29+
return data
30+
rescue StandardError => err
31+
write_log_audit(err.code)
32+
puts err.message
33+
end
34+
35+
def write_log_audit(status)
36+
filename = ($0.split("/")).last.split(".")[0]
37+
puts "[Sample Code Testing] [#{filename}] #{status}"
38+
end
39+
40+
if __FILE__ == $0
41+
profileid = '93B32398-AD51-4CC2-A682-EA3E93614EB1'
42+
Create_instrument_identifier_card_enroll_for_network_token.new.run(profileid)
43+
end
44+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# frozen_string_literal: true
2+
3+
4+
require 'cybersource_rest_client'
5+
require_relative './payment-credentials-from-network-token'
6+
7+
public
8+
class NetworkTokenization
9+
def run()
10+
11+
config = MerchantConfiguration.new.merchantConfigProp
12+
require 'AuthenticationSDK/core/MerchantConfig'
13+
merchant_configuration = Merchantconfig.new(config)
14+
15+
# Step-I
16+
encoded_payment_credentials_response = Payment_credentials_from_network_token.new.run
17+
18+
#Step-II
19+
decoded_response = CyberSource::JWEUtility.decryptJWEResponse(encoded_payment_credentials_response, merchant_configuration)
20+
21+
puts 'Decoded Response'
22+
puts decoded_response
23+
end
24+
25+
if __FILE__ == $0
26+
NetworkTokenization.new.run
27+
end
28+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# frozen_string_literal: true
2+
3+
require 'cybersource_rest_client'
4+
require_relative '../../data/Configuration'
5+
6+
7+
public
8+
class Payment_credentials_from_network_token
9+
def run
10+
# token_id of your instrument
11+
token_id = '7010000000008573216'
12+
config = MerchantConfiguration.new.merchantConfigProp()
13+
api_client = CyberSource::ApiClient.new
14+
api_instance = CyberSource::TokenApi.new(api_client, config)
15+
data, headers, status_code = api_instance.post_token_payment_credentials(token_id)
16+
puts data, status_code, headers
17+
write_log_audit(status_code)
18+
return data
19+
rescue StandardError => err
20+
write_log_audit(err.code)
21+
puts err.message
22+
end
23+
24+
def write_log_audit(status)
25+
filename = ($0.split("/")).last.split(".")[0]
26+
puts "[Sample Code Testing] [#{filename}] #{status}"
27+
end
28+
29+
if __FILE__ == $0
30+
31+
Payment_credentials_from_network_token.new.run
32+
end
33+
end

data/Configuration.rb

+5
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ def merchantConfigProp()
5858
log_config['enableMasking'] = enableMasking
5959

6060
configurationDictionary['logConfiguration'] = log_config
61+
62+
# PEM Key file path for decoding JWE Response Enter the folder path where the .pem file is located.
63+
# It is optional property, require adding only during JWE decryption.
64+
configurationDictionary['pemFileDirectory'] = 'resource/NetworkTokenCert.pem'
65+
6166
return configurationDictionary
6267
end
6368

resource/NetworkTokenCert.pem

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-----BEGIN RSA PRIVATE KEY-----
2+
MIIEpAIBAAKCAQEA2tNGgpyJKgviPHjuNmcF+5tPjFsxBKebsto9swyebVcJVYu5Mp4Yz8VnhPbEdkyzckTtAulXQYA82iPYG/BHEbChR/PHwO3yCsbTDDNQlkB0R5c5Py/Ts4BSLvIwkbJEvd/SQxTPaPOOYjqbqSfzJ4oKsCGzW+K94UnZic8b5II8CrKlLZLZSO2RoURFg+4htjXhikBJXqJdDhneZCgnMxbWU8MKbdXXJUIDZq0jMkNUNOi1xdzLHhZQl464kD+VocTUS06Ky8h/FBU6xRJciLQW7/VieqzVxG5MGxwcSNfbiozG7aHw+Nt4Awkt6N2VpcxL6AmOXoKRH5om1yCNhwIDAQABAoIBAQCky1WfiVl288ol9oCXMdD8ogMvVYG92qfT8q1iiQ9KkrBx3y7SouNWnXiPVvOvj6XYWXYQqj/PEU9CjJn0uGgdN2LOeBWoAso0OXW5C3AWJ2YqgAVZw5/v36SEvFm9b357a/LCGAr3I+zHpxGRO4fP8BKKgGa9vS14W5BbS0DbPZ9/QvzRfinw6l+/l2mnPihB8KyvABtsiBv0ylh525JY3SFp7bx9qLePjYXMR9u8P+LhD4CPvps5htj1E/JSV3nysNYUP7qc3m4OPhrT46ly2vIMVYDWrHw7i9CGf4XVtZuJ0jRSaG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