Class: Braintree::LocalPaymentContextGateway
- Inherits:
-
Object
- Object
- Braintree::LocalPaymentContextGateway
- Defined in:
- lib/braintree/local_payment_context_gateway.rb
Constant Summary collapse
- CREATE_LOCAL_PAYMENT_CONTEXT =
<<~GRAPHQL mutation CreateLocalPaymentContext($input: CreateLocalPaymentContextInput!) { createLocalPaymentContext(input: $input) { paymentContext { id legacyId type paymentId approvalUrl merchantAccountId orderId createdAt transactedAt approvedAt amount { value currencyCode } } } } GRAPHQL
- FIND_LOCAL_PAYMENT_CONTEXT =
<<~GRAPHQL query Node($id: ID!) { node(id: $id) { ... on LocalPaymentContext { id legacyId type amount { value currencyIsoCode } approvalUrl merchantAccountId transactedAt approvedAt createdAt updatedAt expiredAt paymentId orderId } } } GRAPHQL
Instance Method Summary collapse
- #create(input) ⇒ Object
- #find(id) ⇒ Object
-
#initialize(gateway, graphql_client) ⇒ LocalPaymentContextGateway
constructor
A new instance of LocalPaymentContextGateway.
Constructor Details
#initialize(gateway, graphql_client) ⇒ LocalPaymentContextGateway
Returns a new instance of LocalPaymentContextGateway.
51 52 53 54 |
# File 'lib/braintree/local_payment_context_gateway.rb', line 51 def initialize(gateway, graphql_client) @gateway = gateway @graphql_client = graphql_client end |
Instance Method Details
#create(input) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/braintree/local_payment_context_gateway.rb', line 56 def create(input) variables = {"input" => input.to_graphql_variables} begin response = @graphql_client.query(CREATE_LOCAL_PAYMENT_CONTEXT, variables) errors = GraphQLClient.get_validation_errors(response) if errors ErrorResult.new(@gateway, {errors: errors}) else payment_context = extract_payment_context(response) SuccessfulResult.new(:payment_context => payment_context) end rescue StandardError => e raise UnexpectedError, e. end end |
#find(id) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/braintree/local_payment_context_gateway.rb', line 74 def find(id) variables = {"id" => id} begin response = @graphql_client.query(FIND_LOCAL_PAYMENT_CONTEXT, variables) errors = GraphQLClient.get_validation_errors(response) if errors ErrorResult.new(@gateway, {errors: errors}) else payment_context = extract_node_payment_context(response) SuccessfulResult.new(:payment_context => payment_context) end rescue NotFoundError raise rescue StandardError => e raise UnexpectedError, e. end end |