Xenland (OP)
Legendary
Offline
Activity: 980
Merit: 1003
I'm not just any shaman, I'm a Sha256man
|
|
September 25, 2011, 04:20:09 AM |
|
I will give 2 BTC to anyone that can give me some pseudo code or near complete and working code with explination or even simple comments of what everything is doing( i can figure things out pretty quickly if its done in front of my eyes so nothing too specific) Just go to this link and at the end of your response post your BTC address http://stackoverflow.com/questions/7543582/integrating-dwolla-with-php-with-their-api
|
|
|
|
mjcmurfy
|
|
September 25, 2011, 04:57:55 AM Last edit: September 25, 2011, 05:09:21 AM by mjcmurfy |
|
You use the SOAP protocol to communicate with their API. Here is a link to a discussion on the API: http://www.dwolla.org/d/showthread.php?3-SOAP-APIHere is a link to the php.net database on SOAP, and how to implement it: http://www.php.net/manual/en/class.soapclient.phpThis is the address that you use to communicate with the API: https://www.dwolla.com/api/API.svc?wsdlYou authenticate with an API key, generated in your dwolla API settings, I believe. Then you can use the other functions of the API. Sorry can't be more specific right now, it's pretty late here right now. But it's pretty easy to do, just read through the documentation on both of those links, and you should figure it out. I can post more detailed information tomorrow for you.
|
|
|
|
Xenland (OP)
Legendary
Offline
Activity: 980
Merit: 1003
I'm not just any shaman, I'm a Sha256man
|
|
September 25, 2011, 05:40:49 AM |
|
excellent documentation, I didn't learn about SOAP until like just now although I've heard of it, i think I'm missing something here..... take a look at my format <?php $client = new SoapClient("https://www.dwolla.com/api/API.svc?wsdl"); //Attempt to buy something with dwolla form $client->RequestPaymentKey("0Aw5gdfgfdgdfgdfgJjfsjdfsdfsdfsdfsfsfsfsdfgfgdj2NA+r0QUFnTeofqvRPl", "oDzdfgdfgdrgdfvsdfwefvtdbyndgsjfgdgfdghjgklgVwga7qbWoL", "1.50", "Testing testing testing", "812-504-6527"); print_r($client);
var_dump($client->__getFunctions());
?>
|
|
|
|
Xenland (OP)
Legendary
Offline
Activity: 980
Merit: 1003
I'm not just any shaman, I'm a Sha256man
|
|
September 25, 2011, 05:50:39 AM |
|
Bounty is still up for grabs if someone wants to assist in writing some psuedo-code
|
|
|
|
Xenland (OP)
Legendary
Offline
Activity: 980
Merit: 1003
I'm not just any shaman, I'm a Sha256man
|
|
September 25, 2011, 05:58:26 AM |
|
excellent documentation, I didn't learn about SOAP until like just now although I've heard of it, i think I'm missing something here..... take a look at my format <?php $client = new SoapClient("https://www.dwolla.com/api/API.svc?wsdl"); //Attempt to buy something with dwolla form $client->RequestPaymentKey("0Aw5gdfgfdgdfgdfgJjfsjdfsdfsdfsdfsfsfsfsdfgfgdj2NA+r0QUFnTeofqvRPl", "oDzdfgdfgdrgdfvsdfwefvtdbyndgsjfgdgfdghjgklgVwga7qbWoL", "1.50", "Testing testing testing", "812-504-6527"); print_r($client);
var_dump($client->__getFunctions());
?> oh yeah error is like this Fatal error: Uncaught SoapFault exception: [a:DeserializationFailed] The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'RequestPaymentKey'. End element 'Body' from namespace ' http://schemas.xmlsoap.org/soap/envelope/' expected. Found element 'param1' from namespace ''. Line 2, position 158. in /home/swiftbitcoins/purchase_order.php:16 Stack trace: #0 /home/swiftbitcoins/purchase_order.php(16): SoapClient->__call('RequestPaymentK...', Array) #1 /home/swiftbitcoins/purchase_order.php(16): SoapClient->RequestPaymentKey('s:50:"0AwevY8CP...', 'oDz1XJ1bjbaTk0i...', '1.50', 'Testing testing...', '812-504-6527') #2 {main} thrown in /home/swiftbitcoins/purchase_order.php on line 16
|
|
|
|
mjcmurfy
|
|
September 25, 2011, 06:25:42 AM Last edit: September 25, 2011, 06:41:48 AM by mjcmurfy |
|
You can use their test API ( https://www.dwolla.com/api/TestAPI.svc?wsdl) to mess around, rather than their official one. The following code: returns the following: array(5) { [ 0 ]=> string(50) "SendMoneyResponse SendMoney(SendMoney $parameters)" [1]=> string(83) "SendMoneyAssumeCostsResponse SendMoneyAssumeCosts(SendMoneyAssumeCosts $parameters)" [2]=> string(74) "RequestPaymentKeyResponse RequestPaymentKey(RequestPaymentKey $parameters)" [3]=> string(71) "VerifyPaymentKeyResponse VerifyPaymentKey(VerifyPaymentKey $parameters)" [4]=> string(65) "ConfirmPaymentResponse ConfirmPayment(ConfirmPayment $parameters)" }
|
|
|
|
mjcmurfy
|
|
September 25, 2011, 06:31:07 AM |
|
You can call the functions by using: $client->__soapCall("SomeFunction", array($a, $b, $c));
I think your way will also work i,e, $client->SomeFunction(yada, yada); It's just a slightly different way of doing it. Set each variable first, before the call. So you can be sure your strings are strings and amounts are numbers. I believe your call failed because where in your call you put "1.50" in quotes, the handler is expecting a decimal value, not a string. Try removing the quotes and see if it works out for you. The parameters, types and descriptions of the functions and their variables can be found here: http://www.dwolla.org/d/showthread.php?3-SOAP-API
|
|
|
|
mjcmurfy
|
|
September 25, 2011, 06:51:32 AM Last edit: September 25, 2011, 07:04:33 AM by mjcmurfy |
|
Try something along these lines: <?php $apiKey='xyz'; $apiCode='xyz'; $description='test'; //ENTER NUMBER, NOT STRING $amount=123; $client = new SoapClient(" https://www.dwolla.com/api/TestAPI.svc?wsdl"); $client->__soapCall("RequestPaymentKey", array($apiKey, $apiCode, $amount, $description)); //RequestPaymentKey returns a boolean: true if the request was successfully processed, False or exception otherwise if($client) { //function executed succesfully } else { //it didn't } ?> for testing purposes, it says on the dwolla site: You are able to test Dwolla’s API by using the following WSDL: https://www.dwolla.com/api/TestAPI.svc?wsdlTest API calls will not hit Dwolla’s database & no action save the responses defined are undertaken. For example, the normal generation of an email containing a secure payment key when RequestPaymentKey() is called does not take place. To simulate success or failure of each method, the amount parameter’s value is changed to one of the following values: Amount Result $1.00 Causes the operation to be successful $3.00 Amount too large (SOAP fault) $4.00 User is invalid (SOAP fault) Other Amount invalid (SOAP fault) So I think if you change the amount value to those test values, and it will simulate a success ($1), a too large failure ($3), a user invalid failure ($4) or an amount invalid failure (any other value).
|
|
|
|
Xenland (OP)
Legendary
Offline
Activity: 980
Merit: 1003
I'm not just any shaman, I'm a Sha256man
|
|
September 25, 2011, 07:15:04 AM |
|
Thanks a bunch i will report back with my results you should give me BTC address just for the effort already!
|
|
|
|
Xenland (OP)
Legendary
Offline
Activity: 980
Merit: 1003
I'm not just any shaman, I'm a Sha256man
|
|
September 25, 2011, 09:48:27 AM |
|
I think it's not picking up the parameters correctly as no matter if I try it my way or your way it just gives me this error about Deserlization or somthing of the sort.... Fatal error: Uncaught SoapFault exception: [a:DeserializationFailed] The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'RequestPaymentKey'. End element 'Body' from namespace 'http://schemas.xmlsoap.org/soap/envelope/' expected. Found element 'param1' from namespace ''. Line 2, position 158. in /home/swiftbitcoins/purchase_order.php:21 Stack trace: #0 /home/swiftbitcoins/purchase_order.php(21): SoapClient->__soapCall('RequestPaymentK...', Array) #1 {main} thrown in /home/swiftbitcoins/purchase_order.php on line 21
Here is the code I use slightly modified you for got the "CustomerId" value <?php $apiKey='0AwevY8CPVHiT2wxoxIl'; $apiCode='oDz1XJ1bjbaTk0i5RMcoEq'; $description='Testing CIB Testing';
$amount=123;
$customerId = "812-504-6527";
$client = new SoapClient("https://www.dwolla.com/api/TestAPI.svc?wsdl"); $client->__soapCall("RequestPaymentKey", array($apiKey, $apiCode, $amount, $description, $customerId));
//RequestPaymentKey returns a boolean: true if the request was successfully processed, False or exception otherwise
if($client) { //function executed succesfully } else { //it didn't }
?>
|
|
|
|
captainteemo
|
|
September 25, 2011, 05:05:59 PM |
|
I don't deal with Dwolla, but.
"Fatal error: Uncaught SoapFault exception"
//RequestPaymentKey returns a boolean: true if the request was successfully processed, False or exception otherwise
?
|
|
|
|
nhodges
|
|
September 25, 2011, 07:37:46 PM |
|
Is your amount supposed to be a string or int?
|
|
|
|
Xenland (OP)
Legendary
Offline
Activity: 980
Merit: 1003
I'm not just any shaman, I'm a Sha256man
|
|
September 25, 2011, 11:52:56 PM |
|
Is your amount supposed to be a string or int?
I don't think (int) can accept decimals?
|
|
|
|
nhodges
|
|
September 26, 2011, 12:16:36 AM |
|
Is your amount supposed to be a string or int?
I don't think (int) can accept decimals? $amount=123; Why do you have int, then?
|
|
|
|
Xenland (OP)
Legendary
Offline
Activity: 980
Merit: 1003
I'm not just any shaman, I'm a Sha256man
|
|
September 26, 2011, 01:07:12 AM |
|
Is your amount supposed to be a string or int?
I don't think (int) can accept decimals? $amount=123; Why do you have int, then? Becuase I previously tryed a varchar but doing the value in quotes. I thought you ment like forceing php to do int like this $amount = (int) 123; If i do that I wont accept decimals (as far as i know)
|
|
|
|
nhodges
|
|
September 26, 2011, 01:37:28 AM Last edit: September 26, 2011, 05:40:36 AM by nhodges |
|
I think you're not forming your object you are passing to the SOAP interface correctly. Shouldn't you have something, like an associative array, that is defining what parameters you are passing to the API? $params = array( 'ApiKey' => $apiKey, 'ApiCode' => $apiCode, 'Amount' => $amount, 'Description' => $description, 'CustomerID' => $customerId );
$client->__soapCall("RequestPaymentKey", $params); Well-constructed API's don't usually parse bundled data sequentially, since there might be non-required fields that would totally skew that type of processing.
|
|
|
|
mjcmurfy
|
|
September 26, 2011, 07:43:48 AM |
|
Is your amount supposed to be a string or int?
I don't think (int) can accept decimals? $amount=123; Why do you have int, then? Becuase I previously tryed a varchar but doing the value in quotes. I thought you ment like forceing php to do int like this $amount = (int) 123; If i do that I wont accept decimals (as far as i know) If you have passed your amount to that script as a string, you can get the float value by using: floatval($amount); You can have it round to 2 decimal places if you use floatval(round($amount,2)); @nhodges: it doesn't matter what you initialize the variable with. If you initialize it with an integer, the variable will be an integer. If you initialize it with a float, it will be a float variable. So it's not necessarily an integer he has defined. For testing purposes yes, but if he wrote $amount=1.23, it would be initialized as a float.
|
|
|
|
nhodges
|
|
September 26, 2011, 09:28:23 AM |
|
Is your amount supposed to be a string or int?
I don't think (int) can accept decimals? $amount=123; Why do you have int, then? Becuase I previously tryed a varchar but doing the value in quotes. I thought you ment like forceing php to do int like this $amount = (int) 123; If i do that I wont accept decimals (as far as i know) If you have passed your amount to that script as a string, you can get the float value by using: floatval($amount); You can have it round to 2 decimal places if you use floatval(round($amount,2)); @nhodges: it doesn't matter what you initialize the variable with. If you initialize it with an integer, the variable will be an integer. If you initialize it with a float, it will be a float variable. So it's not necessarily an integer he has defined. For testing purposes yes, but if he wrote $amount=1.23, it would be initialized as a float. Sure, I know about PHP's funky type casting (good or bad, however you want to look at it) I was just thinking it might be an issue on the API side. Do you think the issue Xenland is having is more related to the second suggestion I made, though?
|
|
|
|
mjcmurfy
|
|
September 26, 2011, 09:38:05 AM |
|
Sure, I know about PHP's funky type casting (good or bad, however you want to look at it) I was just thinking it might be an issue on the API side. Do you think the issue Xenland is having is more related to the second suggestion I made, though?
It's quite possible. An associative array might do the trick alright.
|
|
|
|
Xenland (OP)
Legendary
Offline
Activity: 980
Merit: 1003
I'm not just any shaman, I'm a Sha256man
|
|
September 27, 2011, 12:13:17 AM |
|
I attempted to use the associative array, and made sure all the variables match exactly from any spelling differences. Still getting this error: SoapFault exception: [a:DeserializationFailed] The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'RequestPaymentKey'. End element 'Body' from namespace ' http://schemas.xmlsoap.org/soap/envelope/' expected. Found element 'param1' from namespace ''. Line 2, position 158. in /home/swiftbitcoins/purchase_order.php:31 Stack trace: #0 /home/swiftbitcoins/purchase_order.php(31): SoapClient->__soapCall('RequestPaymentK...', Array) #1 {main}ERROR using this code $client = new SoapClient("https://www.dwolla.com/api/TestAPI.svc?wsdl"); $params = array( 'ApiKey' => $apiKey, 'ApiCode' => $apiCode, 'Amount' => $amount, 'Description' => $description, 'CustomerID' => $customerId );
try{ $client->__soapCall("RequestPaymentKey", $params); }catch(Exception $e){ echo $e; echo "ERROR"; } Just so we are clear ApiCode is really the "Secret" key right?
|
|
|
|
|