Last active
July 28, 2020 02:40
-
-
Save agentcoops/45cf61c03756b85aa2d8 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
Dim StripeURL, APIKey | |
StripeURL = "https://api.stripe.com/v1/charges" | |
APIKey = <YOUR SECRET KEY> | |
Function makeStripeAPICall(requestBody) | |
Dim objXmlHttpMain | |
Set objXmlHttpMain = CreateObject("Msxml2.ServerXMLHTTP") | |
On Error Resume Next | |
objXmlHttpMain.open "POST", StripeURL, False | |
objXmlHttpMain.setRequestHeader "Authorization", "Bearer "& APIKey | |
objXmlHttpMain.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" | |
objXmlHttpMain.send requestBody | |
makeStripeAPICall = objXmlHttpMain.responseText | |
End Function | |
Function chargeCard(month, year, cvc, number, cost) | |
Dim cardDetails, requestBody | |
cardDetails = "source[exp_month]="& month &"&source[exp_year]="& year &"&source[number]="& number &"&source[cvc]="& cvc | |
requestBody = "currency=usd&amount="& cost &"&source[object]=card&"& cardDetails | |
chargeCard = makeStripeAPICall(requestBody) | |
End Function | |
Function chargeCardWithToken(token, cost) | |
Dim requestBody | |
requestBody = "currency=usd&amount="& cost &"&source="& token | |
chargeCardWithToken = makeStripeAPICall(requestBody) | |
End Function | |
MsgBox(chargeCard("01", "20", "123", "4242424242424242", "400")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment