Created
March 22, 2018 04:48
-
-
Save yasalmasri/886e137b6bf25b3ff9114ac212848139 to your computer and use it in GitHub Desktop.
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
url = "https://sandbox-api.openpay.mx/v1/#{ENV['OPENPAY_MERCHANT_ID']}/webhooks" | |
hook = { | |
url: URL_TO_MY_CONTROLLER, | |
user: 'USER', | |
password: 'PASSWORD', | |
event_types: [ | |
'charge.refunded', | |
'charge.failed', | |
'charge.cancelled', | |
'charge.created', | |
'charge.succeeded', | |
'charge.rescored.to.decline', | |
'subscription.charge.failed', | |
'payout.created', | |
'payout.succeeded', | |
'payout.failed', | |
'transfer.succeeded', | |
'fee.succeeded', | |
'fee.refund.succeeded', | |
'spei.received', | |
'chargeback.created', | |
'chargeback.rejected', | |
'chargeback.accepted', | |
'order.created', | |
'order.activated', | |
'order.payment.received', | |
'order.completed', | |
'order.expired', | |
'order.cancelled', | |
'order.payment.cancelled' | |
] | |
} | |
res = RestClient::Request.execute( | |
method: :post, | |
url: url, | |
user: ENV['OPENPAY_PRIVATE_KEY'], | |
ssl_version: :TLSv1_2, | |
payload: hook.to_json, | |
headers: { | |
content_type: :json, | |
accept: :json, | |
user_agent: 'Openpay/v1 Ruby-API', | |
json: hook.to_json | |
} | |
) | |
ap JSON.parse res.body |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment