Skip to content
This repository was archived by the owner on Feb 23, 2023. It is now read-only.

Commit d17d178

Browse files
authored
MGI Tutorial: add imports to code examples (#697)
1 parent 2baf4f9 commit d17d178

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

content/docs/tutorials/moneygram-access-integration-guide.mdx

+20-3
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ The following code demonstrates how to implement the application’s side of thi
122122

123123

124124
```python
125+
import requests
126+
from stellar_sdk import Network
127+
from stellar_sdk.sep.stellar_web_authentication import read_challenge_transaction
128+
125129
def get_token() -> str:
126130
query = f"{AUTH_URL}?account={AUTH_PUBLIC_KEY}&memo={USER_ID}"
127131
response = requests.get(query)
@@ -165,6 +169,8 @@ The following code can be used as a reference for implementing this logic yourse
165169

166170

167171
```python
172+
import requests
173+
168174
def initiate_withdraw(token: str, amount: str) -> Tuple[str, str]:
169175
post_body = {
170176
"asset_code": ASSET_CODE, # USDC
@@ -239,6 +245,8 @@ This code uses a simple polling mechanism with no bail-out condition. The applic
239245

240246

241247
```python
248+
import requests
249+
242250
response_body = poll_transaction_until_status(
243251
transaction_id,
244252
token=token,
@@ -292,6 +300,10 @@ Below is highly simplified code for submitting a payment transaction. It does no
292300

293301

294302
```python
303+
from stellar_sdk import (
304+
Server, TransactionBuilder, Network, Asset, IdMemo
305+
)
306+
295307
submit_payment(
296308
destination=response_body["transaction"]["withdraw_anchor_account"],
297309
memo=response_body["transaction"]["withdraw_memo"],
@@ -334,6 +346,9 @@ Note that this code does not handle [path payments] or [claimable balances], two
334346

335347

336348
```python
349+
from stellar_sdk import Server
350+
from .queries import get_transaction_by_memo
351+
337352
def stream_payments(account: str, cursor: str):
338353
s = Server()
339354
payments = s.payments().for_account(account).join("transactions")
@@ -342,14 +357,14 @@ def stream_payments(account: str, cursor: str):
342357
payment["type"] != "payment"
343358
or payment["from"] == account
344359
or payment["asset_type"] == "native"
345-
or payment["asset_code"] != "USDC"
346-
or payment["asset_issuer"] != USDC_ISSUER
360+
or payment["asset_code"] != ASSET_CODE
361+
or payment["asset_issuer"] != ASSET_ISSUER
347362
):
348363
continue
349364
transaction = get_transaction_by_memo(
350365
payment["transaction"]["memo"],
351366
payment["transaction"]["memo_type"]
352-
)
367+
) # DB query
353368
if not transaction:
354369
continue
355370
print(
@@ -374,6 +389,8 @@ Note that MoneyGram’s transaction details page is protected with a JWT token i
374389

375390

376391
```python
392+
from .api import poll_transction_until_status
393+
377394
response_body = poll_transaction_until_status(
378395
transaction_id,
379396
"pending_user_transfer_complete"

0 commit comments

Comments
 (0)