diff --git a/README.md b/README.md index 16841ef..1ba1102 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ $api = Instamojo\Instamojo::init($authType,[ "username" => 'FOO', /** In case of user based authentication**/ "password" => 'XXXXXXXX' /** In case of user based authentication**/ - ],true); /** true for sandbox enviorment**/ + ],true); /** true for sandbox environment**/ ``` @@ -62,10 +62,10 @@ catch (Exception $e) { } ``` -This will give you JSON object containing details of the Payment Request that was just created with `longurl` key provide you instamojo-payment-url. +This will give you JSON object containing details of the Payment Request and a `longurl` on which you can perform a checkout process. ### Recommended seamless checkout Option - You can render your Instamojo checkout form and collect payments on your webpage with just the instamojo-payment-url obtained in `createPaymentRequest()` using JS based seamless checkout library. To know more how its work [Click here](https://docs.instamojo.com/page/seamless-checkout). + You can render the Instamojo checkout form and collect payments on your webpage using the instamojo-payment-url obtained from `createPaymentRequest()` using our JS based seamless checkout library. To know more about how it works [Click here](https://docs.instamojo.com/page/seamless-checkout). ## Payment Request Creation Parameters @@ -82,8 +82,8 @@ This will give you JSON object containing details of the Payment Request that wa * `redirect_url`: set this to a thank-you page on your site. Buyers will be redirected here after successful payment. * `webhook`: set this to a URL that can accept POST requests made by Instamojo server after successful payment. * `allow_repeated_payments`: To disallow multiple successful payments on a Payment Request pass `false` for this field. If this is set to `false` then the link is not accessible publicly after first successful payment, though you can still access it using API(default value: `true`). - * `partner_fee_type` : Allows you to receive a cut from from payments you facilitate. For fixed fee set this to `fixed`, or for percentage fee set it to `percent`. - * `partner_fee` : This describes the fee that you would collect. It can be either a fixed amount, or a percentage of the original amount, depending on the value of `partner_fee_type`. + * `partner_fee_type` : Allows you to receive a cut from the payments you facilitate. For fixed fee set this to `fixed`, or for percentage fee set it to `percent`. + * `partner_fee` : This is a double data type key which describes the fee that you would collect. It can be either a fixed amount, or a percentage of the original amount, depending on the value of `partner_fee_type`. * `mark_fulfilled` : Flag to determine if you want to put the payment on hold until you explicitly fulfil it. If `mark_fulfilled` is `True` the payment will be paid out to the merchant. If `mark_fulfilled` is `False`, then the payment will be put on hold until you explicitly fulfil the payment. See Fulfil a Payment below on how to fulfil a payment. * `expires_at` : Time after which the payment request will be expired in UTC timestamp. Max value is 600 seconds. Default is Null. @@ -219,7 +219,7 @@ catch (Exception $e) { ``` `$payment_request_id` id the `id` key obtained in `createPaymentRequest()` method. -This will give you JSON object containing with created `order_id` key. +This will give you JSON object that contains newly created order id in `order_id` key. ### Get the details of a Gateway Order @@ -297,7 +297,7 @@ catch (Exception $e) { } ``` -This will give you JSON object containing details of the Refund. +This will give you JSON object containing details of the Refund. @@ -314,7 +314,7 @@ catch (Exception $e) { } ``` -This will give you an array containing Refunds details so far. +This will give you an array containing Refunds details so far. getRefunds() also accepts optional parameters for pagination. diff --git a/docs/v1.1/README.md b/docs/v1.1/README.md index 46ad921..d122288 100644 --- a/docs/v1.1/README.md +++ b/docs/v1.1/README.md @@ -43,7 +43,9 @@ catch (Exception $e) { This will give you JSON object containing details of the Payment Request that was just created. - +### Recommended seamless checkout Option + You can render the Instamojo checkout form and collect payments on your webpage using the instamojo-payment-url obtained from `createPaymentRequest()` using our JS based seamless checkout library. To know more about how it works [Click here](https://docs.instamojo.com/page/seamless-checkout). + ### Get the status or details of a Payment Request ```php diff --git a/docs/v2.0/README.md b/docs/v2.0/README.md index cd549cc..1ba1102 100644 --- a/docs/v2.0/README.md +++ b/docs/v2.0/README.md @@ -2,7 +2,12 @@ Assists you to programmatically create, edit and delete Links on Instamojo in PHP. -**Note**: If you're using this wrapper with our sandbox environment `https://test.instamojo.com/` then you should pass `true` as third argument to the `Instamojo` class while initializing it. `client_id` and `client_secret` token for the same can be obtained from https://test.instamojo.com/developers/ (Details: [Test Or Sandbox Account](https://instamojo.zendesk.com/hc/en-us/articles/208485675-Test-or-Sandbox-Account)). +**Note**: +* If you are using other version of instamojo-php you can refer to their docs from appropriate link below + * [v1.1](docs/v1.1) + +* If you're using this wrapper with our sandbox environment `https://test.instamojo.com/` then you should pass `true` as third argument to the `Instamojo` class while initializing it. `client_id` and `client_secret` token for the same can be obtained from https://test.instamojo.com/developers/ (Details: [Test Or Sandbox Account](https://instamojo.zendesk.com/hc/en-us/articles/208485675-Test-or-Sandbox-Account)). + ```php $authType = "app/user" /**Depend on app or user based authentication**/ @@ -13,7 +18,7 @@ $api = Instamojo\Instamojo::init($authType,[ "username" => 'FOO', /** In case of user based authentication**/ "password" => 'XXXXXXXX' /** In case of user based authentication**/ - ],true); /** true for sandbox enviorment**/ + ],true); /** true for sandbox environment**/ ``` @@ -57,10 +62,10 @@ catch (Exception $e) { } ``` -This will give you JSON object containing details of the Payment Request that was just created with `longurl` key provide you instamojo-payment-url. +This will give you JSON object containing details of the Payment Request and a `longurl` on which you can perform a checkout process. ### Recommended seamless checkout Option - You can render your Instamojo checkout form and collect payments on your webpage with just the instamojo-payment-url obtained in `createPaymentRequest()` using JS based seamless checkout library. To know more how its work [Click here](https://docs.instamojo.com/page/seamless-checkout). + You can render the Instamojo checkout form and collect payments on your webpage using the instamojo-payment-url obtained from `createPaymentRequest()` using our JS based seamless checkout library. To know more about how it works [Click here](https://docs.instamojo.com/page/seamless-checkout). ## Payment Request Creation Parameters @@ -77,8 +82,8 @@ This will give you JSON object containing details of the Payment Request that wa * `redirect_url`: set this to a thank-you page on your site. Buyers will be redirected here after successful payment. * `webhook`: set this to a URL that can accept POST requests made by Instamojo server after successful payment. * `allow_repeated_payments`: To disallow multiple successful payments on a Payment Request pass `false` for this field. If this is set to `false` then the link is not accessible publicly after first successful payment, though you can still access it using API(default value: `true`). - * `partner_fee_type` : Allows you to receive a cut from from payments you facilitate. For fixed fee set this to `fixed`, or for percentage fee set it to `percent`. - * `partner_fee` : This describes the fee that you would collect. It can be either a fixed amount, or a percentage of the original amount, depending on the value of `partner_fee_type`. + * `partner_fee_type` : Allows you to receive a cut from the payments you facilitate. For fixed fee set this to `fixed`, or for percentage fee set it to `percent`. + * `partner_fee` : This is a double data type key which describes the fee that you would collect. It can be either a fixed amount, or a percentage of the original amount, depending on the value of `partner_fee_type`. * `mark_fulfilled` : Flag to determine if you want to put the payment on hold until you explicitly fulfil it. If `mark_fulfilled` is `True` the payment will be paid out to the merchant. If `mark_fulfilled` is `False`, then the payment will be put on hold until you explicitly fulfil the payment. See Fulfil a Payment below on how to fulfil a payment. * `expires_at` : Time after which the payment request will be expired in UTC timestamp. Max value is 600 seconds. Default is Null. @@ -214,7 +219,7 @@ catch (Exception $e) { ``` `$payment_request_id` id the `id` key obtained in `createPaymentRequest()` method. -This will give you JSON object containing with created `order_id` key. +This will give you JSON object that contains newly created order id in `order_id` key. ### Get the details of a Gateway Order @@ -292,7 +297,7 @@ catch (Exception $e) { } ``` -This will give you JSON object containing details of the Refund. +This will give you JSON object containing details of the Refund. @@ -309,7 +314,7 @@ catch (Exception $e) { } ``` -This will give you an array containing Refunds details so far. +This will give you an array containing Refunds details so far. getRefunds() also accepts optional parameters for pagination. diff --git a/main.php b/main.php index 6cf51db..8be59b7 100644 --- a/main.php +++ b/main.php @@ -9,15 +9,7 @@ ],true); - // $transaction_id = "TEST_".time(); - // var_dump([ - // "name" => "XYZ", - // "email" => "xyz@squareboat.com", - // "phone" => "9999999988", - // "amount" => 200, - // "transaction_id" => $transaction_id, - // "currency" => "INR" - // ]); + $payment_request = $instaobj->createPaymentRequest([ 'amount'=>10, @@ -29,11 +21,9 @@ "292e38e570794fa592ccf74cc84c8fda", [ "name" => "XYZ", - "email" => "xyz@squareboat.com", + "email" => "foo@Foo.com", "phone" => "9999999988", - // "amount" => 200, - // "transaction_id" => $transaction_id, - // "currency" => "INR" + ]); var_dump(json_encode($gateway_order)); diff --git a/src/Instamojo.php b/src/Instamojo.php index fe0cb9e..0d3de3c 100644 --- a/src/Instamojo.php +++ b/src/Instamojo.php @@ -176,13 +176,7 @@ public function __toString() */ static function init($type='app', $params, $test=false) { - // $scope = isset($params['scope']) ? $params['scope'] : NULL; - - // if (self::$thisObj != null && (self::$scope == $scope || $scope == NULL ) ) { - - // return self::$thisObj; - - // } else { + self::validateTypeParams($type, $params); self::$authType = $type; @@ -206,7 +200,7 @@ static function init($type='app', $params, $test=false) self::$scope = isset($auth_response['scope']) ? $auth_response['scope'] : ''; return self::$thisObj; - // } + } /** diff --git a/tests/unit/GatewayOrderTest.php b/tests/unit/GatewayOrderTest.php index 8c8eb3d..73a03aa 100644 --- a/tests/unit/GatewayOrderTest.php +++ b/tests/unit/GatewayOrderTest.php @@ -20,7 +20,7 @@ public function test_create_a_gateway_order() $gateway_order = $this->instaobj->createGatewayOrder([ "name" => "XYZ", - "email" => "xyz@squareboat.com", + "email" => "xyz@foo.com", "phone" => "9999999988", "amount" => "200", "transaction_id" => $transaction_id,