Pages:
Author

Topic: Looking for a PHP dev that can give me some Pseudo-code for Dwolla API [2BTC] - page 2. (Read 4907 times)

legendary
Activity: 980
Merit: 1003
I'm not just any shaman, I'm a Sha256man
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? Tongue

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)
sr. member
Activity: 322
Merit: 251
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? Tongue
legendary
Activity: 980
Merit: 1003
I'm not just any shaman, I'm a Sha256man
Is your amount supposed to be a string or int?

I don't think (int) can accept decimals?
sr. member
Activity: 322
Merit: 251
Is your amount supposed to be a string or int?
full member
Activity: 143
Merit: 101
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

?
legendary
Activity: 980
Merit: 1003
I'm not just any shaman, I'm a Sha256man
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....

Code:
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

Code:

$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
}

?>
legendary
Activity: 980
Merit: 1003
I'm not just any shaman, I'm a Sha256man
Thanks a bunch i will report back with my results you should give me BTC address just for the effort already!
sr. member
Activity: 336
Merit: 250
Try something along these lines:

Quote

$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:

Quote
You are able to test Dwolla’s API by using the following WSDL:
https://www.dwolla.com/api/TestAPI.svc?wsdl

Test 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).
sr. member
Activity: 336
Merit: 250
You can call the functions by using:

Quote
$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

sr. member
Activity: 336
Merit: 250
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:

Quote

$client = new SoapClient("https://www.dwolla.com/api/TestAPI.svc?wsdl");
var_dump($client->__getFunctions());

?>

returns the following:

Quote
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)" }
legendary
Activity: 980
Merit: 1003
I'm not just any shaman, I'm a Sha256man
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

Code:
$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
Quote from: error
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
legendary
Activity: 980
Merit: 1003
I'm not just any shaman, I'm a Sha256man
Bounty is still up for grabs if someone wants to assist in writing some psuedo-code
legendary
Activity: 980
Merit: 1003
I'm not just any shaman, I'm a Sha256man
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

Code:
$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());
?>
sr. member
Activity: 336
Merit: 250
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-API

Here is a link to the php.net database on SOAP, and how to implement it:
http://www.php.net/manual/en/class.soapclient.php

This is the address that you use to communicate with the API:
https://www.dwolla.com/api/API.svc?wsdl

You 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.
legendary
Activity: 980
Merit: 1003
I'm not just any shaman, I'm a Sha256man
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
Pages:
Jump to: