Created
April 22, 2020 14:56
-
-
Save thlinux1107/b82359e8755d94262e0e0ca519c4d5fa to your computer and use it in GitHub Desktop.
Paya Connect - Transactions Endpoint - Vault Sale
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /*---------------------------------------------- | |
# Author: SDK Support Group | |
# Company: Paya | |
# Contact: sdksupport@paya.com | |
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
# !!! Samples intended for educational use only!!! | |
# !!! Not intended for production !!! | |
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
# -----------------------------------------------*/ | |
require 'net/http' | |
require 'uri' | |
require 'json' | |
require 'openssl' | |
host = "https://api.sandbox.payaconnect.com" | |
path = "/v2/transactions" | |
url = host + path | |
# You'll receive sandbox credentials when you register with | |
# https://https://developer.sandbox.payaconnect.com/ and click SignUp. | |
locationID = "[Location ID]" | |
developerID = "[Developer ID]" | |
userID = "[User ID]" | |
userAPIKey = "[User API Key]" | |
uri = URI.parse(url) | |
time = Time.now.to_i | |
timestamp = time.to_s | |
puts "Timestamp: " + timestamp | |
header = { | |
'Content-Type'=> 'application/json', | |
'developer-id'=> developerID, | |
'user-api-key'=> userAPIKey, | |
'user-id'=> userID, | |
} | |
reqJson = {transaction: { | |
action: 'sale', | |
account_type: 'mc', | |
payment_method: 'cc', | |
location_id: locationID, | |
transaction_amount: '1.00', | |
account_vault_id: '[Account Vault ID]', # account_vault_api_id also may be used | |
order_num: 'Invoice ' + timestamp, | |
description: 'SDK Test CC Sale Ruby' | |
} | |
}.to_json | |
puts "Request Body:" | |
puts reqJson | |
# Create the HTTP objects | |
http = Net::HTTP.new(uri.host, uri.port) | |
http.use_ssl = true | |
http.verify_mode = OpenSSL::SSL::VERIFY_NONE | |
request = Net::HTTP::Post.new(uri.request_uri, header) | |
request.body = reqJson | |
# Send the request | |
response = http.request(request) | |
puts "Response Code:" | |
puts response.code | |
puts "Response Body:" | |
puts response.body |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment